<commit_before>var playerName;
var socket;

window.onload = function () {
	document.getElementById("startButton").onclick = function () {
		var tmpName = document.getElementById("playerNameInput").value;
		playerName = tmpName.replace(/(<([^>]+)>)/ig, "");
		document.getElementById("gameAreaWrapper").style.display = "block";
		document.getElementById("startMenuWrapper").style.display = "none";
		socket = io();
		SetupSocket(socket);
		animloop();
	}
}


// Canvas
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
var gameWidth = screenWidth * 3;
var gameHeight = screenHeight * 3;
var xoffset = -gameWidth;
var yoffset = -gameHeight;

var gameStart = false;
var disconnected = false;

var startPingTime = 0;

var KEY_ENTER = 13;

var chatCommands = {};
var backgroundColor = "#EEEEEE";

var foodConfig = {
  border: 2,
  borderColor: "#f39c12",
  fillColor: "#f1c40f",
  size: 5
};

var playerConfig = {
  border: 3,
  borderColor: "#c0392b",
  fillColor: "#ea6153",
  textColor: "#FFFFFF",
  textBorder: "#000000",
  textBorderSize: 3,
  defaultSize: 10
};

var enemyConfig = {
  border: 3,
  borderColor: "#27ae60",
  fillColor: "#2ecc71",
  textColor: "#FFFFFF",
  textBorder: "#000000",
  textBorderSize: 3,
  defaultSize: 10
};

var player = {
  id: -1,
  x: gameWidth / 2, y: gameHeight / 2,
  mass: 0, speed: 5,
  //TODO: exclude width and height out of player package
  screenWidth: screenWidth,
  screenHeight: screenHeight,
  gameWidth: gameWidth,
  gameHeight: gameHeight
};

var foods = [];
var enemies = [];
var target = {x: player.x, y: player.y};

var c = document.getElementById("cvs");
c.addEventListener("mousemove", gameInput, false);
c.width = screenWidth; c.height = screenHeight;

var graph = c.getContext("2d");

var chatInput = document.getElementById("chatInput");
chatInput.addEventListener("keypress", sendChat);

// Chat
function addChatLine(name, text) {
  var chatLine = document.createElement("li");
  chatLine.className = (name == player.name)?"me":"friend";
  chatLine.innerHTML = "<b>" + name + "</b>: " + text;
  var chatList = document.getElementById("chatList");
  chatList.insertBefore(chatLine, chatList.childNodes[0]);
}

function addSystemLine(text) {
  var chatLine = document.createElement("li");
  chatLine.className = "system";
  chatLine.innerHTML = text;
  var chatList = document.getElementById("chatList");
  chatList.insertBefore(chatLine, chatList.childNodes[0]);
}

function registerChatCommand(name, description, callback) {
  chatCommands[name] = {
    description: description,
    callback: callback
  };
}

function checkLatency() {
  // Ping
  startPingTime = Date.now();
  socket.emit("ping");
}

function toggleDarkMode(args) {
  var LIGHT = '#EEEEEE';
  var DARK = '#181818';
  var on = args[0] === 'on';
  var off = args[0] === 'off';

  if (on || (!off && backgroundColor === LIGHT)) {
    backgroundColor = DARK;<commit_msg>Make chat more intuitive<commit_after>var playerName;
var socket;

window.onload = function () {
	document.getElementById("startButton").onclick = function () {
		var tmpName = document.getElementById("playerNameInput").value;
		playerName = tmpName.replace(/(<([^>]+)>)/ig, "");
		document.getElementById("gameAreaWrapper").style.display = "block";
		document.getElementById("startMenuWrapper").style.display = "none";
		socket = io();
		SetupSocket(socket);
		animloop();
	}
}


// Canvas
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
var gameWidth = screenWidth * 3;
var gameHeight = screenHeight * 3;
var xoffset = -gameWidth;
var yoffset = -gameHeight;

var gameStart = false;
var disconnected = false;

var startPingTime = 0;

var KEY_ENTER = 13;

var chatCommands = {};
var backgroundColor = "#EEEEEE";

var foodConfig = {
  border: 2,
  borderColor: "#f39c12",
  fillColor: "#f1c40f",
  size: 5
};

var playerConfig = {
  border: 3,
  borderColor: "#c0392b",
  fillColor: "#ea6153",
  textColor: "#FFFFFF",
  textBorder: "#000000",
  textBorderSize: 3,
  defaultSize: 10
};

var enemyConfig = {
  border: 3,
  borderColor: "#27ae60",
  fillColor: "#2ecc71",
  textColor: "#FFFFFF",
  textBorder: "#000000",
  textBorderSize: 3,
  defaultSize: 10
};

var player = {
  id: -1,
  x: gameWidth / 2, y: gameHeight / 2,
  mass: 0, speed: 5,
  //TODO: exclude width and height out of player package
  screenWidth: screenWidth,
  screenHeight: screenHeight,
  gameWidth: gameWidth,
  gameHeight: gameHeight
};

var foods = [];
var enemies = [];
var target = {x: player.x, y: player.y};

var c = document.getElementById("cvs");
c.addEventListener("mousemove", gameInput, false);
c.width = screenWidth; c.height = screenHeight;

var graph = c.getContext("2d");

var chatInput = document.getElementById("chatInput");
chatInput.addEventListener("keypress", sendChat);

// Chat
function addChatLine(name, text) {
  var chatLine = document.createElement("li");
  chatLine.className = (name == player.name)?"me":"friend";
  chatLine.innerHTML = "<b>" + name + "</b>: " + text;
  var chatList = document.getElementById("chatList");
  if (chatList.childNodes.length >=5) {
    chatList.removeChild(chatList.childNodes[0]);
  }
  chatList.appendChild(chatLine);
}

function addSystemLine(text) {
  var chatLine = document.createElement("li");
  chatLine.className = "system";
  chatLine.innerHTML = text;
  var chatList = document.getElementById("chatList");
  if (chatList.childNodes.length >=5) {
    chatList.removeChild(chatList.childNodes[0]);
  }
  chatList.appendChild(chatLine, chatList.childNodes[0]);
}

function registerChatCommand(name, description, callback) {
  chatCommands[name] = {
    description: description,
    callback: callback
  };
}

function checkLatency() {
  // Ping
  startPingTime = Date.now();
  socket.emit("ping");
}

function toggleDarkMode(args) {
  var LIGHT = '#EEEEEE';
  var DARK = '#181818';
  var on = args[0] === 'on';
  var off = args[0] === 'off';

  if (on || (!off && backgroundColor === LIGHT)) {
    backgroundColor = DARK;
{'fraction_non_alphanumeric': 0.15471635335218767, 'fraction_numerical': 0.022126102146065547, 'mean_word_length': 4.587360594795539, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, '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': '4391978', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1956, 'n_words': 473}