<commit_before>(function ($) {
  if (window.MegaHAL === undefined || window.MegaHAL === null) {
    MegaHAL = window.Agworld = {};
  }
  MegaHAL.init = function() {
    $("#username").on("shown.bs.modal", function(){
      $("input#name").focus();
    });
    $("#username").modal({
      keyboard: false,
      backdrop: "static"
    });
    $("form#name").on("submit", function(){
      $("#username").modal('hide');
      $("#spinner").show();
      MegaHAL.chat($("input#name").val() || "Anon");
      return false;
    });
    $("form#user").on("submit", function(){
      $("#input").hide();
      $("#spinner").show();
      MegaHAL.user($("#input").val());
      return false;
    });
  };
  MegaHAL.chat = function(name) {
    _gaq.push(['_trackPageview', "api/chats"])
    request = $.ajax({
      url: "api/chats",
      type: "POST",
      data: { user: name },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      MegaHAL.key = data.chat.key;
      MegaHAL.name = name;
      $("#log").append('<div class="utterance alert alert-success role="alert"><span class="name">' + name + ':</span> Started a new chat.</div>');
      window.onbeforeunload = function(e) {
        return 'Your chat with MegaHAL will end.';
      };
      $('body').scrollTop($('body')[0].scrollHeight);
      setTimeout("MegaHAL.ping();", 800);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      data = jqXHR.responseJSON;
      for (i = 0; i < data.length; i++) {
        $("#log").append('<div class="utterance alert alert-danger role="alert"><span class="name">Error:</span> ' + data[i] + '</div>');
      }
      $('body').scrollTop($('body')[0].scrollHeight);
    });
  };
  MegaHAL.ping = function() {
    request = $.ajax({
      url: "api/replies",
      type: "POST",
      data: { key: MegaHAL.key },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      _gaq.push(['_trackPageview', "api/replies"])
      reply = data.reply.text;
      $("#log").append('<p class="mh10 utterance"><span class="name">MegaHAL:</span> ' + reply + '</p>');
      $("#input").val("");
      $("#spinner").hide();
      $("#input").show();
      $("#input").focus();
      $('body').scrollTop($('body')[0].scrollHeight);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      setTimeout("MegaHAL.ping();", 800)
    });
  };
  MegaHAL.user = function(text) {
    _gaq.push(['_trackPageview', "api/inputs"])
    request = $.ajax({
      url: "api/inputs",
      type: "POST",
      data: { key: MegaHAL.key, text: text },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      $("#log").append('<p class="user utterance"><span class="name">' + MegaHAL.name + ':</span> ' + text + '</p>');
      setTimeout("MegaHAL.ping();", 800);
      $('body').scrollTop($('body')[0].scrollHeight);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      data = jqXHR.responseJSON;
      for (i = 0; i < data.length; i++) {
        $("#log").append('<div class="utterance alert alert-danger role="alert"><span class="name">Error:</span> ' + data[i] + '</div>');
      }
      $('body').scrollTop($('body')[0].scrollHeight);
    });
  };
}(jQuery))<commit_msg>sanitisation<commit_after>(function ($) {
  if (window.MegaHAL === undefined || window.MegaHAL === null) {
    MegaHAL = window.Agworld = {};
  }
  MegaHAL.init = function() {
    $("#username").on("shown.bs.modal", function(){
      $("input#name").focus();
    });
    $("#username").modal({
      keyboard: false,
      backdrop: "static"
    });
    $("form#name").on("submit", function(){
      $("#username").modal('hide');
      $("#spinner").show();
      MegaHAL.chat($("input#name").val() || "Anon");
      return false;
    });
    $("form#user").on("submit", function(){
      $("#input").hide();
      $("#spinner").show();
      MegaHAL.user($("#input").val());
      return false;
    });
  };
  MegaHAL.chat = function(name) {
    _gaq.push(['_trackPageview', "api/chats"])
    request = $.ajax({
      url: "api/chats",
      type: "POST",
      data: { user: name },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      MegaHAL.key = data.chat.key;
      MegaHAL.name = name;
      $("#log").append('<div class="utterance alert alert-success role="alert"><span class="name"></span> Started a new chat.</div>');
      $("#log").children().last().find(".name").text(name + ":");
      window.onbeforeunload = function(e) {
        return 'Your chat with MegaHAL will end.';
      };
      $('body').scrollTop($('body')[0].scrollHeight);
      setTimeout("MegaHAL.ping();", 800);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      data = jqXHR.responseJSON;
      for (i = 0; i < data.length; i++) {
        $("#log").append('<div class="utterance alert alert-danger role="alert"><span class="name">Error:</span> <span class="message"></span></div>');
        $("#log").children().last().find(".message").text(data[i]);
      }
      $('body').scrollTop($('body')[0].scrollHeight);
    });
  };
  MegaHAL.ping = function() {
    request = $.ajax({
      url: "api/replies",
      type: "POST",
      data: { key: MegaHAL.key },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      _gaq.push(['_trackPageview', "api/replies"])
      reply = data.reply.text;
      $("#log").append('<p class="mh10 utterance"><span class="name">MegaHAL:</span> <span class="message"></span></p>');
      $("#log").children().last().find(".message").text(reply);
      $("#input").val("");
      $("#spinner").hide();
      $("#input").show();
      $("#input").focus();
      $('body').scrollTop($('body')[0].scrollHeight);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      setTimeout("MegaHAL.ping();", 800)
    });
  };
  MegaHAL.user = function(text) {
    _gaq.push(['_trackPageview', "api/inputs"])
    request = $.ajax({
      url: "api/inputs",
      type: "POST",
      data: { key: MegaHAL.key, text: text },
      accepts: "json",
      dataType: "json"
    });
    request.done(function(data) {
      $("#log").append('<p class="user utterance"><span class="name"></span> <span class="message"></span></p>');
      $("#log").children().last().find(".name").text(MegaHAL.name + ":");
      $("#log").children().last().find(".message").text(text);
      setTimeout("MegaHAL.ping();", 800);
      $('body').scrollTop($('body')[0].scrollHeight);
    });
    request.fail(function(jqXHR, textStatus, errorThrown) {
      data = jqXHR.responseJSON;
      for (i = 0; i < data.length; i++) {
        $("#log").append('<div class="utterance alert alert-danger role="alert"><span class="name">Error:</span> <span class="message"></span></div>');
        $("#log").children().last().find(".message").text(data[i]);
      }
      $('body').scrollTop($('body')[0].scrollHeight);
    });
  };
}(jQuery))
{'fraction_non_alphanumeric': 0.24377046846077174, 'fraction_numerical': 0.0051260145237078175, 'mean_word_length': 3.0344629523262494, 'pattern_counts': {'":': 2, '<': 55, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4419200', 'n_tokens_mistral': 2317, 'n_tokens_neox': 2327, 'n_words': 375}