<commit_before><!DOCTYPE html>
<html>
<head>
  <title>Intermediate action</title>

  <%= javascript_include_tag "intermediate" %>

  <%= javascript_include_tag "#{FactlinkUI::Application.config.static_url}/lib/dist/easyXDM/easyXDM.min.js" %>
  <style type="text/css">
    html, body {
      height: 100%;
      width: 100%;
      margin: 0 auto;
      padding: 0;
      overflow: hidden;
    }

    iframe {
      height: 100%;
      width: 100%;
      border: 0;
      z-index: 2147483646;
    }

    iframe.overlay {
      background: transparent;
    }

    form {
      display: none;
    }
  </style>

  <%= csrf_meta_tag %>
</head>
<body>
  <!-- THIS FORM IS DEPRECATED -->
  <%= form_for(facts_path, :url => facts_path, :as => :post, :html => { :target => "frame", :id => "form"}) do |f| %>
    <input type="hidden" name="evidence_id" id="evidence_id" value="">
    <input type="text" name="url" id="url" value="">
    <input type="text" name="title" id="title" value="">
    <input type="text" name="opinion" id="opinion" value="">
    <textarea name="passage" id="passage">
    </textarea>
    <input type="text" name="fact" id="fact" value="">
  <% end %>
  <iframe src="" name="frame" id="frame"></iframe>

  <script type="text/javascript">
    var // The iFrame
        showFrame = document.getElementById("frame"),
        // The global remote object
        remote = new easyXDM.Rpc({}, {
          remote: {
            hide: {},
            show: {},
            highlightNewFactlink: {},
            stopHighlightingFactlink: {}
          },
          local: {
            // DEPRECATED
            createEvidence: function(evidence_id, url, type, title) {

              getTopIntermediatePage().submitEvidenceToShowFrame(type, evidence_id);
            },
            // DEPRECATED
            createNewEvidence: function(fact, passage, url, type, title) {
              if (opinion !== undefined) {
                document.getElementById("opinion").value = opinion;
              }


              getTopIntermediatePage().submitNewEvidenceToShowFrame(type, fact, passage, url, title);
            },
            showFactlink: function(id, successFn) {
              showFrame.onload = function() {
                showFrame.onload = undefined;
                successFn();
              };

              // Set the source of the iframe
              showFrame.src = "/facts/" + id;
              // Show the overlay
              showFrame.className = "overlay";
            },
            position: function(top, left) {
              try {
                showFrame.contentWindow.position(top, left);
              } catch (e) { // Window not yet loaded
                showFrame.onload = function() {
                  showFrame.contentWindow.position(top, left);
                };
              }
            },
            //easyXDM does not support passing functions wrapped in objects (such as options in this case)
            // so therefore we need this workaround
            ajax: function(path, options, successFn, errorFn) {

              ajax(path, $.extend({
                success: successFn,
                error: errorFn
              },options));
            }
          }
        });

    function ajax(path, options) {
      $.ajax(path, $.extend({
        headers: {
          'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
        }
      }, options));
    }

    function getTopIntermediatePage() {
      var proxiedPage = parent;
      var proxyContainer = proxiedPage.parent;
      var showFactlinkContainer = proxyContainer.parent;
      return showFactlinkContainer.parent; //(same source as current page)
    }



    function submitEvidenceToShowFrame(type, evidence_id) {
      var fact_id = showFrame.contentWindow.fact_id;
      var script = document.createElement("script");

      script.src = "<%= add_evidence_path %>?type=" + type + "&fact_id=" + fact_id + "&evidence_id=" + evidence_id;
      script.type = "text/javascript";

      showFrame.contentWindow.document.getElementsByTagName('head')[0].appendChild(script);
    }

    function submitNewEvidenceToShowFrame(type, fact, passage, url, title) {
      var fact_id = showFrame.contentWindow.fact_id;
      var script = document.createElement("script");

      // Todo: should be done using POST
      script.src = "<%= create_fact_as_evidence_path %>?type=" + type + "&fact=" + fact + "&url=" + escape(url) + "&passage=" + passage + "&fact_id=" + fact_id + "&title=" + title;
      script.type = "text/javascript";

      showFrame.contentWindow.document.getElementsByTagName('head')[0].appendChild(script);
    }

    function openNewProxyWindow(search_params) {
      var doc = showFrame.contentWindow.document;
      window.proxyFrame = document.createElement("iframe");

      window.proxyFrame.className = "proxyFrame";
      window.proxyFrame.src = "<%= FactlinkUI::Application.config.proxy_url %>/search?query=" + search_params + "&factlinkModus=addToFact";

      doc.getElementsByTagName("body")[0].appendChild(window.proxyFrame);
    }

    function hideProxyWindow() {
      window.proxyFrame.style.display = "none";
      window.proxyFrame.src = "<%= FactlinkUI::Application.config.proxy_url %>/?url=http://www.google.com&factlinkModus=addToFact";
    }

  </script>
</body>
</html><commit_msg>CLEAN-UP > Removed unused functionality in the intermediate<commit_after><!DOCTYPE html>
<html>
<head>
  <title>Intermediate action</title>

  <%= javascript_include_tag "intermediate" %>

  <%= javascript_include_tag "#{FactlinkUI::Application.config.static_url}/lib/dist/easyXDM/easyXDM.min.js" %>
  <style type="text/css">
    html, body {
      height: 100%;
      width: 100%;
      margin: 0 auto;
      padding: 0;
      overflow: hidden;
    }

    iframe {
      height: 100%;
      width: 100%;
      border: 0;
      z-index: 2147483646;
    }

    iframe.overlay {
      background: transparent;
    }

    form {
      display: none;
    }
  </style>

  <%= csrf_meta_tag %>
</head>
<body>
  <iframe src="" name="frame" id="frame"></iframe>

  <script type="text/javascript">
    var // The iFrame
        showFrame = document.getElementById("frame"),
        // The global remote object
        remote = new easyXDM.Rpc({}, {
          remote: {
            hide: {},
            show: {},
            highlightNewFactlink: {},
            stopHighlightingFactlink: {}
          },
          local: {
            showFactlink: function(id, successFn) {
              showFrame.onload = function() {
                showFrame.onload = undefined;
                successFn();
              };

              // Set the source of the iframe
              showFrame.src = "/facts/" + id;
              // Show the overlay
              showFrame.className = "overlay";
            },
            position: function(top, left) {
              try {
                showFrame.contentWindow.position(top, left);
              } catch (e) { // Window not yet loaded
                showFrame.onload = function() {
                  showFrame.contentWindow.position(top, left);
                };
              }
            },
            //easyXDM does not support passing functions wrapped in objects (such as options in this case)
            // so therefore we need this workaround
            ajax: function(path, options, successFn, errorFn) {
              ajax(path, $.extend({
                success: successFn,
                error: errorFn
              },options));
            }
          }
        });

    function ajax(path, options) {
      $.ajax(path, $.extend({
        headers: {
          'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
        }
      }, options));
    }
  </script>
</body>
</html>
{'fraction_non_alphanumeric': 0.1366555355766761, 'fraction_numerical': 0.006807089648086309, 'mean_word_length': 2.052528420227362, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5514796', 'n_tokens_mistral': 2353, 'n_tokens_neox': 2155, 'n_words': 473}