User:Maulle Breezy/global.js/chat.js

//Not mine, just using, this way i can at least add to the code and import it if need be

//Chat's topic. Remember to escape single quotes in the topic using \' to prevent this from breaking. //var chatTopic = 'Welcome to the XXX Chat' //$(function {	//   $('#ChatHeader .public.wordmark').prepend(' '+chatTopic+' ') //	.find('a').attr('style','position:relative;text-decoration:underline;') //}) //$('#ChatHeader .public.wordmark div:not(:first-child)').remove /* * ChatTags *  By User:AnimatedCartoons */ //  (function ($) {   'use strict';    var disable = $.isArray(window.chatTagsDisable) ? window.chatTagsDisable : [];    // Translations    var lng = {        // English        en: {            hide: 'Hide spoiler',            show: 'Show spoiler'        },        // Polski        pl: {            hide: 'Ukryj',            show: 'Pokaż'        },        // Português        'pt-br': {            hide: 'Esconder',            show: 'Mostrar'        },        // Español        es: {            hide: 'Ocultar spoiler',            show: 'Mostrar spoiler'        },        // Català        ca: {            hide: 'Amaga spoiler',            show: 'Mostra spoiler'        },        // Italiano        it: {            hide: 'Nascondere spoiler',            show: 'Mostrare spoiler'        },        // Français        fr: {            hide: 'Cacher spoiler',            show: 'Montrer spoiler'        },        // 日本の (Japanase) ja: { hide: '隠すスポイラー', show: '表示スポイラー' },       // русский  (Russian) ru: { hide: 'Скрыть спойлер', show: 'Показать спойлер' },       // Deutsch de: { hide: 'Spoiler ausblenden', show: 'Spoiler anzeigen' }   };    lng = $.extend(lng.en, lng[mw.config.get('wgContentLanguage')]); mainRoom.model.chats.bind('afteradd', function (chat) {       var t = chat.attributes.text,            $m = $('#Chat_' + roomId + ' .message:last').html;        if ($.inArray('*bg', disable) === -1) {            // Message line background            if (t.match(/(?=.*\[\*bg .*\])/gi)) {                $m = $m.replace(//gi, ).replace(/<\/a\>/gi, );                var bckgrnd = (/\[\*bg (.*?)\]/gi).exec($m);                if (bckgrnd[1].match(/^https?:\/\//gi)) {                    $('#Chat_' + roomId + ' li:last').css('background-image', 'url(' + bckgrnd[1] + ')');                } else {                    $('#Chat_' + roomId + ' li:last').css('background-color', bckgrnd[1]);                }                $m = $m.replace(/\[\*bg (.*?)\]/gi, '');            }        }        if ($.inArray('b', disable) === -1) {            // Boldface            if (t.match(/(?=.*\[b\])(?=.*\[\/b\])/gi)) { $m = $m.replace(/\[b\]/gi, ' ').replace(/\[\/b\]/gi, ' '); }       }        if ($.inArray('bg', disable) === -1) { // Text background if (t.match(/(?=.*\[bg .*\])(?=.*\[\/bg\])/i)) { $m = $m.replace(/\[bg (.*?)\]/gi, '').replace(/\[\/bg\]/gi, ' '); }       }        if ($.inArray('big', disable) === -1) { // Big if (t.match(/(?=.*\[big\])(?=.*\[\/big\])/gi)) { $m = $m.replace(/\[big\]/gi, ' ').replace(/\[\/big\]/gi, ' '); }       }        if ($.inArray('c', disable) === -1) { // Color if (t.match(/(?=.*\[c .*\])(?=.*\[\/c\])/i)) { $m = $m.replace(/\[c (.*?)\]/gi, '').replace(/\[\/c\]/gi, ' '); }       }        if ($.inArray('f', disable) === -1) { // Font if (t.match(/(?=.*\[f .*\])(?=.*\[\/f\])/i)) { $m = $m.replace(/\[f (.*?)\]/gi, '').replace(/\[\/f\]/gi, ' '); }       }        if ($.inArray('i', disable) === -1) { // Italicize if (t.match(/(?=.*\[i\])(?=.*\[\/i\])/i)) { $m = $m.replace(/\[i\]/gi, ' ').replace(/\[\/i\]/gi, ' '); }       }        if ($.inArray('img', disable) === -1) { // Image if (t.match(/(?=.*\[img .*\])/i)) { $m = $m.replace(//gi, ).replace(/<\/a\>/gi, ).replace(/\[img (.*?)\]/gi, ''); }       }        if ($.inArray('p', disable) === -1) { // Preformatted if (t.match(/(?=.*\[p\])(?=.*\[\/p\])/i)) { $m = $m.replace(/\[p\]/gi, ' ').replace(/\[\/p\]/gi, ' '); }       }        if ($.inArray('s', disable) === -1) { // Strikethrough if (t.match(/(?=.*\[s\])(?=.*\[\/s\])/i)) { $m = $m.replace(/\[s\]/gi, ' ').replace(/\[\/s\]/gi, ' '); }       }        if ($.inArray('sc', disable) === -1) { // SoundCloud if (t.match(/(?=.*\[sc .*\])/i)) { $m = $m.replace(/\[sc (.*?)\]/gi, ' '); }       }        if ($.inArray('small', disable) === -1) { // Small if (t.match(/(?=.*\[small\])(?=.*\[\/small\])/gi)) { $m = $m.replace(/\[small\]/gi, ' ').replace(/\[\/small\]/gi, ' '); }       }        if ($.inArray('sp', disable) === -1) { // Spoiler if (t.match(/(?=.*\[sp\])(?=.*\[\/sp\])/gi)) { $m = $m.replace(/\[sp\]/gi, ' Spoiler ').replace(/\[\/sp\]/gi, ' '); }       }        if ($.inArray('sub', disable) === -1) { // Subscript if (t.match(/(?=.*\[sub\])(?=.*\[\/sub\])/i)) { $m = $m.replace(/\[sub\]/gi, ).replace(/\[\/sub\]/gi, ); }       }        if ($.inArray('sup', disable) === -1) { // Superscript if (t.match(/(?=.*\[sup\])(?=.*\[\/sup\])/i)) { $m = $m.replace(/\[sup\]/gi, '').replace(/\[\/sup\]/gi, ' '); }       }        if ($.inArray('u', disable) === -1) { // Underline if (t.match(/(?=.*\[u\])(?=.*\[\/u\])/i)) { $m = $m.replace(/\[u\]/gi, ' ').replace(/\[\/u\]/gi, ' '); }       }        if ($.inArray('yt', disable) === -1) { // YouTube if (t.match(/(?=.*\[yt .*\])/i)) { $m = $m.replace(/\[yt (.*?)\]/gi, ''); }       }        $('#Chat_' + roomId + ' .message:last').html($m); });   $('body').on('click', '#spoil', function  { var $s = $(this).siblings('#spoil2'); if ($($s).is(':hidden')) { $(this).text(lng.hide); $($s).show; } else { $(this).text(lng.show); $($s).hide; }   }); }(this.jQuery));