MediaWiki:Chat.js

/** * Chat topic *  From the RuneScape Wiki */ var chatTopic = 'STUDENTS: Please read and follow The Rules before chatting.';

$(function {    "use strict";    $('#ChatHeader .public.wordmark').prepend('' + chatTopic + ' ').find('a').attr('style', 'position:relative; text-decoration:underline;'); }); $('#ChatHeader .public.wordmark div:not(:first-child)').remove;

/** * Mark patrollers, admins, and bureaucrats */ setInterval(function {    "use strict";    $('.User.chat-mod .username').each(function  { if (this.innerHTML.match(/AnimatedCartoons|Killer365|MisterJim|Ailourophile|Gumballamiyumi/)) { $(this).parent.addClass('admin').removeClass('chat-mod'); }       if (this.innerHTML.match(/InvaderrrZIM|DeviantSerpent/)) { $(this).parent.addClass('bureaucrat').removeClass('chat-mod'); }       if (this.innerHTML.match(/OctagonDinosaur|Randomced859/)) { $(this).parent.addClass('patroller').removeClass('chat-mod'); }   }); }, 1);

/** * Clear chat */ function addClearChatText { "use strict"; if ($('.clearChatText').length <= 0) { var clearChatText = document.createElement('span'); $('Clear chat ').prependTo('.Rail'); } }

function clearChat { "use strict"; var chatSize = $('div.Chat:first ul li').size - 1; $('.Chat:first li:lt(' + chatSize + ')').remove; }

window.onload = addClearChatText;

/** * Spam protection *  By User:Joeytje50 *  From the RuneScape Wiki */ var maxLimit = 6, // Limit for sent lines maxLength = 1250, // Limit for how long a line can be (in chars) limitTimeout = 2000, // Timeout for the sent lines limiter rate = 0;

function ratelimit(e) { if (rate > maxLimit) { this.disabled = true; e.preventDefault; mainRoom.sendMessage({           which: 13,            shiftKey: false,            preventDefault: function  {}        }); document.location.href = wgServer + "/wiki/Main_Page"; 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]; 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);

/** * Chat options *  By User:Callofduty4, User:Madnessfan34537, and User:Sactage *  From the Call of Duty Wiki */ var chatOptionsLoaded = false; if (!chatOptionsLoaded) { chatOptionsLoaded = true; importScriptPage('MediaWiki:Chat.js/options.js', 'cod'); }