<commit_before>/*-------------------------------------------------------------------------------------*/

window.init_web_sock = _.once(function() {
  connect_websocket();
  keep_trying_to_connect();
});
/*-------------------------------------------------------------------------------------*/
function is_https() {

  var patt = new RegExp("^https:");

  return patt.test(window.location.href);
}
/*-------------------------------------------------------------------------------------*/
function connect_websocket() {

  var scheme = is_https() ? "wss://" : "ws://";

  var uri = settings.web_sock_uri;
  if (uri == null)
    uri = window.document.location.host;
  uri = scheme + uri + "/";

  try {
    window.web_sock = new WebSocket(uri);

    window.web_sock.onmessage = function(message) {

      event = jQuery.parseJSON(message.data);

      console.log(event);
      process_event(event);
    };

    window.web_sock.onopen = function() {
      console.log("websocket connected.");

      window.web_sock.send(JSON.stringify({type: 'total_connections'}));

      /*
      window.web_sock.send(JSON.stringify({
        type: 'subscribe',
        competition_id: window.slam.id
      }));
      */
<commit_msg>reconnect to websocket on each page on change for competition#show<commit_after>/*-------------------------------------------------------------------------------------*/

function init_web_sock() {
  connect_websocket();
  keep_trying_to_connect();
}
/*-------------------------------------------------------------------------------------*/
function is_https() {

  var patt = new RegExp("^https:");

  return patt.test(window.location.href);
}
/*-------------------------------------------------------------------------------------*/
function connect_websocket() {

  var scheme = is_https() ? "wss://" : "ws://";

  var uri = settings.web_sock_uri;
  if (uri == null)
    uri = window.document.location.host;
  uri = scheme + uri + "/";

  try {
    window.web_sock = new WebSocket(uri);

    window.web_sock.onmessage = function(message) {

      event = jQuery.parseJSON(message.data);

      console.log(event);
      process_event(event);
    };

    window.web_sock.onopen = function() {
      console.log("websocket connected.");

      window.web_sock.send(JSON.stringify({type: 'total_connections'}));

      
      window.web_sock.send(JSON.stringify({
        type: 'subscribe',
        competition_id: window.slam.id
      }));

{'fraction_non_alphanumeric': 0.33482506102522375, 'fraction_numerical': 0.0, 'mean_word_length': 1.4788306451612903, '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': '1060408', 'n_tokens_mistral': 670, 'n_tokens_neox': 645, 'n_words': 113}