User:Akrivus/wikia.js

function importScript(b) { var a = mw.config.get('wgScript') + "?title=" + encodeURIComponent(b.replace(/ /g, "_")).replace(/%2F/ig, "/").replace(/%3A/ig, ":") + "&action=raw&ctype=text/javascript"; return importScriptURI(a) }

function importScriptURI(a) { var b = document.createElement("script"); b.setAttribute("src", a); b.setAttribute("type", "text/javascript"); document.getElementsByTagName("head")[0].appendChild(b); return b }

function importScriptPage(b, d) { var a = "/index.php?title=" + encodeURIComponent(b.replace(/ /g, "_")).replace("%2F", "/").replace("%3A", ":") + "&action=raw&ctype=text/javascript"; if (typeof d == "string") { if (d.indexOf("://") == -1) { a = "http://" + d + ".wikia.com" + a       } else { a = d + a       } }   return importScriptURI(a) }

function importStylesheet(a) { return importStylesheetURI(mw.config.get('wgScript') + "?action=raw&ctype=text/css&title=" + encodeURIComponent(a.replace(/ /g, "_"))) }

function importStylesheetURI(b, d) { var a = document.createElement("link"); a.type = "text/css"; a.rel = "stylesheet"; a.href = b;   if (d) { a.media = d   } document.getElementsByTagName("head")[0].appendChild(a); return a }

function importStylesheetPage(b, d) { var a = "/index.php?title=" + encodeURIComponent(b.replace(/ /g, "_")).replace("%2F", "/").replace("%3A", ":") + "&action=raw&ctype=text/css"; if (typeof d == "string") { if (d.indexOf("://") == -1) { a = "http://" + d + ".wikia.com" + a       } else { a = d + a       } }   return importStylesheetURI(a) }

function addOnloadHook(func) { $(func); }

/* Chat skin */ .Chat ul.you { background: none; }   .WikiaPage { box - shadow: none!important; } body { background - image: url(http: //vignette3.wikia.nocookie.net/steven-universe/images/5/50/Wiki-background); background - position: center center; background - attachment: fixed; }       .User img { border: 1 px solid #00B2EE; border-radius: 3px; height: 25px; width: 25px; } /* User color and icons */ /** removes the star **/ .modicon { display:none; } .User.chat-mod .username:after { background-image: none; } .bureaucrat { color: # 90E E90!important; font - weight: bold; }

.bureaucrat: after { content: url(http: //vignette2.wikia.nocookie.net/steven-universe/images/c/c9/Peridotgem15x15.png) !important; }

.admin { color: #3a80fc !important; font-weight: bold; } .admin:after { content: url(http://vignette2.wikia.nocookie.net/steven-universe/images/f/f2/NewSapphireGem2admin.png/revision/latest?cb= 20150826060017) !important; }

.supadmin { color: #FFFFFF!important; font - weight: bold; }

.supadmin: after { content: url(http: //vignette1.wikia.nocookie.net/steven-universe/images/1/11/Pearlgem15x15.png) !important; }

.bot { color: #F94D00!important; font - weight: bold; }

.bot: after { content: url(http: //vignette2.wikia.nocookie.net/steven-universe/images/4/40/Redeye15x15.png) !important; }

.vstf { color: #19FFB2 !important; font-weight: bold; } .vstf:after { content: url(http://vignette2.wikia.nocookie.net/steven-universe/images/a/aa/Centipeetlegem15x15.png) !important; } .chatmod { color:# C646C6!important; font - weight: bold; }

.chatmod: after { content: url(http: //vignette2.wikia.nocookie.net/steven-universe/images/7/70/Amethystgem15x15.png) !important; }

.patroller { color: #5CC7BD !important; font-weight: bold; } .patroller:after { content: url(http://vignette1.wikia.nocookie.net/steven-universe/images/9/9f/Alexandritegem15x15.png) !important; } .moderator { color: # FF007F!important; font - weight: bold; }

.moderator: after { content: url(http: //vignette1.wikia.nocookie.net/steven-universe/images/7/75/Stevengem15x15.png) !important; }

.rollback { color: #F29C37!important; font - weight: bold; }

.rollback: after { content: url(http: //vignette2.wikia.nocookie.net/steven-universe/images/e/e5/Jaspergem15x15.png) !important; }

.ic { color: #1589FF !important; font-weight: bold; } .ic:after { content: url(http://vignette1.wikia.nocookie.net/steven-universe/images/5/5a/Lapisgem15x15.png) !important; }

/* Custom username hilite (goodbye intervals!) */ /* by Cod4 */ /* Listen for new messages and update hilite for each incoming message */ window.mainRoom.socket.bind('chat:add', function(message) {   var name = getName(message);                                            element = $('.Chat').first.find('ul').children.last.find('.username');                                            updateHighlight(element, name);                                        });

/* Listen for new user joins and update hilite on the userlist accordingly */ window.mainRoom.socket.bind('join', function(message) {                                       var name = getName(message);                                        /* Loop around userlist to find appropriate element */                                        $('#WikiChatList').find('li.User').each(function { if ($(this).attr("data-user") == name) { updateHighlight($(this).find('span.username'), name); }                                       });                                    });

/* Listen for user status changes and keep user highlight on the userlist */ window.mainRoom.socket.bind('updateUser', function(message) {                                       var name = getName(message);                                        if (name == mw.config.get('wgUserName')) {                                            updateYourHighlight;                                        } else {                                            $('#WikiChatList').find('li.User').each(function { if ($(this).attr("data-user") == name) { updateHighlight($(this).find('span.username'), name); }                                           });                                        }                                    });

/* update your username and the existing userlist when you join chat */ updateYourHighlight; $('#WikiChatList').find('li.User').each(function {                                       updateHighlight($(this).find('span.username'), $(this).attr("data-user"));                                    });

/* Get a username from a chat event to use */ function getName(messageData) { var userData = new models.User; userData.mport(messageData.data); return userData.get('name'); }

/* Function to update your highlight at the upper right */ function updateYourHighlight { var headerUserElement = $('#ChatHeader').find('div.User').find('span.username'); updateHighlight(headerUserElement, mw.config.get('wgUserName')); }

headerUserElement = $('#ChatHeader').find('div.User').find('span.username'); updateHighlight(headerUserElement, headerUserElement.text); /* function to add highlight class without needing regex. */                                   /* add usernames in the same format as necessary. */                                   function updateHighlight(element, name) { switch (name) { /* Bureaucrats */ case 'Killer365': case 'Superluigi6': case 'Pearl is awsome': element.addClass('bureaucrat').removeClass('chat-mod'); break; /* Admins */ case 'AwesomeSteven': case 'ThePK': case 'LarsMars': case 'Vogel100': case 'Lilduders': case 'Sharayna': element.addClass('admin').removeClass('chat-mod'); break; /*Support Admins*/ /*element.addClass('supadmin').removeClass('chat-mod'); break; /* Bots */ case 'StevenBot': case 'GarnetBot': case 'KPehT': case 'Polymorphic Sentient Bot': case 'SapphireBot': case 'Holographic Pearl': element.addClass('bot').removeClass('chat-mod'); break; /* VSTF */ case 'Callofduty4': case 'Cyanide3': case 'Ajraddatz': case 'Yatalu': case 'RansomTime': element.addClass('vstf').removeClass('chat-mod'); break; /* Chat Mods */ case 'Poorle': case 'JinxBinx': case 'Alcana': case 'Strong In The Real Way': case 'AwesomePeridot': case 'Sticks the Badger': case 'XeonNRI': case '50000cal': element.addClass('chatmod').removeClass('chat-mod'); break; /* Patrollers */ /*element.addClass('patroller'); break; /* Rollbackers */ case 'Perlen297': case 'Ylimegirl': element.addClass('rollback'); break; /* Moderators */ case 'Lizington': case 'Judgekoo': case 'Aqualad124': element.addClass('moderator'); break; }                                   }

/* 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;

/* Chat options */ var chatOptionsLoaded = false; if (!chatOptionsLoaded) { chatOptionsLoaded = true; }

/**                                    * ChatTags - A BBCode parser for Wikia Special:Chat *                                    * Version v2.1.8 *                                    * Copyright (c) 2013 - 2015 Maria Williams (Shining-Armor) *                                    * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is                                    * furnished to do so, subject to the following conditions: *                                     * The above copyright notice and this permission notice shall be included in                                     * all copies or substantial portions of the Software. *                                     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR                                     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN                                    * THE SOFTWARE. */

var chatags = window.chatags || {};

chatags.images = chatags.images || false; chatags.videos = chatags.videos || false;

chatags.css = '.chatags-image{max-width:300px;max-width:300px;}';

chatags.tags = { 'b': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/b]', ' '); } else { s = s.replace('[b]', ' '); }                                           return s;                                        }, 'bg': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/bg]', ' '); } else { try { t = t.split(' '); s = s.replace('[bg ' + t[1] + ']', ''); } catch (e) { console.log(e) }                                           }                                            return s;                                        }, 'big': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/big]', ' '); } else { s = s.replace('[big]', ' '); }                                           return s;                                        }, 'c': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/c]', ' '); } else { try { t = t.split(' '); s = s.replace('[c ' + t[1] + ']', ''); } catch (e) { console.log(e) }                                           }                                            return s;                                        }, 'code': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/code]', ' '); } else { s = s.replace('[code]', ' '); }                                           return s;                                        }, 'font': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/font]', ' '); } else { try { t = t.split(' '); s = s.replace('[font ' + t[1] + ']', ''); } catch (e) { console.log(e) }                                           }                                            return s;                                        }, 'i': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/i]', ' '); } else { s = s.replace('[i]', ' '); }                                           return s;                                        }, 'img': function(s, t) { if (chatags.images !== true) return s;                                           if (t.charAt(0) !== '/') { try { t = t.split(' '); s = s.replace('[img ' + t[1] + ']', ''); } catch (e) { console.log(e) }                                           }                                            return s;                                        }, 'small': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/small]', ' '); } else { s = s.replace('[small]', ' '); }                                           return s;                                        }, 's': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/s]', ' '); } else { s = s.replace('[s]', ' '); }                                           return s;                                        }, 'sub': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/sub]', ' '); } else { s = s.replace('[sub]', ' '); }                                           return s;                                        }, 'sup': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/sup]', ' '); } else { s = s.replace('[sup]', ' '); }                                           return s;                                        }, 'u': function(s, t) { if (t.charAt(0) === '/') { s = s.replace('[/u]', ' '); } else { s = s.replace('[u]', ' '); }                                           return s;                                        }, 'yt': function(s, t) { if (chatags.videos !== true) return s;                                           if (t.charAt(0) !== '/') { try { t = t.split(' '); s = s.replace('[yt ' + t[1] + ']', ' '); } catch (e) { console.log(e) }                                           }                                            return s;                                        } };

chatags.parser = function(s) { var t = s.match(/\[([^\[\];]*)\]/g); var tg = '';

if (!t) return s;

for (var i = 0; i < t.length; i++) { tg = t[i].match(/\[\/?([^\[\]]*)\]/)[1];

try { tg = tg.split(' ')[0]; } catch (e) {}

if (typeof chatags.tags[tg] !== 'undefined') { s = chatags.tags[tg](s, t[i].replace('[', ).replace(']', )); }                                       }                                        return s;                                    };

chatags.init = function { if (typeof window.mainRoom !== 'undefined') { $('head').append(' ' + chatags.css + ' '); window.mainRoom.model.chats.bind("afteradd", function(c) {                                               var string = $("#Chat_" + roomId + " .message:last").html;

string = chatags.parser(string); $("#Chat_" + roomId + " .message:last").html(string); });                                       }                                    };

$(document).ready(function {                                       chatags.init;                                    });

/**                                    * !mods.js                                     * * Ping all moderators present in chat * @author: w:User:Fubuki風吹 */

$(function {                                       if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {                                            var groups = mw.config.get('wgUserGroups').join(' ');                                            if ((groups.indexOf('bureaucrat') + groups.indexOf('sysop') + groups.indexOf('chatmoderator') + groups.indexOf('helper') + groups.indexOf('vstf') + groups.indexOf('staff')) > -6) {                                                $('.Chat').on('DOMNodeInserted', function(e) { var msg = $.parseHTML(e.target.innerHTML)[7]; if (msg !== void 0 && msg.innerHTML.substr(0, 5) == '!mods') { $(' ', {                                                           id: 'mod-ping',                                                            src: 'http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg',                                                            autoplay: true                                                        }).appendTo('body'); setTimeout(function {                                                           if ($('#mod-ping').length) $('#mod-ping').remove;                                                        }, 1000); }                                               });                                            }                                        }                                    });                                    //

* /                                   /**                                     * ChatOptions * Change how Special:Chat looks and functions using an interface. * Uses cookies to store the changes. * A potential solution to all your chathacks problems. *                                    * Many thanks to the Call of Duty Wiki Chat, * who supported and helped this the whole way through. * It has been much appreciated. Thank you! *                                    * WARNING * Make sure you are not loading MediaWiki:Chat.js/load.js                                     * with MediaWiki:Chat-edit-count. * Load it with MediaWiki:Chat-welcome-message, or this * will malfunction badly. * TODO: Improve user interface *                                    * @version 1.3.1 * @author Callofduty4 * @author Madnessfan34537 * @author Sactage  */

/**                                    * Function to set a cookie * @param cookie_name A string representing the cookie's name * @param data The value of the cookie to be set */                                   function setCookie(cookie_name, data) { var domain = wgServer.split("//")[1]; document.cookie = cookie_name + "=" + data + "; max-age=" + 60 * 60 * 24 * 150 + "; path=/; domain=" + domain; }

/**                                    * Function to get a cookie's value * @param cookie_name A string representing the cookie's name * @param pos The index of the value to get from the cookie * @return The string value of the cookie */                                   function getCookie(cookie_name, pos) { var x, y, cookie_array = document.cookie.split(";"); for (var 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]); }                                       }                                    }

/**                                    * Function to check if a chat options module is enabled * @since 1.3.0 * @author Sactage * @param name The name of the options module * @return boolean */                                   function isEnabled(module) { var c;                                       switch (module) { case "chatHacks": c = getCookie("customisation", 2); break; case "tabComplete": c = getCookie("customisation", 4); break; case "multiKick": c = getCookie("customisation", 5); break; case "multiPM": c = getCookie("customisation", 6); break; case "searchBar": c = getCookie("customisation", 7); break; case "stopSideScroll": c = getCookie("customisation", 9); break; case "ignoreURL": c = getCookie("customisation", 8); break; default: return false; }                                       return (c === "true"); }

// Store chat customisation options as an object var chatOptions = { look: { fontColor: getCookie("customisation", 1), fontFamily: getCookie("customisation", 3), surroundColor: getCookie("customisation", 10), selfPostColor: getCookie("customisation", 11), backgroundColor: getCookie("customisation", 0), modalIcon: "http://img4.wikia.nocookie.net/__cb20140531235013/dev/images/c/c0/ChatOptionsIcon.png" },                                       modules: { chatHacks: { element: "#chatHacks", enabled: isEnabled("chatHacks"), loaded: false, load: function { if ($("#pingspan").length > 0 || this.loaded) return; /*                                                     * ChatHacks.js, by Monchoman45. * Version 7.0 *                                                     * Features: *  Ability to clear your chat window *  A host of slash commands *  Ability to create multi user private chats *  Inline alerts every time your away status changes *  Icons next to messages by staff and chat mods in the room *  Pings when someone mentions your name or any other specified phrases */

if (wgCanonicalSpecialPageName == 'Chat') { window.hasFocus = true; window.dinged = false; window.ding = 0; window.titleorig = document.title;

function Unding { //for fixing the title after you've been dinged document.getElementsByTagName('title')[0].innerHTML = window.titleorig; clearInterval(window.ding); window.dinged = false; }                                                       $(window).bind('focus', Unding); $(window).bind('focus', function {                                                           window.hasFocus = true;                                                        }); $(window).bind('blur', function {                                                           window.hasFocus = false;                                                        });

//Function for adding messages to the window NodeChatDiscussion.prototype.iconPing = function(chat) { var icon = ''; for (var i in this.model.users.models) { if (this.model.users.models[i].attributes.name == chat.attributes.name) { if (this.model.users.models[i].attributes.isStaff) { icon = ' '; } else if (this.model.users.models[i].attributes.isModerator) { icon = ' '; }                                                                   break; }                                                           }                                                            if (icon) { this.chatUL.children.last.children('.username').html(this.chatUL.children.last.children('.username').html + icon); }

if (mainRoom.isInitialized && chat.attributes.name != wgUserName && !chat.attributes.isInlineAlert) { window.dinged = true; //resolve HTML var text = chat.attributes.text; var pings = document.getElementById('pings').value.removeTrailing('\n').split('\n'); for (var i = 0; i < pings.length; i++) { if (text.toLowerCase.indexOf(pings[i].toLowerCase) != -1 || this != mainRoom.viewDiscussion) { if (!window.hasFocus) { //Only annoy people if the window isn't focused document.getElementById('sound').innerHTML = ' '; if (!window.dinged) { window.ding = setInterval('FlashTitle', 500); }                                                                       }                                                                        this.scrollToBottom; if (this == mainRoom.viewDiscussion) { var ref = text.toLowerCase.indexOf(pings[i].toLowerCase); var phrase = text.slice(ref, ref + pings[i].length); this.chatUL.children.last.children('.message').addClass('ping'); }                                                                       break; }                                                               }                                                            }

//Kill emoticons this.chatUL.children.last.children('.message img').each(function {                                                               this.outerHTML = '' + this.title + ' ';                                                            }); }                                                       mainRoom.model.chats.bind('afteradd', $.proxy(mainRoom.viewDiscussion.iconPing, mainRoom.viewDiscussion));

//Away status functions NodeChatController.prototype.setAway = function(msg) { if (!msg) { var msg = ''; }                                                           $.log("Attempting to go away with message: " + msg); var setStatusCommand = new models.SetStatusCommand({                                                               statusState: STATUS_STATE_AWAY,                                                                statusMessage: msg                                                            }); this.inlineAlert(i18n['away']); this.socket.send(setStatusCommand.xport); }                                                       NodeChatController.prototype.setBack = function { if (!this.comingBackFromAway) { // if we have sent this command (but just haven't finished coming back yet), don't keep spamming the server w/this command $.log("Telling the server that I'm back."); this.comingBackFromAway = true; var setStatusCommand = new models.SetStatusCommand({                                                                   statusState: STATUS_STATE_PRESENT,                                                                    statusMessage: ''                                                                }); this.inlineAlert(i18n['back']); this.socket.send(setStatusCommand.xport); }                                                       }

//Send message function NodeChatController.prototype.sendMessage = function(event) { if (!this.active) { return true; }

if (event.which == 13 && !event.shiftKey) { event.preventDefault; mainRoom.resetActivityTimer; var inputField = this.viewDiscussion.getTextInput; var send = Preparse.call(this, inputField.val);

if (inputField.val && send) { var chatEntry = new models.ChatEntry({                                                                       roomId: this.roomId,                                                                        name: wgUserName,                                                                        text: inputField.val                                                                    }); if (this.isPrivate == true) { //is prive if (this.afterInitQueue.length < 1 || this.model.users.length < 2) { this.mainController.socket.send(this.model.privateRoom.xport); }                                                                       if (!this.isInitialized) { this.afterInitQueue.push(chatEntry.xport); //temp chat entry in case of slow connection time chatEntry.set({                                                                               temp: true,                                                                                avatarSrc: wgAvatarUrl                                                                            }); this.model.chats.add(chatEntry); } else { this.socket.send(chatEntry.xport); }                                                                   } else { this.socket.send(chatEntry.xport); }

event.preventDefault; }                                                               inputField.val(''); $.log('submitting form'); inputField.focus; }                                                       }                                                        mainRoom.viewDiscussion.unbind('sendMessage'); mainRoom.viewDiscussion.bind('sendMessage', $.proxy(mainRoom.sendMessage, mainRoom));

//Functions that have to be changed for interwiki chat NodeChatController.prototype.openPrivateRoom = function(users) { users.push(wgUserName); $.ajax({                                                               type: 'POST',                                                                url: wgScript + '?action=ajax&rs=ChatAjax&method=getPrivateRoomID',                                                                data: {                                                                    users: users.join(',')                                                                },                                                                success: $.proxy(function(data) { $.log("Attempting create private room with users " + users.join(',')); var data = new models.OpenPrivateRoom({                                                                       roomId: data.id,                                                                        users: users                                                                    }); this.baseOpenPrivateRoom(data, true); this.showRoom(data.get('roomId')); this.chats.privates[data.get('roomId')].isPrivate = true; this.chats.privates[data.get('roomId')].init; //this.socket.send(data.xport); }, this)                                                           }); this.viewUsers.hideMenu; }

NodeRoomController.prototype.onJoin = function(message) { var joinedUser = new models.User; joinedUser.mport(message.joinData);

var connectedUser = this.model.users.findByName(joinedUser.get('name'));

if (typeof connectedUser == "undefined") { this.model.users.add(joinedUser); this.fire('afterJoin', joinedUser);

//TODO: move it to other class if (!this.isPrivate) { // Create the inline-alert (on client side so that we only display it if the user actually IS new to the room and not just disconnecting/reconnecting). var newChatEntry = new models.InlineAlert({                                                                       text: $.msg('chat-user-joined', [joinedUser.get('name')])                                                                    }); this.model.chats.add(newChatEntry); }

this.disableRoom(joinedUser, false); } else { // The user is already in the room... just update them (in case they have changed). this.model.users.remove(connectedUser); this.model.users.add(joinedUser); }                                                       }                                                        NodeRoomController.prototype.onPart = function(message) { var partedUser = new models.User; partedUser.mport(message.data);

var connectedUser = this.model.users.findByName(partedUser.get('name'));

if (typeof connectedUser != "undefined") {

//TODO: move it to other class if (!this.isPrivate) { var newChatEntry = new models.InlineAlert({                                                                       text: $.msg('chat-user-parted', [connectedUser.get('name')])                                                                    }); this.model.chats.add(newChatEntry); }

this.model.users.remove(connectedUser); this.disableRoom(connectedUser, true); }                                                       }                                                        NodeRoomController.prototype.disableRoom = function(user, flag) { if (this.isPrivate == false) { //TODO: fix it for multiuser priv chat var privateUser = this.model.privateUsers.findByName(user.get('name'));

if (typeof privateUser != "undefined") { var roomId = privateUser.get('roomId'); if (typeof(this.chats.privates[roomId]) != "undefined") { this.chats.privates[roomId].model.room.set({                                                                           'blockedMessageInput': flag                                                                        }); }                                                                   //try to reconnect if (flag === false && this.chats.privates[roomId].model.chats.length > 0) { this.socket.send(this.chats.privates[roomId].model.privateRoom.xport); }                                                               }                                                            }                                                        }

NodeChatController.prototype.showRoom = function(roomId) { $.log(roomId); if (this.activeRoom == roomId) { return false; }

this.activeRoom = roomId; if (roomId == 'main') { this.chats.main.setActive(true); } else { this.chats.main.setActive(false); }

for (var i in this.chats.privates) { if (i == roomId) { this.chats.privates[i].setActive(true); } else { this.chats.privates[i].setActive(false); }                                                           }

for (var i in this.chats.opens) { if (i == roomId) { this.chats.opens[i].setActive(true); } else { this.chats.opens[i].setActive(false); }                                                           }                                                            return true; }

NodeChatController.prototype.openPublicRoom = function(roomId) { this.chats.opens[roomId] = new NodeRoomController(roomId); this.chats.opens[roomId].mainController = this; //set main controller for this chat room this.showRoom(roomId); this.chats.opens[roomId].init; }

/*//For interwiki chatting, a merger of NodeRoomController's private management functions, and NodeChatController's public management functions. NodeInterwikiController = $.createClass(NodeRoomController, {		constructor: function (roomId) {			NodeInterwikiController.superclass.constructor.apply(this,arguments);			this.socket.bind('updateUser', $.proxy(this.onUpdateUser, this)); //Check			this.bind('afterJoin', $.proxy(this.afterJoin, this));			this.viewUsers = new NodeChatUsers({model: this.model, el: $('body')});			this.viewUsers.bind('showPrivateMessage', $.proxy(this.privateMessage, this) );			this.viewUsers.bind('kickBan', $.proxy(this.kickBan, this) );			this.viewUsers.bind('giveChatMod', $.proxy(this.giveChatMod, this) );			this.viewUsers.bind('blockPrivateMessage', $.proxy(this.blockPrivate, this) ); //Check			this.viewUsers.bind('allowPrivateMessage', $.proxy(this.allowPrivate, this) ); //Check			this.viewUsers.bind('mainListClick', $.proxy(this.mainListClick, this) ); //Check			this.viewUsers.bind('privateListClick', $.proxy(this.privateListClick, this) ); //Check this.viewUsers.bind('clickAnchor', $.proxy(this.clickAnchor, this) ); //Check this.viewUsers.render; this.viewDiscussion.show; return this; }	});*/

NodeChatController.prototype.inlineAlert = function(text) { for (var i in text.split('\n')) { this.viewDiscussion.chatUL.append('' + text.split('\n')[i] + ''); }                                                           this.viewDiscussion.scrollToBottom; }

function FlashTitle { if (document.getElementsByTagName('title')[0].innerHTML == window.titleorig) { document.getElementsByTagName('title')[0].innerHTML = i18n['activity'].replace(/\$1/g, wgSiteName); } else { document.getElementsByTagName('title')[0].innerHTML = window.titleorig; }                                                       }

function Preparse(input) { //Parse slash commands. if (input.charAt(0) == '/') { var com = input.split(' '); com[0] = com[0].substring(1, com[0].length); var ref = '.' + com[0].toLowerCase; if (window.commands[com[0].toLowerCase] == undefined) { return true; }                                                               while (typeof eval('window.commands' + ref) != 'function') { if (typeof eval('window.commands' + ref) == 'string') { ref = ref.substring(0, ref.lastIndexOf('.')) + '.' + eval('window.commands' + ref).toLowerCase; continue; }                                                                   if (typeof eval('window.commands' + ref) == 'object') { if (!com[1]) { if (typeof eval('window.commands' + ref).default == 'function') { eval('window.commands' + ref).default.call(this, '', chat); }                                                                           return true; }                                                                       if (eval('window.commands' + ref)[com[1].toLowerCase]) { ref += '.' + com[1].toLowerCase; } else if (eval('window.commands' + ref).default) { ref += '.default'; if (typeof eval('window.commands' + ref) == 'function') { break; }                                                                       } else { return true; }                                                                       com = com.slice(1, com.length); continue; }                                                                   if (typeof eval('window.commands' + ref) == 'undefined') { return true; }                                                               }                                                                com = com.slice(1, com.length); return eval('window.commands' + ref).call(this, com.join(' '), input); } else { return true; }                                                       }

window.commands = { 'away': 'afk', 'afk': function(com, text) { if ($('#ChatHeader .User').hasClass('away') == false) { toggleAway; } //if you're away, hitting enter has already sent you back },                                                           'clear': function(com, text) { //Clear the active chat window this.clearWindow; },                                                           'nc': function(com, text) { //Nobody cares $('#Write [name="message"]').val( + (com ? com : i18n['nobodycares']) + ); return true; },                                                           'devoice': function(com, text) { //IRCpwnt $('#Write [name="message"]').val('* ChanServ set channel mode -v ' + (com ? com : wgUserName)); return true; },                                                           'coppa': function(com, text) { //Too young if (com) { $('#Write [name="message"]').val('http://coppa.org ' + com); } else { $('#Write [name="message"]').val('http://coppa.org ' + i18n['coppa']); }                                                               return true; },                                                           'silence': function(com, text) { //Idle $('#Write [name="message"]').val('People idle, enjoy the silence. http://www.youtube.com/watch?v=diT3FvDHMyo'); return true; },                                                           'kick': 'kickban', 'ban': 'kickban', 'kb': 'kickban', 'kickban': function(com, text) { //Kickban a user if (com) { var mod = new models.KickBanCommand({                                                                       userToBan: com                                                                    }); this.socket.send(mod.xport); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'unban': function(com, text) { //Unban a user if (com) { api.newQuery(POST, 'action=userrights&user=' + com + '&remove=bannedfromchat', function(result) {                                                                       if (result.userrights.removed[0] == 'bannedfromchat') {                                                                            this.inlineAlert(i18n['unbanned'].replace(/\$1/g, com));                                                                        } else {                                                                            this.inlineAlert(i18n['notbanned'].replace(/\$1/g, com));                                                                        }                                                                    }); api.send(0, true); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'mod': function(com, text) { //Make a user a mod if (com) { var giveChatModCommand = new models.GiveChatModCommand({                                                                       userToPromote: com                                                                    }); this.socket.send(giveChatModCommand.xport); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'demod': function(com, text) { //Remove a user's mod right if (com) { api.newQuery(POST, 'action=userrights&user=' + com + '&remove=chatmoderator', function(result) {                                                                       if (result.userrights.removed[0] == 'chatmoderator') {                                                                            this.inlineAlert(i18n['demodded'].replace(/\$1/g, com));                                                                        } else {                                                                            this.inlineAlert(i18n['notmod'].replace(/\$1/g, com));                                                                        }                                                                    }); api.send(0, true); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'block': function(com, text) { //Block a user from private chatting you if (com) { this.blockPrivate({                                                                       name: com                                                                    }); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'unblock': function(com, text) { //Unblock a user from private chatting you - should merge this into a toggle if (com) { this.allowPrivate({                                                                       name: com                                                                    }); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            'chat': 'private', 'room': 'private', 'private': function(com, text) { //Invoke a private room if (com) { var arr = com.split('#'); for (var i in arr) { array[i] = arr[i].removeTrailing(' '); }                                                                   mainRoom.openPrivateChat(arr); } else { this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0])); }                                                           },                                                            /*'enter': 'join', 'join': function(com, text) { //Now for a command with chutzpah - join any chat on Wikia //Need to fix this so that joined rooms can be selected if(com) { var data = new models.OpenPrivateRoom({roomId: com}); mainRoom.baseOpenPrivateRoom(data, true); $('.private').before(' ' + com + ' <span id="MsgCount_' + com + '" class="splotch">0 '); mainRoom.showRoom(com); mainRoom.chats.privates[com].init; }			else {this.inlineAlert(i18n['errroom'].replace(/\$1/g, text.split(' ')[0]));} },		'leave': 'part', 'part': function(com, text) { //Leave the room you're looking at, or the room you specify if(!com) {var id = this.roomId; var chat = this;} else {var id = com; var chat = mainRoom.chats.privates[com];} $('#Room_' + id).remove; chat.socket.autoReconnect = false; chat.socket.socket.disconnect; if(!com) {mainRoom.show('main');} },*/                                                           'roomid': 'id', 'id': function(com, text) { this.inlineAlert(i18n['id'] + ': ' + this.roomId); },                                                           'self': function(com, text) { //Send a message to yourself if (com) { newstr = ''; for (var i = 0; i < com.length; i++) { switch (com.charAt(i)) { case '[': if (com.charAt(i + 1) == '[') { var k = com.indexOf(']', i); if (com.charAt(k + 1) == ']') { var substr = com.substring(i + 2, k); if (substr.indexOf('|') != -1) { var link = substr.substring(0, substr.indexOf('|')); var linktext = substr.substring(substr.indexOf('|') + 1, substr.length); } else { var link = substr; var linktext = link; }                                                                                       var linkspl = link.split(' '); link = ''; for (var j in linkspl) { link += linkspl[j] + '_'; }                                                                                       link = link.substring(0, link.length - 1); newstr += '<a href="/wiki/' + link + '">' + linktext + '</a>'; i = k + 1; }                                                                               } else if (com.substring(i + 1, i + 8) == 'http://') { var k = com.indexOf(']', i); var splstr = com.substring(i + 1, k).split(' '); if (splstr == com.substring(i + 1, k)) { var linktext = '[1]'; } else { var linktext = build(splstr, 1); }                                                                                   newstr += '<a href="' + splstr[0] + '">' + linktext + '</a>'; i = k;                                                                               } break; default: newstr += com.charAt(i); break; }                                                                   }                                                                    this.viewDiscussion.chatUL.append('<img class="avatar" src="' + $('#ChatHeader .User img').attr('src') + '"> ' + wgUserName + ' (' + i18n['self'] + ') ' + newstr + ' </li>'); } else { this.viewDiscussion.chatUL.append('<img class="avatar" src="' + $('#ChatHeader .User img').attr('src') + '"> ' + wgUserName + ' (' + i18n['self'] + ') </li>'); }                                                               this.viewDiscussion.scrollToBottom; },                                                           'help': function(com, text) { if (com) { var ref = com.replace(/ /g, '.'); var str = ''; var subcoms = []; var subdirs = []; while (typeof eval('window.commands.' + ref) == 'string') { ref.substring(0, ref.lastIndexOf('.')) + '.' + eval('window.commands' + ref).toLowerCase; }                                                                   var command = eval('window.commands.' + ref); if (i18n['help-' + ref]) { str += i18n['help'].replace(/\$1/g, ref.replace(/\./g, ' ')).replace(/\$2/g, i18n['help-' + ref].replace(/\$1/g, i18n['example']).replace(/\$1/g, i18n['exampleuser'])); }                                                                   if (typeof command == 'object') { for (var i in command) { if (typeof command[i] == 'function') { subcoms.push(i); }                                                                           if (typeof command[i] == 'object') { subdirs.push(i); }                                                                       }                                                                    }                                                                    if (subcoms.length > 0) { str += '\n' + i18n['subcoms'] + ': ' + subcoms.join(', '); }                                                                   if (subdirs.length > 0) { str += '\n' + i18n['subdirs'] + ': ' + subdirs.join(', '); }                                                                   str = str.removeTrailing('\n'); if (str != '') { this.inlineAlert(str); } else { this.inlineAlert(i18n['nohelp'].replace(/\$1/g, command)); }                                                               } else { var str = []; for (var i in window.commands) { if (typeof window.commands[i] == 'function' || typeof window.commands[i] == 'object') { str.push(i); }                                                                   }                                                                    this.inlineAlert(i18n['commands'].replace(/\$1/g, str.join(', '))); }                                                           }                                                        };

//Parser helping function - takes an array of text created with .split(' '), //and an index number for where to start, then rebuilds the string. //Can also accept an index value for where to stop. function build(text, index, stop) { var newtext = ''; if (stop == undefined || stop == 0) { stop = text.length } else if (stop < 0) { stop += text.length }                                                           if (index == stop || index == text.length - 1) { return text[index]; }                                                           for (var i = index; i < stop; i++) { newtext += text[i] + ' '; }                                                           return newtext; }

function toggleAway(msg) { if (!msg) { var msg = ''; }                                                           if ($('#ChatHeader .User').hasClass('away') == true) { mainRoom.setBack; } else { mainRoom.setAway(msg); }                                                       }                                                        toggleAway.back = function { //Force back status if ($('#ChatHeader .User').hasClass('away') == true) { mainRoom.setBack; }                                                       }                                                        toggleAway.away = function(msg) { //Force away status if (!msg) { var msg = ''; }                                                           if ($('#ChatHeader .User').hasClass('away') == false) { mainRoom.setAway(msg); }                                                       }

NodeChatController.prototype.clearWindow = function { this.viewDiscussion.chatUL.html(''); this.inlineAlert(i18n['cleared']); }

function active { //Returns the NodeChatController for the active window if (mainRoom.activeRoom && mainRoom.activeRoom != 'main') { return mainRoom.chats.privates[mainRoom.activeRoom]; } else { return mainRoom; }                                                       }

String.prototype.removeTrailing = function(char) { //Remove extraneous characters var str = this; while (str.charAt(0) == char) { str = str.substring(1, str.length); }                                                           while (str.charAt(str.length - 1) == char) { str = str.substring(0, str.length - 1); }                                                           return str; }

function createCookie(name, value, days) { if (days) { var date = new Date; date.setTime(date.getTime + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString; } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; }

function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); }                                                           return null; }

$(function {                                                           if (!importScriptURI) {                                                                function importScriptURI(a) {                                                                    var b = document.createElement("script");                                                                    b.setAttribute("src", a);                                                                    b.setAttribute("type", "text/javascript");                                                                    document.getElementsByTagName("head")[0].appendChild(b);                                                                    return b                                                                }                                                            }                                                            importScriptURI('http://c.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js/i18n.js&action=raw&ctype=text/javascript'); importScriptURI('http://monchbox.wikia.com/index.php?title=MediaWiki:APIQuery.js&action=raw&ctype=text/javascript'); //APIQuery for /unban

$('head').append('<style type="text/css">\n.stafficon {\n\tmargin-bottom:-4px;\n\twidth:14px;\n\theight:14px;\n}\n.modicon {\n\tmargin-bottom:-3px;\n\twidth:14px;\n\theight:14px;\n}\n.UserStatsMenu {\n\tcolor:#000;\n}\n.Write [name="message"] {\n\twidth:93%;\n}\n.inline-alert span {\n\tcolor:#006CB0;\n\tcursor:pointer;\n}\n.inline-alert span:hover {\n\ttext-decoration:underline;\n}\n#pingspan {\n\tposition:absolute;\n\tz-index:5;\n\ttop:23px;\n\tmargin-left:15px;\n\tfont-size:15px;\n\tfont-weight:normal;\n\tline-height:15px;\n}\n#pings {\n\tresize:none;\n\tmargin-left:0;\n\tfont-size:12px;\n\theight:100px;\n\tdisplay:block;\n}\n#pingspan div span {\n\tfont-size:55%;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n.message.ping {\n\tcolor:red;\n}\n ');

//Unbind all of the window listeners that set your status to back $(window).unbind('mousemove').unbind('focus').unbind('keypress'); //Add the sound space $('body').append(' '); });                                                   } else {                                                        $(function { var a = document.getElementsByTagName('a'); for (var i = 0; i < a.length; i++) { if (a[i].href && a[i].href.indexOf('/wiki/Special:Chat') != -1) { a[i].addEventListener('click', function(event) {                                                                       event.preventDefault;                                                                        OpenChatWindow;                                                                    }); a[i].removeAttribute('data-canonical'); }                                                           }                                                            if (document.body.className.indexOf('skin-oasis') != -1) { window.chatcheck = setInterval('ChatCheck', 200); }                                                       });

function ChatCheck { if ($('.chat-join button').length != 0) { $('.chat-join button').replaceWith('<a class="wikia-button" onclick="OpenChatWindow">' + $('.chat-join button').html + '</a>'); clearInterval(window.chatcheck); }                                                       }

function OpenChatWindow { window.chatwindow = window.open('/wiki/Special:Chat?useskin=wikia', 'chat'); window.chatwindow.onload = function { window.chatwindow.importScriptPage('User:' + wgUserName + '/global.js', 'c'); window.chatwindow.importScript('User:' + wgUserName + '/wikia.js'); }                                                       }                                                    }                                                    this.loaded = true; }                                           },                                            tabComplete: { element: "#tabComplete", enabled: isEnabled("tabComplete"), loaded: false, load: function { // http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ function getCaretPos(ctrl) { var CaretPos = 0; // IE Support if (document.selection) { ctrl.focus; var Sel = document.selection.createRange; Sel.moveStart('character', -ctrl.value.length); CaretPos = Sel.text.length; }                                                       // Firefox support else if (ctrl.selectionStart || ctrl.selectionStart == '0') CaretPos = ctrl.selectionStart; return (CaretPos); }

function setCaretPos(ctrl, pos) { if (ctrl.setSelectionRange) { ctrl.focus; ctrl.setSelectionRange(pos, pos); } else if (ctrl.createTextRange) { var range = ctrl.createTextRange; range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select; }                                                   }

//Tab insert for usernames $('[name="message"]').after(' [0,"","",0,null] '); $('[name="message"]').keydown(function(e) {                                                       if (e.keyCode == 9) {                                                            e.preventDefault;                                                            var curval = this.value;                                                            var afData = eval(document.getElementById('autofilldata').innerHTML);                                                            var curpos = afData[3] == 0 ? getCaretPos(this) : afData[3];                                                            var carpos = getCaretPos(this)                                                            if ((!curval.charAt(carpos) || curval.charAt(carpos).match(/\s/)) && !curval.charAt(carpos - 1).match(/\s/) && this.value.length) {                                                                var unamestart = ''; if (afData[1].length == 0) { for (i = curpos - 1; i >= 0 && !curval.charAt(i).match(/\s/); i--) { unamestart = curval.charAt(i) + unamestart; }                                                               } else { unamestart = afData[1]; }                                                               var afterTComplete = ''; for (i = curpos; i < curval.length; i++) { afterTComplete += curval.charAt(i); }                                                               //generate list of users var userList = ''; var userlistelems = document.getElementsByClassName('User'); for (i = 0; i < userlistelems.length; i++) { userList += userlistelems[i].getElementsByClassName('username')[0].innerHTML + ','; }                                                               userList = userList.replace(new RegExp('(' + wgUserName + '|RSChatBot),|,$', 'g'), '') userList = userList.split(',').sort var matchedNames = []; for (i = 0; i < userList.length; i++) { if (userList[i].match(new RegExp('^' + unamestart, 'i'))) { matchedNames.push(userList[i]); }                                                               }                                                                var newval = curval.split(''); for (i = carpos - 1; i >= 0 && i >= carpos - (!(afData[4] === null) ? (matchedNames[afData[4]] ? matchedNames[afData[4]].length : 0) : unamestart.length) && matchedNames.length > 0; i--) { newval[i] = ''; }                                                               matchedNames = !matchedNames[0] ? [''] : matchedNames; newval[curpos - unamestart.length] += matchedNames[afData[0]] ? matchedNames[afData[0]] : ''; newval = newval.join(''); this.value = newval; setCaretPos(this, curpos + (matchedNames[afData[0]].length ? matchedNames[afData[0]].length : 0)) var iter = afData[0] >= matchedNames.length - 1 ? 0 : afData[0] + 1; document.getElementById('autofilldata').innerHTML = '[' + iter + ',"' + unamestart + '","' + matchedNames[afData[0]] + '",' + curpos + ',' + afData[0] + ']' }                                                           return false; } else if (e.which != 16) { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }                                                   }).click(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }).blur(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; })                                                   this.loaded = true;                                                }                                            },                                            multiKick: {                                                element: "#multiKick",                                                enabled: isEnabled("multiKick"),                                                loaded: false,                                                load: function {                                                    importScriptPage("User:Madnessfan34537/multikick.js", "cod");                                                    $('<a id="multiKickerButton" class="wikia-button" href="javascript:showPopup" style="position:absolute; right:55px; top:22px;">Multikick</a>').appendTo('.Write'); // to prevent issues with the button not loading this.loaded = true; }                                           },                                            multiPM: { element: "#multiPM", enabled: isEnabled("multiPM"), loaded: false, load: function { if (wgCanonicalSpecialPageName == 'Chat') { function createGroupPM { var users = prompt('Enter comma seperated list of users to start a PM with', ''); var users = users.split(','); mainRoom.openPrivateChat(users); }                                                       $('form#Write').append('<a class="wikia-button" href="javascript:createGroupPM" style="position:absolute; right:50px; top:0;">PM</a>'); }                                                   this.loaded = true; }                                           },                                            searchBar: { element: "#searchBar", enabled: isEnabled("searchBar"), loaded: false, load: function { $('#ChatHeader').append('<form style="display:inline-block;position:absolute;top:7px;right:190px;z-index:9001;" method="get" action="Special:Search?title=Special:Search" class="WikiaSearch" id="WikiaSearch" target="_blank"><input type="text" accesskey="f" autocomplete="off" placeholder="Search" name="search"><input type="hidden" value="0" name="fulltext"> <img height="14px" class="sprite search" src="http://bits.wikimedia.org/skins-1.19/vector/images/search-ltr.png?303-4"> '); $('.ChatHeader form.WikiaSearch').submit(function {                                                       setTimeout("$('form.WikiaSearch input[name=\"search\"]').attr('value', '')", 500)                                                    }); this.loaded = true; }                                           },                                            ignoreURL: { element: "#ignoreURL", enabled: isEnabled("ignoreURL"), loaded: false, load: function { $('head').append('<style type="text/css">li[data-user="URL"] {display:none;} '); this.loaded = true; }                                           },                                            stopSideScroll: { element: "#stopSideScroll", enabled: isEnabled("stopSideScroll"), loaded: false, load: function { $('head').append('<style type="text/css">#WikiaPage .Chat .message { word-wrap: break-word; } '); this.loaded = true; }                                           }                                        }                                    }

/**                                    * Applies updated settings to the chat skin */                                   function updateChatSkin { $('body').css({                                           "background-color": chatOptions.look.surroundColor                                        }); $('.WikiaPage').css({                                           "background-color": chatOptions.look.backgroundColor,                                            "color": chatOptions.look.fontColor,                                            "font-family": chatOptions.look.fontFamily                                        }); $('.Chat').css({                                           "font-family": chatOptions.look.fontFamily                                        }); $('.Rail').css({                                           "font-family": chatOptions.look.fontFamily                                        }); $('.ChatHeader').css({                                           "background-color": chatOptions.look.backgroundColor,                                            "font-family": chatOptions.look.fontFamily                                        }); var selfPostElement = document.createElement('style'); selfPostElement.innerHTML = '.Chat .you{background:' + chatOptions.look.selfPostColor + ' !important;}'; $('head').append(selfPostElement); $('.Write [name="message"]').css({                                           "color": chatOptions.look.fontColor                                        }); $('.Write .message').css({                                           "background-color": chatOptions.look.backgroundColor                                        }); $('.ChatHeader .User .username').css({                                           "color": chatOptions.look.fontColor                                        }); for (var m in chatOptions.modules) { if (chatOptions.modules.hasOwnProperty(m)) { var module = chatOptions.modules[m]; if (typeof module.enabled === 'boolean' && module.enabled && !module.loaded) { module.load; }                                           }                                        }                                    }

/**                                    * Displays the options window */                                   function openOptions { // TODO: Kill this with fire? There has to be a better way to do this - perhaps use $.showModal var $optionsWindowHTML = $.showCustomModal("Options", '<form method="" name="" class="WikiaForm "> <p style="font-size:120%; font-weight:bold; font-style:italic;">Colour changes <p style="font-size:80%;">Enter a <a href="http://www.w3schools.com/html/html_colornames.asp" target="_blank">colour name</a> or <a href="http://html-color-codes.info/" target="_blank">colour hex</a> Chat background <input type="text" name="backgroundColourinput" id="backgroundColourinput" value="' + chatOptions.look.backgroundColor + '"/>  Self-post background <input type="text" name="selfPostColourinput" id="selfPostColourinput" value="' + chatOptions.look.selfPostColor + '"/>   Surround <input type="text" name="surroundColourinput" id="surroundColourinput" value="' + chatOptions.look.surroundColor + '"/>   Font colour <input type="text" name="fontColourinput" id="fontColourinput" value="' + chatOptions.look.fontColor + '"/>  <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 <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 <input type="checkbox" name="chatHacks" value="chatHacks" id="chatHacks"/> Enable <a href="http://c.wikia.com/wiki/User:Monchoman45/ChatHacks.js" target="_blank">chathacks</a>    <input type="checkbox" name="multiPM" value="multiPM" id="multiPM"/> Enable <a href="http://callofduty.wikia.com/wiki/User:Madnessfan34537/multipm.js" target="_blank">multi PM</a> <input type="checkbox" name="tabComplete" value="tabComplete" id="tabComplete"/>Enable <a href="http://runescape.wikia.com/wiki/User:Joeytje50/tabinsert.js" target="_blank">tab complete</a>   <input type="checkbox" name="searchBar" value="searchBar" id="searchBar"/>Enable <a href="http://callofduty.wikia.com/wiki/MediaWiki:Chat.js/searchbar.js" target="_blank">search bar</a> <input type="checkbox" name="multiKick" value="multiKick" id="multiKick" />Enable <a href="http://callofduty.wikia.com/wiki/User:Madnessfan34537/multikick.js" target="_blank">multi kick</a>    <input type="checkbox" name="ignoreURL" value="ignoreURL" id="ignoreURL"/>Ignore URL in main chat <input type="checkbox" name="stopSideScroll" value="stopSideScroll" id="stopSideScroll"/>Stop the sidescroll bar to appear after someone spams ', { id: "optionsWindow", width: 600, buttons: [{ id: "cancel", message: "Cancel", handler: function { cancelChanges; }                                           }, {                                                id: "updateCookie", defaultButton: true, message: "Update!", handler: function { updateCookie; }                                           }]                                        });                                        $(".close").click(cancelChanges);                                        // Check if various modules have been enabled by the user, and check their boxes if so                                        if (chatOptions.modules.chatHacks.enabled)                                            $("#chatHacks").attr("checked", true);                                        if (chatOptions.modules.multiPM.enabled)                                            $("#multiPM").attr("checked", true);                                        if (chatOptions.modules.tabComplete.enabled)                                            $("#tabComplete").attr("checked", true);                                        if (chatOptions.modules.searchBar.enabled) $("#searchBar").attr("checked", true); if (chatOptions.modules.multiKick.enabled) $("#multiKick").attr("checked", true); if (chatOptions.modules.ignoreURL.enabled) $("#ignoreURL").attr("checked", true); if (chatOptions.modules.stopSideScroll.enabled) $("#stopSideScroll").attr("checked", true);

if (typeof window.customFonts !== "undefined" && window.customFonts.length) { for (var i = 0; i < window.customFonts.length; i++) { var font = window.customFonts[i]; $("#fontList").append('<option value="' + font + '" style="font-family:' + font + ';">' + font.slice(0, 1).toUpperCase + font.slice(1) + ' '); }                                       }                                        // Set certain modules' checkboxes to disabled if specific conditions are not met if (!wgUserGroups.indexOf("chatmoderator") && !wgUserGroups.indexOf("sysop") && !wgUserGroups.indexOf("staff") && !wgUserGroups.indexOf("helper") && !wgUserGroups.indexOf("vstf")) $("#multiKick").attr("disabled", true); if (wgServer !== "http://callofduty.wikia.com") $("#ignoreURL").attr("disabled", true);

$("select option[value='" + chatOptions.look.fontFamily + "']").attr("selected", "selected"); // sets the font selector to the one chosen currently }

/**                                    * Close the options window without saving any changes */                                   function cancelChanges { var dialog = $('#optionsWindow'); dialog.closeModal; }

/**                                    * Saves user options and stores them in a cookie for persistence across sessions */                                   function updateCookie { chatOptions.look.backgroundColor = $('#backgroundColourinput').val; chatOptions.look.fontColor = $('#fontColourinput').val; chatOptions.look.fontFamily = $('#fontList').val; chatOptions.look.surroundColor = $('#surroundColourinput').val; chatOptions.look.selfPostColor = $('#selfPostColourinput').val; for (var m in chatOptions.modules) { if (chatOptions.modules.hasOwnProperty(m)) { var module = chatOptions.modules[m]; if (typeof module.element != 'undefined' && $(module.element).attr("checked")) { module.enabled = true; } else { module.enabled = false; }                                           }                                        }

// Set the cookies setCookie("customisation", chatOptions.look.backgroundColor + ", " + chatOptions.look.fontColor + ", " + chatOptions.modules.chatHacks.enabled + ", " + chatOptions.look.fontFamily + ", " + chatOptions.modules.tabComplete.enabled + ", " + chatOptions.modules.multiKick.enabled + ", " + chatOptions.modules.multiPM.enabled + ", " + chatOptions.modules.searchBar.enabled + ", " + chatOptions.modules.ignoreURL.enabled + ", " + chatOptions.modules.stopSideScroll.enabled + ", " + chatOptions.look.surroundColor + ", " + chatOptions.look.selfPostColor); updateChatSkin; cancelChanges; }

// Add Options button if (!$("#chatOptionsButton").length) { $('.Rail').prepend('<div id="chatOptionsButton" 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="' + chatOptions.look.modalIcon + '" width="18px"/> Options '); // Prevent multiple buttons from being appended }

window.onload = updateChatSkin;

//Chat's topic. Remember to escape single quotes in the topic using \' to prevent this from breaking. var chatTopic = 'Welcome to the Steven Universe Wiki chat. Please read <a href="Steven_Universe_Wiki:Chat_Policy" target="_blank">the rules</a> before chatting.';

$(function {                                       $('#ChatHeader .public.wordmark').prepend('<divclass="chattopic" style="text-align:center;position:absolute;width:60%;z-index:0;font-size: 13px;color:#000000;font-weight:bold;line-height:1.6;margin-left:110px;">' + chatTopic + ' ')                                            .find('a').attr('style', 'position:relative;text-decoration:none;');                                    }); $('#ChatHeader .public.wordmark div:not(:first-child)').remove;

//Clear chat button

function addClearChatText { if ($('.clearChatText').length <= 0) { var clearChatText = document.createElement('span'); $('<div class="clearChatText" onclick="clearChat" style="margin: 10px auto" align="center"><a class="clearChatButton wikia-button">Clear chat</a> ').prependTo('.Rail'); }                                   }

function clearChat { $('.Chat li').remove; }

window.onload = addClearChatText;

//END Clear chat button

//Switch to night button var night_button = 'Night theme';

//Switch to day button var day_button = 'Day theme';

//                                   //Color scheme for DAY Chat //                                   //Link color var linkColorDay = '#2C7E9A';

//All text Color var textColorDay = '#000000';

//Self text background color var selfTextColorDay = '#DCFBFD';

//Chat background color var backgroundColorDay = '#DCFBFD';

//Chat foreground color var foregroundColorDay = '#DCFBFD';

//User stats foreground color var userStatsColorDay = '#DCFBFD';

//END DAY Chat color scheme

//                                   //Color scheme for NIGHT Chat //                                   //Link color var linkColor = '#D1FFFF';

//All text Color var textColor = '#f2f2f2';

//Self text background color var selfTextColor = '#012445';

//Chat background color var backgroundColor = '#012445';

//Chat foreground color var foregroundColor = '#012445';

//User stats foreground color var userStatsColor = '#012445';

//END NIGHT Chat color scheme

//Day and night color schemes //Written by Foodbandlt

function addDayStyle { var styleElementDay = document.createElement('style');

styleElementDay.setAttribute("id", "day"); styleElementDay.innerHTML = 'body{background-color: ' + backgroundColorDay + ';}.username, .message, div.chattopic, .info .edits, .UserStatsMenu .info .since, #ChatHeader h1.private, .Write [name="message"]{color: ' + textColorDay + ';}.WikiaPage, .UserStatsMenu, .ChatHeader, .Write [name="message"]{background-color: ' + foregroundColorDay + ' !important;}.Chat .you{background: ' + selfTextColorDay + ';}a{color: ' + linkColorDay + ';}.UserStatsMenu .info{background-color:' + userStatsColorDay + ';}'; $('head').append(styleElementDay); }

function addNightStyle { var styleElement = document.createElement('style');

styleElement.setAttribute("id", "night"); styleElement.innerHTML = 'body{background-color: ' + backgroundColor + ';}.username, .message, div.chattopic, .info .edits, .UserStatsMenu .info .since, #ChatHeader h1.private, .Write [name="message"]{color: ' + textColor + ';}.WikiaPage, .UserStatsMenu, .ChatHeader, .Write [name="message"]{background-color: ' + foregroundColor + ' !important;}.Chat .you{background: ' + selfTextColor + ';}a{color: ' + linkColor + ';}.UserStatsMenu .info{background-color:' + userStatsColor + ';}'; $('head').append(styleElement); }

function addDayNightButton {

$('<div class="day-night-div" onclick="switch_view" style="margin: 10px auto; text-align: center; cursor: pointer;"><a class="day-night-button wikia-button">' + day_button + '</a> ').prependTo('.Rail'); if ($('style#night').size < 1 && $('style#nightUser').size < 1) { addNightStyle; }                                   }

function day_night(which) { 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 { 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; }

// http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ function getCaretPos(ctrl) { var CaretPos = 0; // IE Support if (document.selection) { ctrl.focus; var Sel = document.selection.createRange; Sel.moveStart('character', -ctrl.value.length); CaretPos = Sel.text.length; }                                       // Firefox support else if (ctrl.selectionStart || ctrl.selectionStart == '0') CaretPos = ctrl.selectionStart; return (CaretPos); }

function setCaretPos(ctrl, pos) { if (ctrl.setSelectionRange) { ctrl.focus; ctrl.setSelectionRange(pos, pos); } else if (ctrl.createTextRange) { var range = ctrl.createTextRange; range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select; }                                   }

//Tab insert for usernames $('[name="message"]').after(' [0,"","",0,null] '); $('[name="message"]').keydown(function(e) {                                       if (e.keyCode == 9) {                                            e.preventDefault;                                            var curval = this.value;                                            var afData = eval(document.getElementById('autofilldata').innerHTML);                                            var curpos = afData[3] == 0 ? getCaretPos(this) : afData[3];                                            var carpos = getCaretPos(this)                                            if ((!curval.charAt(carpos) || curval.charAt(carpos).match(/\s/)) && !curval.charAt(carpos - 1).match(/\s/) && this.value.length) {                                                var unamestart = '';                                                if (afData[1].length == 0) {                                                    for (i = curpos - 1; i >= 0 && !curval.charAt(i).match(/\s/); i--) { unamestart = curval.charAt(i) + unamestart; }                                               } else { unamestart = afData[1]; }                                               var afterTComplete = ''; for (i = curpos; i < curval.length; i++) { afterTComplete += curval.charAt(i); }                                               //generate list of users var userList = ''; var userlistelems = document.getElementsByClassName('User'); for (i = 0; i < userlistelems.length; i++) { userList += userlistelems[i].getElementsByClassName('username')[0].innerHTML + ','; }                                               userList = userList.replace(new RegExp('(' + wgUserName + '|RSChatBot),|,$', 'g'), '') userList = userList.split(',').sort var matchedNames = []; for (i = 0; i < userList.length; i++) { if (userList[i].match(new RegExp('^' + unamestart, 'i'))) { matchedNames.push(userList[i]); }                                               }                                                var newval = curval.split(''); for (i = carpos - 1; i >= 0 && i >= carpos - (!(afData[4] === null) ? (matchedNames[afData[4]] ? matchedNames[afData[4]].length : 0) : unamestart.length) && matchedNames.length > 0; i--) { newval[i] = ''; }                                               matchedNames = !matchedNames[0] ? [''] : matchedNames; newval[curpos - unamestart.length] += matchedNames[afData[0]] ? matchedNames[afData[0]] : ''; newval = newval.join(''); this.value = newval; setCaretPos(this, curpos + (matchedNames[afData[0]].length ? matchedNames[afData[0]].length : 0)) var iter = afData[0] >= matchedNames.length - 1 ? 0 : afData[0] + 1; document.getElementById('autofilldata').innerHTML = '[' + iter + ',"' + unamestart + '","' + matchedNames[afData[0]] + '",' + curpos + ',' + afData[0] + ']' }                                           return false; } else if (e.which != 16) { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }                                   }).click(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }).blur(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; })

setInterval(function {                                       $.getJSON("/api.php?action=query&format=json&prop=revisions&titles=MediaWiki:Emoticons&rvprop=content&cb=" + new Date.getTime, function(data) { var a = data.query.pages; for (var pageid in a) { var content = a[pageid].revisions[0]["*"]; mw.config.set("EMOTICONS", content); }                                       });                                    }, typeof ajaxEmoticonsInterval === "undefined" ? 30000 : ajaxEmoticonsInterval); //

/*                                     * Chat Announcements * @description Create announcements for all the users in chat * Must be installed in the wiki's MediaWiki:Chat.js or it will not work * @author Ozuzanna */

;                                   (function($, mw) {

if (mw.config.get('wgCanonicalSpecialPageName') !== "Chat") return;

var forAll = window.chatAnnouncementsAll, object, username, escapedUsername, message;

//start the chat event listener we need to use mainRoom.model.chats.bind("afteradd", function(child) {                                           object = $('#entry-' + child.cid);

//make sure not alert if (!object.hasClass('inline-alert')) { username = object.attr('data-user'); escapedUsername = username.replace(/[!"#$%&'*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&').replace(/ /g, "_");                                               message = object.children('.message').text.trim;

//check if user is mod or if the config is set, as well as if the correct format is used if (($("#WikiChatList #user-" + escapedUsername).hasClass('chat-mod') || forAll) && message.substr(0, 10) == "/announce ") object.html('<a href="' + mw.util.getUrl('User:' + mw.html.escape(username)) + '">' + mw.html.escape(username) + '</a>: ' + mw.html.escape(message.substr(10)) + '</li>'); }                                       });

})(this.jQuery, this.mediaWiki);                                   //

var onNewMessage = [], onStatusMessage = [];