<commit_before>const socket = new WebSocket('ws://' + location.hostname + ':' + location.port);

socket.addEventListener('open', function () {
  console.log('socket opened');
});

if (document.querySelector('.index')) {
  console.log('Homepage');
} else if (document.querySelector('.controller')) {
  document.querySelector('form').addEventListener('submit', onButtonPress);

  /**
   * Send an update score request to the server
   */
  function onButtonPress(event) {
    socket.send(
      JSON.stringify({
        device: 'phone',
        action: 'UPDATE_SCORE',
        gameID: document.querySelector('[name="gameID"]').value,
        playerID: document.querySelector('[name="playerID"').value
      })
    );

    event.preventDefault();
  }
} else if (document.querySelector('.new-player')) {
  console.log('New Player');
}
<commit_msg>Re-render home from vDom<commit_after>const diff = require('virtual-dom/diff');
const patch = require('virtual-dom/patch');
const createElement = require('virtual-dom/create-element');
const render = require('../render');
const socket = new WebSocket('ws://' + location.hostname + ':' + location.port);

socket.addEventListener('open', function () {
  console.log('socket opened');
});

if (document.querySelector('.index')) {
  replaceView('index');
} else if (document.querySelector('.controller')) {
  document.querySelector('form').addEventListener('submit', onButtonPress);

  /**
   * Send an update score request to the server
   */
  function onButtonPress(event) {
    socket.send(
      JSON.stringify({
        device: 'phone',
        action: 'UPDATE_SCORE',
        gameID: document.querySelector('[name="gameID"]').value,
        playerID: document.querySelector('[name="playerID"').value
      })
    );

    event.preventDefault();
  }
} else if (document.querySelector('.new-player')) {
  console.log('New Player');
}

function replaceView(view) {
  initialData = JSON.parse(initialData);

  let tree = render(view, ...initialData);
  let rootNode = createElement(tree);

  document.body.replaceChild(rootNode, document.querySelector('[data-root]'));
}

{'fraction_non_alphanumeric': 0.17179365830572646, 'fraction_numerical': 0.0, 'mean_word_length': 4.168704156479218, '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': '1622969', 'n_tokens_mistral': 592, 'n_tokens_neox': 602, 'n_words': 116}