<commit_before>;(function() {

  var DPad = function() {
    this.socket = null;
    this.currentAction = '';
    this.currentDirection = '';
    this.currentId = '';
    this.dataReceived = null;
    this.playerName = '';
  };
  DPad.prototype = {
    initSocketConnection: function() {
      var self = this;

      this.remoteAddress = document.getElementById('ip-input').value;
      this.socket = new WebSocket('ws://' + this.remoteAddress + ':9000');

      this.socket.onopen = function() {
          this.isopen = true;
          console.log("Connected!");

          self.sendAction('want-to-play');
      }

      this.socket.onmessage = function(e) {
          var dpadContainer = document.getElementById('container-dpad'),
              playerType = document.getElementById('type-of-player'),
              htmlObject = document.getElementsByTagName('html')[0],
              form = document.getElementsByTagName('form')[0];

          self.dataReceived = JSON.parse(e.data);
          console.log(e.data);

          if (
            self.dataReceived &&
            self.dataReceived.role &&
            self.dataReceived.color
          ) {
            //Hide form, show the d-pad, update the player type and applies the color
            dpadContainer.style.display = 'block';
            playerType.innerHTML = (self.dataReceived.role).toUpperCase();
            htmlObject.style.background = self.dataReceived.color;
          }
      }

      this.socket.onclose = function(e) {
          var errorMessage = document.getElementById('error-message')
              dpadContainer = document.getElementById('container-dpad'),
              playerType = document.getElementById('type-of-player'),
              htmlObject = document.getElementsByTagName('html')[0],
              form = document.getElementsByTagName('form')[0];

          //Restart the initial value
          dpadContainer.style.display = 'none';
          playerType.innerHTML = '';
          htmlObject.style.background = 'dimgrey';
          errorMessage.innerHTML = 'Connection closed';
          console.log("Connection closed.");

      }
    },
    restartData: function() {
        this.socket = null;
        this.currentAction = '';
        this.currentDirection = '';
        this.currentId = '';
        this.dataReceived = null;
        this.isopen = false;
        this.playerName = '';
    },
    enable: function(option) {
      var nameInput = document.getElementById('name-input'),
          errorMessage = document.getElementById('error-message');

      if (option) {
        if (nameInput.value !== '') {
            errorMessage.innerHTML = '';
            this.playerName = nameInput.value;<commit_msg>switch off when close connection<commit_after>;(function() {

  var DPad = function() {
    this.socket = null;
    this.currentAction = '';
    this.currentDirection = '';
    this.currentId = '';
    this.dataReceived = null;
    this.playerName = '';
  };
  DPad.prototype = {
    initSocketConnection: function() {
      var self = this;

      this.remoteAddress = document.getElementById('ip-input').value;
      this.socket = new WebSocket('ws://' + this.remoteAddress + ':9000');

      this.socket.onopen = function() {
          this.isopen = true;
          console.log("Connected!");

          self.sendAction('want-to-play');
      }

      this.socket.onmessage = function(e) {
          var dpadContainer = document.getElementById('container-dpad'),
              playerType = document.getElementById('type-of-player'),
              htmlObject = document.getElementsByTagName('html')[0],
              form = document.getElementsByTagName('form')[0];

          self.dataReceived = JSON.parse(e.data);
          console.log(e.data);

          if (
            self.dataReceived &&
            self.dataReceived.role &&
            self.dataReceived.color
          ) {
            //Hide form, show the d-pad, update the player type and applies the color
            dpadContainer.style.display = 'block';
            playerType.innerHTML = (self.dataReceived.role).toUpperCase();
            htmlObject.style.background = self.dataReceived.color;
          }
      }

      this.socket.onclose = function(e) {
          var errorMessage = document.getElementById('error-message')
              dpadContainer = document.getElementById('container-dpad'),
              playerType = document.getElementById('type-of-player'),
              htmlObject = document.getElementsByTagName('html')[0],
              switchOff = document.getElementById("switch-off"),
              form = document.getElementsByTagName('form')[0];

          //Restart the initial value
          switchOff.checked = true;
          dpadContainer.style.display = 'none';
          playerType.innerHTML = '';
          htmlObject.style.background = 'dimgrey';
          errorMessage.innerHTML = 'Connection closed';
          console.log("Connection closed.");

      }
    },
    restartData: function() {
        this.socket = null;
        this.currentAction = '';
        this.currentDirection = '';
        this.currentId = '';
        this.dataReceived = null;
        this.isopen = false;
        this.playerName = '';
    },
    enable: function(option) {
      var nameInput = document.getElementById('name-input'),
          errorMessage = document.getElementById('error-message');

      if (option) {
        if (nameInput.value !== '') {
            errorMessage.innerHTML = '';
            this.playerName = nameInput.value;
{'fraction_non_alphanumeric': 0.12915462427745664, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 2.1603881278538815, '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': '5149585', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1423, 'n_words': 249}