<commit_before>var myNickname = "";
var socket = io();
$('form').submit(function(){
	socket.emit('chat message', $('#m').val());
	$('#m').val('');
	$("#smiley-picker").addClass('hide');
	return false;
  });

socket.on('chat message', function(msg){
	console.log(msg);
	var nick = msg.split(":")[0];
	console.log("nick: " + nick);
	msg = msg.split(": ")[1];
	msg = msg.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
        return '&#'+i.charCodeAt(0)+';';
    });
    msg = createSmileys(msg);
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle">' + nick + ' said:</p>' + '<p class="chatMessage">' + msg + '</p>');
	autoScroll();
	console.log($("#chatWindow")[0].scrollHeight);
	if(myNickname != nick)
	{
		playSound("message");
	}
  });

socket.on('greeting', function(msg){
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle"><NAME> said:</p>' + '<p class="chatMessage">' + msg + '.</p>');
	autoScroll()
});

socket.on('privmsg', function(msg){
	console.log("got a priv message from " + nick);
	var nick = msg.split(":")[0];
	msg = msg.split(": ")[1];
	msg = msg.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
        return '&#'+i.charCodeAt(0)+';';
    });
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle">' + nick + ' said in private:</p>' + '<p class="chatMessage">' + msg + '.</p>');
	autoScroll()
});

socket.on('alert', function(msg){
	var alert = msg.split(":")[0];
	var info = msg.split(":")[1];
	switch(alert)
	{
		case 'nick':
			myNickname = info;
			$('.nickName').html(info);
			$('.program-title').html("MSN Messenger - " + info + " - (online)")
			break;
		case 'chatters':
			$('.nickStatus').html("It's " + info + " online right now.");
			break;
		case 'nudge':
			nudge(10);
			playSound('nudge');
			break;
		case 'newChatter':
			if(myNickname != info)
			{
				playSound('login');
			}
			break;
	}
});

function autoScroll()
{
	$("#chatWindow").scrollTop($("#chatWindow")[0].scrollHeight);
}<commit_msg>Makes smileys in the nick possible<commit_after>var myNickname = "";
var socket = io();
$('form').submit(function(){
	socket.emit('chat message', $('#m').val());
	$('#m').val('');
	$("#smiley-picker").addClass('hide');
	return false;
  });

socket.on('chat message', function(msg){
	console.log(msg);
	var nick = msg.split(": ")[0];
	console.log("nick: " + nick);
	msg = msg.slice(msg.indexOf(": ")+2, msg.length); //message is from : and to the end.
	msg = secureString(msg);
    nick = secureString(nick);

    msg = createSmileys(msg);
    nick = createSmileys(nick);
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle">' + nick + ' said:</p>' + '<p class="chatMessage">' + msg + '</p>');
	autoScroll();
	console.log($("#chatWindow")[0].scrollHeight);
	if(myNickname != nick)
	{
		playSound("message");
	}
  });

socket.on('greeting', function(msg){
	msg = createSmileys(msg);
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle"><NAME> said:</p>' + '<p class="chatMessage">' + msg + '.</p>');
	autoScroll()
});

socket.on('privmsg', function(msg){
	console.log("got a priv message from " + nick);
	var nick = msg.split(": ")[0];
	msg = msg.slice(msg.indexOf(": ")+2, msg.length);
	msg = secureString(msg);
	nick = secureString(nick);
    msg = createSmileys(msg);
    nick = createSmileys(nick);
	$('#chatWindow').html( $('#chatWindow').html() + '<p class="chatTitle">' + nick + ' said in private:</p>' + '<p class="chatMessage">' + msg + '.</p>');
	autoScroll()
});

socket.on('alert', function(msg){
	var alert = msg.split(":")[0];
	var info = msg.slice(msg.indexOf(":")+1, msg.length);
	switch(alert)
	{
		case 'nick':
			myNickname = info;
			$('.nickName').html(myNickname);
			$('.program-title').html("MSN Messenger - " + myNickname + " - (online)")
			break;
		case 'chatters':
			$('.nickStatus').html("It's " + info + " online right now.");
			break;
		case 'nudge':
			nudge(10);
			playSound('nudge');
			break;
		case 'newChatter':
			if(myNickname != info)
			{
				playSound('login');
			}
			break;
	}
});

function autoScroll()
{
	$("#chatWindow").scrollTop($("#chatWindow")[0].scrollHeight);
}

function secureString(str)
{
	return str.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
        		return '&#'+i.charCodeAt(0)+';';
   			});
}
{'fraction_non_alphanumeric': 0.2620545073375262, 'fraction_numerical': 0.010249242953645469, 'mean_word_length': 4.327543424317618, 'pattern_counts': {'":': 12, '<': 32, '<?xml version=': 0, '>': 32, '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': '869981', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1575, 'n_words': 294}