<commit_before>var chat = (function (){
	var chat_ul;
	var input_field;
	var url;

	var chat_request = new XMLHttpRequest();
	var sec_in_day = (24 * 60 * 60);

	function send_message()
	{
		chat_request.open('POST',url,true);

		var msg = input_field.value;
		if (msg != "")
		{
			chat_request.setRequestHeader("Content-type", "text/plain");
			chat_request.send(msg);
		}
	}

	function handle_key_press(e)
	{
		var key = e.keyCode || e.which;
		if (key == 13)  //enter keycode
			send_message();
	}

	function format_date_string(hours, minutes, seconds){
		function pad(n){return n<10 ? '0'+n : n}
		return pad(hours)+':'
			+ pad(minutes)+':'
			+ pad(seconds);
	}

	function handle_event(msg) {
		data = JSON.parse(msg);

		var date = new Date();
		var offset = data['time_in_sec'] - (date.getTimezoneOffset() * 60) + sec_in_day;
		offset %= sec_in_day;
		var seconds = offset % 60;
		var minutes = Math.floor(offset / 60) % 60;
		var hours = Math.floor(offset / 3600);
		var time_fmt = "(" + format_date_string(hours, minutes, seconds) + ") ";

		var li = document.createElement('li');
		li.className = "message";
		var li_text = "<span style='color:#999;font-size:small;'>" + time_fmt + "</span><span style='color:#000;font-size:small;font-weight: bold;'>" + data['username'] + ' : ' + "</span>" +
						"<span style='color:#000'>" + data['msg'] + "</span>";
		li.innerHTML = li_text;

		chat_ul.appendChild(li);
		chat_ul.scrollTop = chat_ul.scrollHeight;

		// Clean input field
		input_field.value="";
	}

	return {
		init: function(chat_listing, input, button, event, post_url) {
			chat_ul = chat_listing;
			input_field = input;
			url = post_url;

			input_field.addEventListener("keypress", handle_key_press, false);
			//button.addEventListener("click", send_message, false);

			event.register_handler('c', handle_event);
		}
	}
})();

(function() {
	function toggle_chat() {
		$("#chat_area").animate({
		height: "toggle",
		opacity: "toggle"
		}, 300);
		return false;
	}
	function in_game_init()
	{
		// click or press <ESC> to show/hide chat
		$("#toggle").click(toggle_chat);
		$(document).keydown(function(e) { 
			if (e.which == 27 ) {
				$("#toggle").trigger("click");
			}
		});
	}
	
	var chat_icon = $('<img id="chat_icon" />').attr('src', '/static/images/chat-default.png');
	window.addEventListener('load', in_game_init, false);
})();
<commit_msg>Minor fix<commit_after>var chat = (function (){
	var chat_ul;
	var input_field;
	var url;

	var chat_request = new XMLHttpRequest();
	var sec_in_day = (24 * 60 * 60);

	function send_message()
	{
		chat_request.open('POST',url,true);

		var msg = input_field.value;
		if (msg != "")
		{
			chat_request.setRequestHeader("Content-type", "text/plain");
			chat_request.send(msg);
		}
	}

	function handle_key_press(e)
	{
		var key = e.keyCode || e.which;
		if (key == 13)  //enter keycode
			send_message();
	}

	function format_date_string(hours, minutes, seconds){
		function pad(n){return n<10 ? '0'+n : n}
		return pad(hours)+':'
			+ pad(minutes)+':'
			+ pad(seconds);
	}

	function handle_event(msg) {
		data = JSON.parse(msg);

		var date = new Date();
		var offset = data['time_in_sec'] - (date.getTimezoneOffset() * 60) + sec_in_day;
		offset %= sec_in_day;
		var seconds = offset % 60;
		var minutes = Math.floor(offset / 60) % 60;
		var hours = Math.floor(offset / 3600);
		var time_fmt = "(" + format_date_string(hours, minutes, seconds) + ") ";

		var li = document.createElement('li');
		li.className = "message";
		var li_text = "<span style='color:#999;font-size:small;'>" + time_fmt + "</span><span style='color:#000;font-size:small;font-weight: bold;'>" + data['username'] + ' : ' + "</span>" +
						"<span style='color:#000'>" + data['msg'] + "</span>";
		li.innerHTML = li_text;

		chat_ul.appendChild(li);
		chat_ul.scrollTop = chat_ul.scrollHeight;

		// Clean input field
		input_field.value="";
	}

	return {
		init: function(chat_listing, input, button, event, post_url) {
			chat_ul = chat_listing;
			input_field = input;
			url = post_url;

			input_field.addEventListener("keypress", handle_key_press, false);
			//button.addEventListener("click", send_message, false);

			event.register_handler('c', handle_event);
		}
	}
})();

(function() {
	function toggle_chat() {
		$("#chat_area").animate({
		height: "toggle",
		opacity: "toggle"
		}, 300);
		return false;
	}
	function in_game_init()
	{
		// click or press <ESC> to show/hide chat
		$("#toggle").click(toggle_chat);
		$(document).keydown(function(e) { 
			if (e.which == 27 ) {
				$("#toggle").trigger("click");
			}
		});
	}

	window.addEventListener('load', in_game_init, false);
})();

{'fraction_non_alphanumeric': 0.18220885259991404, 'fraction_numerical': 0.015900300816501935, 'mean_word_length': 3.994635193133047, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 18, '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': '199428', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1655, 'n_words': 339}