User:Ultimate Dark Carnage/chat.js

importArticles({   type: 'script',    articles: [        "u:dev:MessageBlocker/code.js",        "u:c:User:Ultimate_Dark_Carnage/commands.js",        "u:c:User:Ultimate_Dark_Carnage/test.js",        "u:c:User:Ultimate_Dark_Carnage/sandbox2.js"    ] }, {    'type': 'style',    articles: [        'u:c:User:Ultimate_Dark_Carnage/chat2.css'    ] });

$(function{   if (wgCanonicalSpecialPageName == "Chat"){        if (navigator.userAgent.match(/Windows/gi)) $('.ChatWindow').addClass('Windows');        else if (navigator.userAgent.match(/OS X/gi)) $('.ChatWindow').addClass('OSX');        else if (navigator.userAgent.match(/Linux/gi)) $('.ChatWindow').addClass('Linux');        var commands = {            "terms": function(txt, user){                if (user){                    txt = '' + user + ': Read Wikia\'s Terms of Use';                } else {                    txt = 'Read Wikia\'s Terms of Use';                }            },            "slap": function(txt, user){                txt = '/me slaps ' + user + ' with a big trout.';            },            "clear": function{                if ($('.Chat').find('li').length){                    $('.Chat').find('li').remove;                } },           "ignore": function(user){ if (user){ var el = $('[data-user="' + user + ']');                   if (!el.is('.ignored')){                        el.hide;                        el.addClass('ignored');                    } else {                        return false;                    }                }            },            "unignore": function(user){                if (user){                    var el = $('[data-user="' + user + ']'); if (el.is('.ignored')){ el.show; el.removeClass('ignored'); } else { return false; }               }            },            "font": function(font, txt, regexp){ if (font){ if (font.split(' ').length){ font = font.replace(font, '"' + font + '"'); }                   window.mainRoom.model.chats.bind("afteradd", function(c){                        var s = $('.Chat .message:last').html;                        s = s.replace(regexp, '' + txt + ' ');                        $('.Chat .message:last').html(s);                    }); }           }        };        function activateCommand(cmd, values){ if (cmd.indexOf('/') === 0){ cmd = cmd.replace(/\/(.*)/gi, '$1'); var user = values.user, font = (cmd = "font") ? values.font : '', txt = values.txt, regexp = values.regexp; if (cmd == "font"){ commands[cmd](font, txt, regexp); } else if (cmd == "ignore" || cmd == "unignore"){ commands[cmd](user); } else if (cmd == "clear"){ commands[cmd]; } else { commands[cmd](txt, user); }           }        }        $('[name="message"]').on('keypress', function(event){            if (event.which == 13 || event.keyCode == 13){                var cmd_regex = /(\/.*) \((.*)\) \(u\:(.*)\)/gi,                    val = $(event.target).val,                    com = val.replace(cmd_regex, '$1'),                    txt = val.replace(cmd_regex, '$2'),                    con = val.replace(cmd_regex, '$3');                activateCommand(com, { user: con, font: con, txt: txt });           }        });    } });