<commit_before>document.addEventListener("DOMContentLoaded", function (event) {

  $("#postmessage").submit(function (e) {

    var data = $("#postmessage").serialize();

    $.post(document.location.href, data, function () {

      $("#words").val("");;

    })

    e.preventDefault();

    return false;

  })

  window.vote = function (e) {

    var button = $(e.target);

    var location = "points/" + $(button).attr("data-message");

    var data = $.param({
      direction: $(button).attr("value"),
      tags: $(button).attr("data-tags")
    })

    var wrapper = $(e.target).closest(".message-wrapper");

    $.post($(wrapper).attr("data-channel") + location, data, function () {

      $(button).attr("disabled", "disabled");

    })

    e.preventDefault();

    return false;

  }

  window.scrollTop = function () {

    $('#chat').scrollTop($('#chat')[0].scrollHeight);

  };

  scrollTop();

  var stateObject = {};

  // Wrapper to check for readystate before sending

  window.sendSocketMessage = function (websocket, message) {

    var sent = false;

    var interval = window.setInterval(function () {
      
      if (sent) {

        window.clearInterval(interval);

      } else {

        if (websocket.readyState === 1) {
          
          websocket.send(message);

          sent = true;

        }

      }

    }, 100)

  };

  window.refresh = function () {

    var currentTags = $('#tags').val();

    document.title = "| Filters | " + currentTags;

    $.get("/meta/refresh/" + $('#tags').val(), function (result) {

      $("#chat")[0].outerHTML = result;

      scrollTop();

      if (!currentTags) {

        history.pushState(stateObject, currentTags, "/");

      } else {

        history.pushState(stateObject, currentTags, currentTags);

      }

      $("#tagField").val(currentTags);

      window.pair();

    })

  }

  var currentTags = document.location.pathname.substring(1).split(",");

  if (currentTags.length === 1 && currentTags[0] === "") {

    currentTags.length = 0;

  }

  $('#tags').tagsInput({
    width: "100%",
    onChange: window.refresh(),
    defaultText: "",
    tagValidator: function (tag) {

      function isValid(str) {
        return /^[a-z\d\-_=@!]+$/i.test(str);
      }

      if (!isValid(tag)) {


        return false;

      } else {

        return true;

      }

    },
    onRemoveTag: window.refresh,
    onAddTag: window.refresh
  });

  // Websocket stuff

  if (window.WebSocket) {

    var connectSocket = function (channel, local, secure) {

      var websocket;

      window.pair = function () {

        var message = {
          type: "pair",
          tags: document.location.pathname,
          user: window.loggedIn
        };

        window.sendSocketMessage(websocket, JSON.stringify(message));

      };

      if (secure) {

        websocket = new WebSocket("wss://" + channel);

      } else {

        websocket = new WebSocket("ws://" + channel);

      }

      websocket.onmessage = function (evt) {
        
        if (evt.data) {

          var message = JSON.parse(evt.data);

          if (message.type === "mention") {<commit_msg>Revert "Wait for websocket readystate before pair"<commit_after>document.addEventListener("DOMContentLoaded", function (event) {

  $("#postmessage").submit(function (e) {

    var data = $("#postmessage").serialize();

    $.post(document.location.href, data, function () {

      $("#words").val("");;

    })

    e.preventDefault();

    return false;

  })

  window.vote = function (e) {

    var button = $(e.target);

    var location = "points/" + $(button).attr("data-message");

    var data = $.param({
      direction: $(button).attr("value"),
      tags: $(button).attr("data-tags")
    })

    var wrapper = $(e.target).closest(".message-wrapper");

    $.post($(wrapper).attr("data-channel") + location, data, function () {

      $(button).attr("disabled", "disabled");

    })

    e.preventDefault();

    return false;

  }

  window.scrollTop = function () {

    $('#chat').scrollTop($('#chat')[0].scrollHeight);

  };

  scrollTop();

  var stateObject = {};

  window.refresh = function () {

    var currentTags = $('#tags').val();

    document.title = "| Filters | " + currentTags;

    $.get("/meta/refresh/" + $('#tags').val(), function (result) {

      $("#chat")[0].outerHTML = result;

      scrollTop();

      if (!currentTags) {

        history.pushState(stateObject, currentTags, "/");

      } else {

        history.pushState(stateObject, currentTags, currentTags);

      }

      $("#tagField").val(currentTags);

      window.pair();

    })

  }

  var currentTags = document.location.pathname.substring(1).split(",");

  if (currentTags.length === 1 && currentTags[0] === "") {

    currentTags.length = 0;

  }

  $('#tags').tagsInput({
    width: "100%",
    onChange: window.refresh(),
    defaultText: "",
    tagValidator: function (tag) {

      function isValid(str) {
        return /^[a-z\d\-_=@!]+$/i.test(str);
      }

      if (!isValid(tag)) {


        return false;

      } else {

        return true;

      }

    },
    onRemoveTag: window.refresh,
    onAddTag: window.refresh
  });

  // Websocket stuff

  if (window.WebSocket) {

    var connectSocket = function (channel, local, secure) {

      var websocket;

      window.pair = function () {

        var message = {
          type: "pair",
          tags: document.location.pathname,
          user: window.loggedIn
        };

        websocket.send(JSON.stringify(message));

      };

      if (secure) {

        websocket = new WebSocket("wss://" + channel);

      } else {

        websocket = new WebSocket("ws://" + channel);

      }

      websocket.onmessage = function (evt) {

        if (evt.data) {

          var message = JSON.parse(evt.data);


          if (message.type === "mention") {
{'fraction_non_alphanumeric': 0.17641060503059144, 'fraction_numerical': 0.0037389530931339226, 'mean_word_length': 2.274902615470228, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1152720', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1733, 'n_words': 341}