User:Ultimate Dark Carnage/wikia.js

importArticles({   type: 'style',    articles: [        'User:Ultimate_Dark_Carnage/advancedui.css'    ] });

// Carnage's Code // DO NOT COPY!! // Create your own function Carnage{ if (wgUserName == "Ultimate Dark Carnage"){ this.enableInfoModule; }   return this; }

Carnage.prototype.enableInfoModule = function{ if ($('.WikiaRail').length){ $('.WikiaRail').on('DOMNodeInserted', function(event){           if (!$('.InfoModule').length){                var module = $(' ', { "class": "InfoModule info-module module", "id": "InfoModule", html: function{ var module_html = ' User Info '; module_html += ' '; $.get('/wiki/User:' + encodeURIComponent(wgUserName), function(data){                           var wikia_page = $(data).find('.WikiaSiteWrapper')[0],                                masthead = $(wikia_page).find('#UserProfileMasthead');                            if (masthead.length){                                var numberOfEdits = masthead.find('.tally em').text,                                    edited_since_base = masthead.find('.tally span').html,                                    edited_since = edited_since_base.split(' ')[1],                                   user = wgUserName,                                    avatar = masthead.find('img.avatar').attr("src");                                module_html += '';                                module_html += '';                                module_html += ' ' + wgUserName + ' ';                                module_html += ' ';                                module_html +=                                     '' +                                        '' +                                            ' ' + numberOfEdits + ' edits ' +                                            'Edited since: ' + edited_since + ' ' + '' + ' ' +                                           'Purge' + '' + 'Profile' + ' ' +                                                   '' + ' ' +                                               '' + '<a href="/wiki/User_talk:' + encodeURIComponent(wgUserName) + '">Talk Page</a></li>' + '</ul>' + ' ' +                                       ' ' +                                    ' ';                            }                        });                        module_html += ' ';                        return module_html;                    }                }); $('.WikiaRail .ChatModule').before(module); }       });    } };

$(document).ready(function{   Carnage.call; }); // End Carnage's Code

/* Chat Stuff */ $(function{   if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat'){        var commands = {            "terms": function(txt){                if (txt) $('#Write .message').val(txt + ': Read Wikia\'s Terms of Use');                else $('#Write .message').val('Read Wikia\'s Terms of Use');            },            "rules": function(txt){                if (txt) $('#Write .message').val('' + txt + ': Read the Community Central:Chat Guidelines');                else $('#Write .message').val('Read the Community Central:Chat Guidelines');            },            "ignore": function(txt){                if (txt){                    $('.Rail [data-user="' + txt + '"], .Chat [data-user="' + txt + '"]').hide;                }            }        };        $('.Write textarea').on('keypress', function(event){ if (event.keyCode == 13 || event.which == 13){ var txt = $('#Write .message').val, txt_regexp = /\!([^\!]\w{1,})(| [^\!].*)/gi, command = txt.replace(txt_regex, '$1'), newtxt = txt.replace(txt_regex, '$2'); if (command){ if (newtxt){ commands[command].call(newtxt); } else { commands[command].call; }               }            }        });    } });

/* jQuery(function($){   if (!$('#KillNotificationsModule').length){        $('.WikiaRail').on('DOMNodeInserted', function(event){ var kill = kill || {}; kill.module = function(config){ var c = { heading: config.heading || "Kill Notifications", type: config.notication_type || "warn", buttonMsg: config.buttonMessage || "Delete notifications", msg: config.message || '' };               var module = $(' ', {                   "class": "KillNotificationsModule module",                   "id": "KillNotificationsModule",                   html: function{                       var module_html = '<h1 class="kill-notifications-heading">';                       if (c.heading){                           module_html += c.heading;                       }                       module_html += ' <div data-target="' + c.type + '" class="kill-notifications-content">';                       if (c.msg){                           module_html += '<p class="kill-notifications-message">' + c.msg + ' ';                       }                       module_html += '<a href="#" class="kill-notifications action wikia-button" id="kill-notifications">' + c.buttonMsg + '</a>';                       module_html += ' ';                       return module_html;                   } });               $(event.target).children('.ChatModule').after(module);                $('.wikia-button.killnotifications').on('click', function{ kill.action; });           };            kill.action = function(config){                var hasclass = ($('.banner-notification').attr("class").match(/(warn|error)/gi)) ? true : false,                    notification = $('.banner-notification');                if (hasClass === true){                    var className = '.' + notification.attr("class");                    notification = $('.banner-notification ' + className);                }                if (notification.length){                    $.openCustomModal('Delete Notifications?', ' Are you sure that you want to delete the notifications? Notification count: ' + notifications.length + ' ', { id: 'KillDialog', width: 550, buttons: [ {                               message: "Confirm", defaultButton: true, id: 'kill-notification-confirm', handler: function{ notification.remove; setInterval(function{                                       var dialog = $('#KillDialog');                                        dialog.closeModal;                                    }, 1000); }                           }, {                                message: "Cancel", id: 'kill-notification-cancel', handler: function{ var dialog = $('#KillDialog'); dialog.closeModal; }                           }                        ]                    });                }            };            kill.module;        }); } }); /* End Chat Stuff */

// User Data Script $(function{   if (!$('link[href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"]').length){ // Check to see that Font Awesome exists. If Font Awesome does not exist...        var fa = $(' ', { "rel": "stylesheet", "href": "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css", "type": "text/css" }); // ...create the element.       $(document.head).append(fa); // Insert the element to the element    }    if ($('.WikiaBarWrapper').length){ // If the .WikiaBarWrapper element exists...        // ...create the element....        var list = $(' ', { "class": "user-data-container", // ..., then insert the 'user-data-container' class name into the element. "id": "user-data-container", // After that, insert the 'user-data-container' id to the element html: function{ // Append the HTML to the element. var html = // Create the HTML '<a href="javascript:void(0);" class="toggle-user-data" id="toggle-user-data">' + '<i class="fa fa-chevron-right"></i>' + '</a>' + '<section class="user-data-wrapper" id="user-data-wrapper">' + '<header class="user-data-header" id="user-data-header">' + ' User Data ' + ' ' +                   '<nav class="user-data" id="user-data">' + '</ul>' + ' ' +                   '<form class="user-data-form" id="user-data-form" onsubmit="return false;">' + ' ' +                           '<input type="text" id="user-data-txt" class="user-data-txt" placeholder="Type username here" />' + '<a href="#" class="user-data-button" id="user-data-button">Enter</a>' + ' ' +                   ' ' +                    ' ';                return html; }       });        $('.WikiaBarWrapper').append(list); // Inserting the aside.user-data-container element to the .WikiaBarWrapper element        var user_data = {}; // Create the user_data object        user_data.add = function(username){ // Create the user_data.add function            var user; // Creating a variable            if (username){ // If the username argument is available...                user = username; // ...define the variable            } else { // else...                user = wgUserName; // ...insert the wgUserName variable            }            var url = '/User:' + encodeURIComponent(user); // Create the URL of the page            $.get(url, function(data){ // ..., then get the page. if (data){ var masthead = $(data).find('#UserProfileMasthead')[0], edits = $(masthead).find('.tally em').text, rights = $(masthead).find('.tag'), avatar = $(masthead).find('.avatar'), list = $(' ', {                           "class": "user-data-section",                            "data-user": user,                            html: function{                                var section =                                    ' ' +                                        '<img class="avatar" src="' + avatar.attr('src') + '" width="30" height="30" alt="' + user + '" />' +                                    ' ' +                                    ' ' +                                        ' ' + user + ' ';                                if (rights){                                    /*rights.each(function{ var t = $(this).text; section += '<var class="user-data-rights">' + t + ' '; }); // TBD                                   */                                }                                section +=                                     ' ' +                                    ' ' +                                        '<em class="numberofedits edits">' + edits + ' ' +                                        ' Edits ' +                                    ' ';                                return section;                            }                        }); $('.user-data .user-data-list').append(list); }           });        };        user_data.toggle = function{            var state = state || 0,                container = $('.user-data-container'),                wrapper = container.find('.user-data-wrapper'),                width = wrapper.width;            container.css('position', 'relative');            if (state === 0){                if (width){                    container.animate({ 'left': '-=' + width }, 1000, function{ state = 1; });               }            } else {                if (width){                    container.animate({ 'left': '+=' + width }, 1000, function{ state = 0; });               }            }        };        $('#toggle-user-data').on('click', function{ user_data.toggle; });       $('#user-data-button').on('click', function{ var user_val = $('#user-data-txt').val; if (user_val){ user_data.add(user_val); }       });    } });

function parseTags(tags){ var tag_regex = /<(.*)(| \w{1,})>(.*)<\/\1>/gi, base_elem = $('.WikiaArticle'); var tag = tag || { 'wikia-button': function(tag_regexp, attribs, content){ }   };    if (tags){ var t = Object.keys(tags); for (var i = 0; i < t.length; i++){ var action = tags[t[i]]; tag[t[i]] = action; }   }    if (typeof tag == 'object'){ var key = Object.keys(tag); for (var j = 0; j < key.length; j++){ if (typeof tag[key[j]] == 'function'){ var tag_name = base_elem.text.replace(tag_regex, '$1'), attr = base_elem.text.replace(tag_regex, '$2'), content = base_elem.text.replace(tag_regex, '$3'), attr_split_base = attr.split(' '), attr_split = attr_split || []; for (var k = 0; k < attr_split_base; k++){ if (attr_split_base){ attr_split = attr_split_base[k].split('='); }               }                if (key[j] == tag_name){ tag[tag_name].call(tag_regex, attr_split, content); }           }        }    } }

function getNumberOfEdits(user){ var edits; user = user || wgUserName; $('#edits-list').get('/User:' + encodeURIComponent(user), function(data){       var el = $(data).find('#UserProfileMasthead')[0],            editcount = el.find('.tally em');        var count = Number(editcount);        if (isNaN(count) === false){            edits = count;        }    }); var el = $(' ', {       "class": "edits-item",        "data-user": user,        html: ' ' + user + ' ' + edits + ' edits '    }); $('#edits-list').append(el); }

var editList = editList || {}; editList.create = function{ var list; if (!$('#edits-list').length){ list = '<aside class="edits-list-wrapper" id="edits-list-wrapper">' + '<a href="javascript:void(0);" class="edit-list-toggle" id="edit-list-toggle">' + '<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" class="svg-chevron">' + ' ' +                           '<linearGradient x1="0%" x2="0%" y1="100%" y2="0%" id="linearGrad1">' + '<stop offset="0%" style="stop-color:#dff8f8; stop-opacity:1;" />' + '<stop offset="50%" style="stop-color:#ffffff; stop-opacity:1;" />' + '<stop offset="100%" style="stop-color:#edffff; stop-opacity:1;" />' + '</linearGradient>' + ' ' +                       '<path d="M 15,6 L 0,15 24,30 30,24 15,15 30,6 24,0 15,6" fill="url(#linearGrad1)"/>' + ' ' +                   ' Toggle ' + '</a>' + '<nav class="edits-list-container" id="edits-list-container">' + '<header class="edits-list-header" id="edits-list-header">' + ' Editcount ' + ' ' +                   '</ul>' + '<form class="edits-list-form" id="edits-list-form" onsubmit="return false;">' + '<label for="edits-list-input" class="placeholder-overlay">Type Username ' + '<input type="text" id="edits-list-input" class="edits-list-input" name="edits-list" />' + '<a href="javascript:void(0);" class="edits-list-submit" id="edits-list-submit">' + '<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" class="svg-plus">' + '<path d="M 10,0 L 10,0 20,0 20,10 30,10 30,20 20,20 20,30 10,30 10,20 0,20 0,10 10,10" fill="white" />' + ' ' +                       '</a>' + ' ' +               ' ' +            ' ';        $('.WikiaSiteWrapper').append(list); } };

editList.create; getNumberOfEdits;

/* Portal Creator */ var portal = portal || {}; portal.create = function(obj){ var port, p, id, description, title, image, interactive, image_width, max; if (typeof obj == 'object'){ image_width = obj.image_width; max = Number(obj.max); port = obj.items; interactive = obj.interactive || false; id = obj.id || ''; description = obj.description || ''; p = '<section class="portal' + ((interactive === true) ? ' portal-interactive': ) + '"' + ((id !== null || id !== ) ? ' id="' + id + '"' : '') + '>' + ((description !== null || description !== ) ? '<header class="portal-description portal-header">' + description + ' ' : ); for (var i = 0; i < Object.keys(port).length; i++){ if (!isNaN(max)){ title = Object.keys(port)[i]; var port_obj = port[title]; image = port_obj.image; if (max < 1){ p += ' ' +                           '<figure class="portal-section" data-title="' + title + '">' + ' ' +                                   '<source srcset="' + image + '" type="' + (port_obj.imageType || 'image/jpeg' ) + '"/>' + '<img src="' + image + '" width="' + image_width + '" height="' + image_width + '" alt="' + title + '" />' + ' ' +                           ' ';                } else if (max >= 1 && max % 2){ p += '<figure class="portal-section" data-title="' + title + '">' + ' ' +                               '<source srcset="' + image + '" type="' + (port_obj.imageType || 'image/jpeg' ) + '"/>' + '<img src="' + image + '" width="' + image_width + '" height="' + image_width + '" alt="' + title + '" />' + ' ' +                       ' ' +                    ' ' +                    ' ';                } else if (max >= 1 && (max % 2) !== 0){ p += '<figure class="portal-section" data-title="' + title + '">' + ' ' +                               '<source srcset="' + image + '" type="' + (port_obj.imageType || 'image/jpeg' ) + '"/>' + '<img src="' + image + '" width="' + image_width + '" height="' + image_width + '" alt="' + title + '" />' + ' ' +                       ' ';                }                if ((Object.keys(port).length % 2) != 1){ p += ' '; }           }            $('.portal-container').html(p); }   } };

/* $('.WikiaRail').on('DOMNodeInserted', '*', function(e){ });

var ut = ut || {}; ut.skin = function(a, b){ var mw = mediaWiki; if (typeof a == 'object'){ if (mw.config.get('skin')){ var s = mw.config.get('skin'); a[s].call(s); }   } else if (typeof a == 'string') { if (mw.config.get('skin') == sk){ sk = mw.config.get('skin') || skin; b.call(sk); }   } };

ut.button = function(a, b, c){ var el, button; if (typeof a == 'object'){ for (var i in a){ el = $(a[i].elem); button = $('<a />', {               "class": "wikia-button",                "id": a[i].id,                text: i,                on: {                    'click': a[i].handler                }            }); if (a[i].type){ button.addClass(a[i].type); }           if (a[i].add == 'append'){ el.append(button); } else if (a[i].add == 'prepend'){ el.prepend(button); } else if (a[i].add == 'before'){ el.before(button); } else if (a[i].add == 'after'){ el.after(button); }       }    } else if (typeof a == 'string'){ el = $(b.elem); button = $('<a />', {           "class": "wikia-button",            "id": b.id,            text: a,            on: {                "click": c            }        }); if (b.type){ button.addClass(b.type); }       if (b.add == 'append'){ el.append(button); } else if (b.add == 'prepend'){ el.prepend(button); } else if (b.add == 'before'){ el.before(button); } else if (b.add == 'after'){ el.after(button); }   }    return button; };

ut.button('Click Here', {   elem: '.WikiaPageHeader .tally',    type: 'secondary',    add: 'after' }, function{    window.location = '/wiki/User:' + wgUserName.split(' ').join('_') + '/common.js'; });

(function($, mw){   if (mw.config.get('skin') == "oasis" || mw.config.get('skin') == "wikia" || mw.config.get('skin') == "venus"){        // Add clock to global navigation        var clock_style =             '.clock-container {' +                '\npadding-left: 10px;' +                 '\n}' +             '\n.clock-container .clock {' +                 '\ncolor: black;' +            '\n}';        function addZero(i){            if (i < 10) i = "0" + i;            return i;        }        if ($('.global-navigation').length && !$('.clock-container').length){            $('.global-navigation > .global-navigation-container').append($(' ', {                "class": "clock-container table-cell",                html: '<a href="?action=purge" class="clock"></a>'            }));            $('head').append('<style type="text/css" media="all" id="clock-container-style">' + clock_style + ' ');            setInterval(function{ var d;               if (new Date){ d = new Date; $('.clock-container .clock').html(addZero(d.getHours) + ':' + addZero(d.getMinutes) + ':' + addZero(d.getSeconds)); }           }, 1000);        }        // Add username to global navigation        if (mw.config.get('wgUserName')){            $('.global-navigation a[data-id="userpage"]').append(function{ if (!$('.global-navigation a[data-id="userpage"] > span.user-name').length){ return $(' ', {                       "class": "user-name",                        "data-user": mw.config.get('wgUserName'),                        text: mw.config.get('wgUserName')                    }); }           });        }    } })(jQuery, mediaWiki);

navigator.info = (function{   var N = navigator.appName,        ua = navigator.userAgent,         tem,        M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);    if (M && (tem = ua.match(/version\/([\.\d]+)/i))!== null) M[2] = tem[1];    M = M? [M[1], M[2]] : [N, navigator.appVersion, '-?'];    return M; }); function getBrowserName(name){ var browserName; if (name){ switch (name){ case 'MSIE': case 'Netscape': browserName = 'Internet Explorer'; break; case 'Firefox': browserName = 'Mozilla Firefox'; break; case 'Chrome': browserName = 'Google Chrome'; break; default: browserName = name; }       return browserName; } } function getBrowserVersion(value){ var v;   if (v > -1){ var value_split = value.split('.'), val = value_split[0]; v = Number(val); if (isNaN(v) === false) return v;       else return NaN; } } var browser = getBrowserName(navigator.info[0]), version = getBrowserVersion(navigator.info[1]); console.log('You are currently using ' + browser + ' ' + version + '!');