User:Joeytje50/chatmsg.js

WikiaEmoticons.newMessage = function (text, emoticonMapping){ var imgUrlsByRegexString = emoticonMapping.getImgUrlsByRegexString; for(var regexString in imgUrlsByRegexString){ /*		 * empty string for emote icons crash Chat * so ignore them */		if(regexString == '') continue; imgSrc = imgUrlsByRegexString[regexString]; imgSrc = imgSrc.replace(/"/g, "%22"); // prevent any HTML-injection		// Build the regex for the character (make it ignore the match if there is a "/" immediately after the emoticon. That creates all kinds of problems with URLs).		var numIters = 0;		var origText = text;		do{			var regex = new RegExp("(^| )(" + regexString + ")([^/]|$)", "gi"); // NOTE: \s does not work for whitespace here for some reason.			var emoticon = "  ";			var glyphUsed = text.replace(regex, '$2');			glyphUsed = glyphUsed.replace(/"/g, "&quot;"); // prevent any HTML-injection text = text.replace(regex, '$1' + emoticon + '$3'); } while ((origText != text) && (numIters++ < 5)); }	return text; }

WikiaEmoticons.doReplacements = function(text, emoticonMapping) { //text = onchatmessage(text, 'raw')?onchatmessage(text, 'raw'):text; text = this.newMessage(text, emoticonMapping); text = onchatmessage(text, 'html')?onchatmessage(text, 'html'):text; return text; } var onchatmessage = function(text, format) { if (format == 'raw') { //Code to run when the raw message code is received } else if (format == 'html') { //Code to run when the message has been encoded to HTML }	return text;//Keep this here, it will break if it's not there. }

function inlineAlert(msg) { document.getElementsByClassName('Chat')[0].getElementsByTagName('ul')[0].innerHTML += ''+msg+''; document.getElementsByClassName('Chat')[0].scrollTop=document.getElementsByClassName('Chat')[0].scrollHeight $('[name="message"]').val('').removeAttr('disabled').focus; } function sendMessage(msg) { $('[name="message"]').val(msg); mainRoom.sendMessage({which: 13, shiftKey: false, preventDefault: function {} }) $('[name="message"]').removeAttr('disabled').focus; }