MediaWiki:Chat.js

//Chat's topic. Remember to escape single quotes in the topic using \' to prevent this from breaking. var chatTopic = ' Welcome to the café. Enjoy your stay! Please be sure to follow all of our  rules  ' $(function {	$('#ChatHeader .public.wordmark').prepend(''+chatTopic+' ')	.find('a').attr('style','position:relative;text-decoration:underline;') }) $('#ChatHeader .public.wordmark div:not(:first-child)').remove /* Creating /me command */ document.getElementsByName('message')[0].onkeypress = function(e) { if (e.which == 32) { if (this.value == '/me' || this.value == '/ME') { this.value = '* '+wgUserName; }	} } /* Block Chat Messages */ importScriptPage('MessageBlocker/code.js', 'dev'); /* Allow Chat Mods and admins to kick users using /kick */ if (wgUserGroups.indexOf('chatmoderator')!=-1 || wgUserGroups.indexOf('sysop')!=-1) { $(function {	$('[name="message"]').keypress(function(e) { if (e.which == 13) { if (this.value.split(' ')[0] == '/kick') { e.preventDefault; var toKick = this.value.replace(/^\/kick /,'') if (!$('#WikiChatList [data-user="'+toKick+'"]').length) { confirm(toKick + ' is not in this chat. Still try to kick him?')?mainRoom.kick({name: toKick}):undefined; } else { mainRoom.kick({name: toKick}) }				this.value = ''; return true; }		}	}); }); } /* Clear chat button */ function addClearChatText{ if ($('.clearChatText').length <= 0) { var clearChatText = document.createElement('span'); $('Clear chat ').prependTo('.Rail'); } } function clearChat{ chatSize = $('div.Chat:first ul li').size-1; $('.Chat:first li:lt('+chatSize+')').remove; } window.onload=addClearChatText; /* END Clear chat button */

/* Spam protection */

// Credit to Joeytje50, script modified slightly for more leniency/easier changing

// Change these variables to modify the leniency of the script

var maxLimit = 6; // limit for sent lines var maxLength = 1250; // limit for how long a line can be (in chars) var limitTimeout = 2000; // timeout for the sent lines limiter

var rate = 0; function ratelimit(e) { if (rate > maxLimit) { this.disabled = true;//disabling input in case they press ESC before the redirect is complete e.preventDefault; mainRoom.sendMessage({which : 13, shiftKey : false, preventDefault : function {} }) document.location.href = wgServer+"/wiki/Project:Chat/Ratelimit_triggered"; return false; }	if (this.value.length>=maxLength || this.value.split('\n').length>=6) { var val = this.value.substring(0,maxLength).split('\n'); val = val[0]+'\n'+val[1]+'\n'+val[2]+'\n'+val[3]+'\n'+val[4];//remove all lines after the 5th line. this.value = val; if (e.type == 'keypress') { e.preventDefault; return false; }	}	if (e.type == 'keypress' && e.which == 13 && !e.shiftKey && this.value != '') { rate += 1; setTimeout(function {			if (rate > 0) { rate -= 1 }		},limitTimeout); } } $('[name="message"]').keyup(ratelimit).keypress(ratelimit).keydown(ratelimit);

/* END Spam protection */ importScriptPage('User:Monchoman45/ChatHacks.js','c'); importScriptPage('User:Joeytje50/tabinsert.js','runescape'); importScriptPage('User:Madnessfan34537/multikick.js','cod'); importScriptPage('User:Madnessfan34537/multipm.js','cod'); importScriptPage('MediaWiki:Chat.js/searchbar.js','cod');

/**************/ /*Chat options*/ /**************/ /* /Change how chat looks using an interface. Uses cookies to store the changes /A potential solution to all your chathacks problems /version 0.4.1.1 /Written by Callofduty4 /* /To do: /More colour settings /Other aesthetic settings // function to set a cookie function setCookie( cookie_name, data ) { var splitServer = wgServer.split("//"); var domain = splitServer[1]; document.cookie = cookie_name + "=" + data + "; max-age=" + 60*60*24*100 + "; path=/; domain=" + domain ; } // function to get a cookie function getCookie( cookie_name, pos ) { var i, x, y, cookie_array = document.cookie.split(";"); for (i=0; i<cookie_array.length; i++) { x = cookie_array[i].substr(0,cookie_array[i].indexOf("=")); y = cookie_array[i].substr(cookie_array[i].indexOf("=")+1); x = x.replace(/^\s+|\s+$/g,""); if (x == cookie_name) { var style_objects = y.split(", "); return unescape(style_objects[pos]); }	} } // defining various global variables var backgroundColour = getCookie("customisation", 0); var fontColour = getCookie("customisation", 1); var chatHacksEnabled = getCookie("customisation", 2); var fontChoice = getCookie("customisation", 3); var chatHacksLoaded = false; // called when chat is loaded to update the skin function loadChatSkin { $('.WikiaPage').css({"background-color":backgroundColour, "color":fontColour, "font-family":fontChoice}); $('.ChatHeader').css({"background-color":backgroundColour}); if (chatHacksEnabled == "true") { importScriptPage("User:Monchoman45/ChatHacks.js","c"); chatHacksLoaded = true; } } function openOptions { $('#optionsWindow').show; $('body').append(' '); } function cancelChanges { $('#optionsWindow').hide; $('.blackout').hide; } function updateCookie { backgroundColour = $('#backgroundColourinput').val; fontColour = $('#fontColourinput').val; fontChoice = $('#fontList').val; if (document.getElementById('chatHacks').checked == 1) { chatHacksEnabled = "true"; }	else { chatHacksEnabled = "false"; }	setDaCookie; updateChatSkin; $('#optionsWindow').hide; $('.blackout').hide; } function updateChatSkin { $('.WikiaPage').css({"background-color":backgroundColour, "color":fontColour, "font-family":fontChoice}); $('.ChatHeader').css({"background-color":backgroundColour}); if (chatHacksLoaded == false && chatHacksEnabled == "true" && $('#pingspan').length <= 0) { importScriptPage("User:Monchoman45/ChatHacks.js","c"); chatHacksLoaded = true; } } function setDaCookie { setCookie("customisation", backgroundColour + ", " + fontColour + ", " + chatHacksEnabled + ", " + fontChoice); } function checkIfChatHacksEnabled { if (chatHacksEnabled == "true") { return("checked"); }	else { return(""); } } var chatHacksChecker = checkIfChatHacksEnabled; /* debug stuff function alerter { var message = getCookie("customisation"); alert(message); } $('body').append(' Options [EXPERIMENTAL]   Colour changes Enter a colour name or colour hex</a> Chat background <input type="text" name="backgroundColourinput" id="backgroundColourinput" value="' + backgroundColour + '"/>  Font colour <input type="text" name="fontColourinput" id="fontColourinput" value="' + fontColour + '"/>  <p style="font-size:120%; font-weight:bold; font-style:italic;">Font  Font family <select id="fontList"><option value="arial" style="font-family:arial;">Arial (default) <option value="courier new" style="font-family:courier new;">Courier new <option value="georgia" style="font-family:georgia;">Georgia <option value="palatino linotype" style="font-family:palatino linotype;">Palatino linotype <option value="Comic Sans MS" style="font-family:Comic Sans MS;">Comic sans <option value="tahoma" style="font-family:tahoma;">Tahoma <option value="Trebuchet MS" style="font-family:Trebuchet MS;">Trebuchet MS <option value="Verdana" style="font-family:Verdana;">Verdana <option value="Lucida Console" style="font-family:Lucida Console;">Lucida Console   <p style="font-size:120%; font-weight:bold; font-style:italic;">Added functionality Update!</a> Cancel</a>  '); $('#optionsWindow').hide; // debug stuff //$('<div onclick="alerter" style="left:50%; margin-left:2px;margin-right:2px; display:inline; text-align: center; cursor: pointer;" align="center">Alerter</a> ').prependTo('.Rail'); //$('<div onclick="loadChatSkin" style="left:50%; margin-left:2px;margin-right:2px; display:inline; text-align: center; cursor: pointer;" align="center">Load</a> ').prependTo('.Rail'); $('.Rail').prepend('<div onclick="openOptions" style="margin:auto; cursor: pointer; font-size:150%; bottom:4px; padding-bottom:2px; border-bottom: 1px solid #CCCCCC; width:90%;" align="center"><img src="http://www.derehamreclaim.co.uk/_images-pages/icon-hammerSpanner.jpg" width="18px"/> Options '); window.onload=loadChatSkin