Thread:DeviantSerpent/@comment-5036232-20130414112818

Hi there!

Could you please replace the contents of MediaWiki:Chat.js with the following? /** * 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;

/** * /me command * From the RuneScape Wiki */ document.getElementsByName('message')[0].onkeypress = function (e) { "use strict"; if (e.which === 32) { if (this.value === '/me') { this.value = '* ' + wgUserName; }   } };

/** * Username autocomplete * By User:Joeytje50 * From the RuneScape Wiki */ importScriptPage('User:Joeytje50/tabinsert.js', 'runescape');

/** * Mark admins */ setInterval(function {    "use strict";    $('#Rail .User.chat-mod:not(.admin) .username').each(function  { if (!this.innerHTML.match(/LeonSkunk|Chibitracy|DeviantSerpent|Miggy7215/)) { $(this).parent.addClass('admin'); }   }); }, 1000);

/** * 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'); }

/** * Create alias * From the RuneScape Wiki */ function createAlias(alias, on, run) { "use strict"; $('[name="message"]').keypress(function (e) {       if (typeof on === 'number') {            on += ;        }        if (typeof on === 'string') {            on = on.split(/[,\|]/);        }        var val = this.value;        if (on.indexOf(e.which + ) !== -1 && val.toLowerCase.search(new RegExp('/' + alias.toLowerCase + '\\b')) === 0) {            val = val.substr(alias.length + (val.charAt(alias.length + 1) === ' ' ? 2 : 1));            if (typeof run === 'string') {                this.value = run + ' ' + val;            } else if (typeof run === 'function') {                run(val, e);            }            if (e.which !== 13) {                e.preventDefault;            }        }    }); }

/** * Allow chat mods and admins to kick users using /kick * From the RuneScape Wiki */ if (wgUserGroups.indexOf('chatmoderator') > -1 || wgUserGroups.indexOf('sysop') > -1) { createAlias('kick', 13, function (toKick, e) {       "use strict";        if ($('#WikiChatList [data-user="' + toKick + '"]').length) {            mainRoom.kick({ name: toKick });       } else {            if (confirm(toKick + ' is not in this chat. Still try to kick him?')) {                mainRoom.kick({ name: toKick });           }        }        e.target.value = '';    }); }

/** * Allow admins to block users using /block , * From the RuneScape Wiki */ if (wgUserGroups.indexOf('sysop') > -1) { createAlias('block', 13, function (toBan, e) {       "use strict";        if (confirm('Are you really sure you want to block ' + toBan + ' permanently from the wiki, and kick them from this chat? Note: seperate the username and the block reason with a comma.')) {            toBan = toBan.split(',');            var reason = toBan.slice(1).join(' ');            $.post('http://theamazingworldofgumball.wikia.com/api.php?action=block&user=' + toBan[0] + '&expiry=infinite&nocreate=true&noemail=true&reason=' + encodeURIComponent(reason));            mainRoom.kick({ name: toBan[0] });       }    }); }

/** * Day and night chat * By User:Foodbandlt * From the MLP:FiM Wiki */ // Switch to night button var night_button = 'Switch to Night Chat',

// Switch to day button day_button = 'Switch to Day Chat',

/**    * Color scheme for Day Chat */   // Link color linkColorDay = '#ABABAB',

// All text Color textColorDay = '#CCFFFF',

// Self text background color selfTextColorDay = '#061118',

// Chat background color backgroundColorDay = '#000000',

// Chat foreground color foregroundColorDay = 'url("http://images.wikia.com/fusionfall/images/8/8c/Chatbackground.png")',

// User stats foreground color userStatsColorDay = 'url("http://images.wikia.com/fusionfall/images/2/2d/Searchlist2.png")',

// User chat box color messageColorDay = 'url("http://images.wikia.com/fusionfall/images/5/5d/Chattext.png")',

// User stats color userstatsmenuColorDay = '#061018',

/**    * Color scheme for Night Chat */   // Link color linkColor = '#03CCFF',

// All text Color textColor = '#D5D4D4',

// Self text background color selfTextColor = '#0C151A',

// Chat background color backgroundColor = '#000000',

// Chat foreground color foregroundColor = '#020C11',

// User stats foreground color userStatsColor = '#013240',

// User chat box color messageColor = '#020C11';

function addDayStyle { "use strict"; var styleElementDay = document.createElement('style'); styleElementDay.setAttribute("id", "day"); styleElementDay.innerHTML = 'body{background: ' + backgroundColor + ';}.username, .message, div.chattopic, .info .edits, .UserStatsMenu .info .since, #ChatHeader h1.private {color: ' + textColor + ';}.Write [name="message"] {color: ' + textColor + ';}.ChatHeader { background: ' + foregroundColor + ';} .UserStatsMenu { background: ' + userStatsColor + ';}.Chat .you{background: ' + selfTextColor + ';}a{color: ' + linkColor + ';}.UserStatsMenu .info {background: ' + foregroundColor + ';}.Write [name="message"] { background: ' + messageColor + ';}.WikiaPage { background: ' + foregroundColor + ';}'; $('head').append(styleElementDay); }

function addNightStyle { "use strict"; var styleElement = document.createElement('style'); styleElement.setAttribute("id", "night"); styleElement.innerHTML = 'body{background: ' + backgroundColorDay + ';}.username, .message, div.chattopic, .info .edits, .UserStatsMenu .info .since, #ChatHeader h1.private {color: ' + textColorDay + ';}.Write [name="message"] {color: ' + backgroundColorDay + ';}.ChatHeader { background: ' + userStatsColorDay + ';} .UserStatsMenu { background: ' + userStatsColorDay + ';}.Chat .you{background: ' + selfTextColorDay + ';}a{color: ' + linkColorDay + ';}.UserStatsMenu .info {background: ' + userstatsmenuColorDay + ';}.Write [name="message"] { background: ' + messageColorDay + ';}.WikiaPage { background: ' + foregroundColorDay + ';}'; $('head').append(styleElement); }

function addDayNightButton { "use strict"; $('' + night_button + ' ').prependTo('.Rail'); if ($('style#night').size < 1 && $('style#nightUser').size < 1) { addDayStyle; } }

function day_night(which) { "use strict"; if (which === "night") { $('style#day').remove; $('.Rail .day-night-div .day-night-button').text(day_button); addNightStyle; } else { $('style#night').remove; $('.Rail .day-night-div .day-night-button').text(night_button); addDayStyle; } }

function switch_view { "use strict"; if ($('.Rail .day-night-div .day-night-button').text === night_button) { day_night("night"); } else { day_night("day"); } }

if ($('.Rail .day-night-button').text === "") { addDayNightButton; }

while ($('.Rail .day-night-div').size > 1) { $('.WikiaPage .Rail div:last-child').remove; } I beautified it and fixed some errors.

Thanks! 