<commit_before>var gameSocket;
var token;
var console = false;
var world = false;

//connection logic
function connect() {
  var url = "http://localhost:3000";
  if(gameSocket) {
    gameSocket.removeAllListeners();
  }
  if(console) {
    console.detach();
  }
  if(world) {
    world.detach();
  }
  
  if(token) {
    gameSocket = io(url + '/txt-world', {'forceNew': true, 'query': 'token=' + token});
  } else {
    gameSocket = io(url + '/txt-world', {'forceNew': true});
  }
  
  console = new Console(gameSocket);
  world = new World(gameSocket, console);
}

$(document).ready(function () { 
  //get temp token
  $.get("/temp", function(string) {
    token = string;
    connect();
  });
});<commit_msg>Fixed websocket connection for Heroku integration<commit_after>var gameSocket;
var token;
var console = false;
var world = false;

//connection logic
function connect() {
  var url = location.origin;
  if(gameSocket) {
    gameSocket.removeAllListeners();
  }
  if(console) {
    console.detach();
  }
  if(world) {
    world.detach();
  }
  
  if(token) {
    gameSocket = io(url + '/txt-world', {'forceNew': true, 'query': 'token=' + token});
  } else {
    gameSocket = io(url + '/txt-world', {'forceNew': true});
  }
  
  console = new Console(gameSocket);
  world = new World(gameSocket, console);
}

$(document).ready(function () { 
  //get temp token
  $.get("/temp", function(string) {
    token = string;
    connect();
  });
});
{'fraction_non_alphanumeric': 0.17748618784530387, 'fraction_numerical': 0.0027624309392265192, 'mean_word_length': 3.3513513513513513, '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': '1515711', 'n_tokens_mistral': 488, 'n_tokens_neox': 484, 'n_words': 113}