<commit_before>require 'active_support/core_ext/module/delegation'
require 'flavour_saver'
require 'hashie/mash'

FS.register_helper :adjust_iframe_height_script do
  <<-HTML.strip_heredoc.html_safe
    <script>$(function() {
      height = this.body.offsetHeight + 30;
      parent.postMessage(JSON.stringify({height: height, id: name}), "*");
    });</script>
  HTML
end

FS.register_helper :data_download do
  json = this.to_json

  <<-HTML.strip_heredoc.html_safe
    <script src="/stanza/assets/FileSaver.js"></script>
    <script src="/stanza/assets/canvas-toBlob.js"></script>

    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/StackBlur.js"></script>
    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script>

    <script>$(function() {
      $('body').append("<div id='stanza_buttons'></div>");
      $("div#stanza_buttons").append("<button id='download_json' class='btn btn-mini' href='#'><i class='icon-font'></i> Save json</button>");
      $("div#stanza_buttons").append("<button id='download_svg' class='btn btn-mini' href='#'><i class='icon-font'></i> Save image(svg)</button>");
      $("div#stanza_buttons").append("<button id='download_image' class='btn btn-mini' href='#'><i class='icon-picture'></i> Save image(png)</button>");

      $("body").append("<div style='display: none;'><canvas id='drawarea'></canvas></div>");

      $("#download_json").on("click",function(){
        var blob = new Blob([JSON.stringify(#{json}, "", "\t")], {type: "text/plain;charset=utf-8"});
        saveAs(blob, "data.json");
      });

      $("#download_svg").on("click",function(){
        if ($("svg")[0]) {
          var svgText = $("svg")[0].outerHTML;
          var blob = new Blob([svgText], {type: "image/svg+xml;charset=utf-8"});
          saveAs(blob, "data.svg");
        }
      });<commit_msg>Delete css_uri key from json<commit_after>require 'active_support/core_ext/module/delegation'
require 'flavour_saver'
require 'hashie/mash'

FS.register_helper :adjust_iframe_height_script do
  <<-HTML.strip_heredoc.html_safe
    <script>$(function() {
      height = this.body.offsetHeight + 30;
      parent.postMessage(JSON.stringify({height: height, id: name}), "*");
    });</script>
  HTML
end

FS.register_helper :data_download do
  this.delete(:css_uri)
  json =  this.to_json

  <<-HTML.strip_heredoc.html_safe
    <script src="/stanza/assets/FileSaver.js"></script>
    <script src="/stanza/assets/canvas-toBlob.js"></script>

    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/StackBlur.js"></script>
    <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script>

    <script>$(function() {
      $('body').append("<div id='stanza_buttons'></div>");
      $("div#stanza_buttons").append("<button id='download_json' class='btn btn-mini' href='#'><i class='icon-font'></i> Save json</button>");
      $("div#stanza_buttons").append("<button id='download_svg' class='btn btn-mini' href='#'><i class='icon-font'></i> Save image(svg)</button>");
      $("div#stanza_buttons").append("<button id='download_image' class='btn btn-mini' href='#'><i class='icon-picture'></i> Save image(png)</button>");

      $("body").append("<div style='display: none;'><canvas id='drawarea'></canvas></div>");

      $("#download_json").on("click",function(){
        var blob = new Blob([JSON.stringify(#{json}, "", "\t")], {type: "text/plain;charset=utf-8"});
        saveAs(blob, "data.json");
      });

      $("#download_svg").on("click",function(){
        if ($("svg")[0]) {
          var svgText = $("svg")[0].outerHTML;
          var blob = new Blob([svgText], {type: "image/svg+xml;charset=utf-8"});
          saveAs(blob, "data.svg");
        } else {
          // TODO...
          alert('Sorry');
        }
      });
{'fraction_non_alphanumeric': 0.21861152141802068, 'fraction_numerical': 0.0029542097488921715, 'mean_word_length': 4.097867001254705, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5276644', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1357, 'n_words': 198}