User:Ultimate Dark Carnage/wikia.js

importArticles({   type: 'style',    articles: [        'User:Ultimate_Dark_Carnage/advancedui.css',        'User:Ultimate_Dark_Carnage/toolbar.css'    ] }/*, {    type: 'script',    articles: [        'u:dev:DoTheHarlemShake/code.js'    ] }*/);

// Carnage's Code // DO NOT COPY!! // Create your own user-exclusive script var Carnage = null, video_code, WikiaElement = null, elem_obj = null; WikiaElement = {}; elem_obj = { get modules{ return document.getElementsByClassName('module'); },   /*    get localNavigation{ var nav = document.getElementsByClassName('WikiHeader')[0]; var wikiNav = this.navigation = nav.getElementsByClassName('WikiNav')[0]; var wordmark = this.wordmark = nav.getElementsByClassName('wordmark')[0]; var firstLevel = this.nav = (wikiNav.children[1].nodeName.toUppercase == 'ul' && wikiNav.children[1].className == 'nav') ? wikiNav.children[1] : wikiNav.getElementsByClassName('nav')[0]; var top_menu = this.topMenu = (function(topNav){           var navObj = "{",                navItem, navLink, navItemTxt;            for (var i = 0; i < topNav.children.length; i++){                navItem = topNav.children[i];                navLink = navItem.children[0];                navItemTxt = navLink.text;                navObj += '"' + String(navItemTxt) + '": {';                navObj += 'elem: navItem';                navObj += 'link: navLink';                navObj += '}';                if (topNav.children.length > 1){                    if (i < (topNav.children.length - 1)){                        navObj += ', \n';                    }                }            }            navObj += '}';            return eval(navObj);        })(firstLevel); return nav; }   */    get article{ return function(type){ if (type == "content") return document.getElementsByClassName('WikiaArticle'); else if (type == "body") return document.getElementsByClassName('WikiaMainContent'); };   },    get body{ return document.getElementsByClassName('WikiaSiteWrapper')[0]; },   get globalNav{ var globalNav = document.getElementsByClassName('global-navigation')[0], globalNavWrapper = globalNav.getElementsByClassName('global-navigation-wrapper')[0]; this.addLinks = function(class_name, content){ var el = document.createElement('div'); el.className = class_name + ' table-cell'; el.innerHTML = content; globalNavWrapper.appendChild(el); };       this.globalNavElem = function{ return globalNav; };       this.globalNavWrapper = function{ return globalNavWrapper; };       this.globalNavLinks = function{ return globalNavWrapper.children; };       return this; },   get ads{ var ad = document.getElementsByClassName('wikia-ad'); if (ad){ this.kill = function{ var parent = ad.parentElement; if (parent){ parent.removeChild(ad); }           };        }        return ad; },   get buttons{ var nodes = null, i;       return function(type){ switch (type){ case 'wikia-button': case 'wikia-button/secondary': case 'button': case 'button/secondary': case 'button-el': case 'button-el/secondary': return (function{                       var wikia_button = (type.indexOf('button') > -1 && type.indexOf('-') === -1) ? document.getElementsByClassName('button') :                             ((type.indexOf('button-el') > -1) ? document.getElementsByTagName('button') : ((type.indexOf('wikia-button') > -1) ? document.getElementsByClassName('wikia-button') : ''));                       nodes = [];                        if (type.indexOf('secondary') > -1){                            for (i = 0; i < wikia_button.length; i++){                                if (wikia_button[i].className.indexOf('secondary') > -1){                                    nodes.push(wikia_button[i]);                                }                            }                            if (nodes.length === 0){                                return false;                            } else {                                return nodes;                            }                        } else {                            for (i = 0; i < wikia_button.length; i++){                                if (wikia_button[i].className.indexOf('secondary') === -1){                                    nodes.push(wikia_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       }                    });                case 'wikia-menu-button':                case 'wikia-menu-button/secondary':                case 'wikia-menu-button/combined':                case 'wikia-menu-button/contribute':                case 'wikia-menu-button/all':                    return (function{ var wikia_menu_button = document.getElementsByClassName('wikia-menu-button'), nodes = []; if (type.indexOf('secondary') > -1){ for (i = 0; i < wikia_menu_button.length; i++){ if (wikia_menu_button[i].className.indexOf('secondary') > -1 && wikia_menu_button[i].className.indexOf('contribute') + wikia_menu_button[i].className.indexOf('combined') < 0){ nodes.push(wikia_menu_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       } else if (type.indexOf('combined') > -1){ for (i = 0; i < wikia_menu_button.length; i++){ if (wikia_menu_button[i].className.indexOf('combined') > -1 && wikia_menu_button[i].className.indexOf('contribute') + wikia_menu_button[i].className.indexOf('secondary') < 0){ nodes.push(wikia_menu_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       } else if (type.indexOf('contribute') > -1){ for (i = 0; i < wikia_menu_button.length; i++){ if (wikia_menu_button[i].className.indexOf('contribute') > -1 && wikia_menu_button[i].className.indexOf('secondary') + wikia_menu_button[i].className.indexOf('secondary') < 0){ nodes.push(wikia_menu_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       } else if (type.indexOf('all') > -1){ for (i = 0; i < wikia_menu_button.length; i++){ if (wikia_menu_button[i].className.indexOf('combined') + wikia_menu_button[i].className.indexOf('contribute') + wikia_menu_button[i].className.indexOf('secondary') > -1){ nodes.push(wikia_menu_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       } else { for (i = 0; i < wikia_menu_button.length; i++){ if (wikia_menu_button[i].className.indexOf('combined') + wikia_menu_button[i].className.indexOf('contribute') + wikia_menu_button[i].className.indexOf('secondary') < 0){ nodes.push(wikia_menu_button[i]); }                           }                            if (nodes.length === 0){ return false; } else { return nodes; }                       }                    });                case 'all':                    return (function{ var wikiaButton = document.getElementsByClassName('wikia-button'), Button = document.getElementsByClassName('button'), buttonEl = document.getElementsByTagName('button'), wikiaMenuButton = document.getElementsByClassName('wikia-menu-button'), input = document.getElementsByTagName('input'), inputArr = null, i, j;                       inputArr = []; nodes = []; for (i = 0; i < input.length; i++){ var inputAttr = input[i].getAttribute('type'); if (inputAttr.indexOf('submit') > -1 || inputAttr.indexOf('button') > -1 || inputAttr.indexOf('reset') > -1){ inputArr.push(input[i]); }                       }                        var elemArr = [wikiaButton, Button, buttonEl, wikiaMenuButton, inputArr]; for (i = 0; i < elemArr.length; i++){ for (j = 0; j < elemArr[i].length; j++){ nodes.push(elemArr[i][j]); }                       }                        return nodes; });               default:                    return false;            }        };    } };

video_code = video_code || 'TWHNr0BrNgo'; Carnage = {};

Carnage.init = function{ if (wgUserName == "Ultimate Dark Carnage"){ var // c = Carnage.enableInfoModule, a = Carnage.animatedSubnav, d = Carnage.mastheadBackground, // i = Carnage.ignoreList.init(Carnage.ignoreList.users), /*m = (function{               $('.WikiaBarWrapper .tools').append($(' ', {                    "class": "overflow custom",                    html: $('', { "href": "javascript:void(0);", "class": "music-link", text: 'Play Music', on: { 'click': function{ Carnage.playMusic(video_code); }                       }                    })                }));            });*/            e = Carnage.extendObj(WikiaElement, elem_obj); } };

// Add custom module var $modal_html = ''; $('.WikiaRail').on('DOMNodeInserted', '.ChatModule', function(event){   var $WikiaRail = $('.WikiaRail'),        $module =             $(' ')            .addClass('CustomModule module')            .attr('id', 'CustomModule')            .html(function{ var $heading = $(' ')                   .text('Test'), $content = $(' ')                   .addClass('module-content center') .html(                       $('')                        .attr('href', '#custom-modal')                        .attr('id', 'modal-trigger')                        .addClass('modal-trigger wikia-button')                        .text('Click Here')                    ); return [$heading, $content]; }),       $chat_module = $WikiaRail.children('.ChatModule');    if (!$('#CustomModule').length) $chat_module.after($module);    $('.modal-trigger').on('click', function(event){ if (!$('#custom-modal').length) $('.WikiaSiteWrapper').append(           $(' ')            .addClass('modal-blackout modal-wrapper')            .attr('id', 'custom-modal')            .on('click', function(event){ if (!$(event.target).is('.modal-body, .modal-body *')){ $close_modal($('.modal-wrapper').attr('id'), function(modal){                       return this;                    }); }           })            .html( $(' ')               .addClass('modal-body _modal') .attr({ 'id': 'custom-modal-body', 'data-title': 'Test' }) .html(function{                   var $header =                         $(' ')                        .addClass('modal-header')                        .html([ $(' ').text('Test'), $('') .attr('href', '#') .attr('id', 'close-modal') .addClass('close-modal') .text('✕') .on('click', function(event){                               $close_modal($('.modal-wrapper').attr('id'), function(modal){ return this; });                           })                        ]),                        $content =                        $(' ')                        .addClass('modal-content')                        .html($modal_html || 'Test'),                        $footer =                        $(' ')                        .addClass('modal-footer right')                        .html( $('') .addClass('modal-button') .attr('id', 'modal-submit-button') .text('Submit') .on('click', function(event){                               $close_modal($('.modal-wrapper').attr('id'), function(modal){ return this; });                           })                        );                    return [$header, $content, $footer];                }) )       );    });    var $close_modal = $close_modal || function(id, action){        var $modal = null;        if (!jQuery) $modal = document.getElementById(id);        else $modal = $('#' + id);        if (!jQuery){            if ($modal.className.indexOf('modal-wrapper') > -1){                var parent = $modal.parentElement || $modal.parentNode;                parent.removeChild($modal);            } else return false;        } else {            if ($modal.hasClass('modal-wrapper')){                $modal.remove;            }        }        if (action instanceof Function) Function.prototype.apply.call(action, window, [$modal]);    }; });

Carnage.extendObj = function(obj1, obj2){ if (typeof obj1 == "object"){ for (var prop in obj2){ if (obj2.hasOwnProperty(prop)){ obj1[prop] = obj2[prop]; }       }        if (typeof obj2 == "object") delete obj2; } else if (typeof obj1 == "undefined"){ obj1 = obj2; if (typeof obj2 == "object") delete obj2; return obj1; } };

Carnage.circular = function(elem, parent){ var e = (elem) ? elem : ((parent) ? parent.getElementsByTagName('li') : ''); if (e && e.length > 5){ var deg_val = 360/e.length; if (Array.forEach) Array.prototype.forEach.call(e, function(el, i){           var deg = Math.round(deg_val * i),                s = document.querySelector(el);            s.style.webkitTransform = 'rotate(' + deg + 'deg)';            s.style.mozTransform = 'rotate(' + deg + 'deg)';            s.style.msTransform = 'rotate(' + deg + 'deg)';            s.style.oTransform = 'rotate(' + deg + 'deg)';            s.style.transform = 'rotate(' + deg + 'deg)';            if (deg > 90 && deg < 270){                var l = el.getElementsByTagName('a')[0] || el.children[0];                if (l){                    l.style.webkitTransform = 'rotate(' + 180 + 'deg)';                    l.style.mozTransform = 'rotate(' + 180 + 'deg)';                    l.style.msTransform = 'rotate(' + 180 + 'deg)';                    l.style.oTransform = 'rotate(' + 180 + 'deg)';                    l.style.transform = 'rotate(' + 180 + 'deg)'; }           }        });        else {            for (var i = 0; i < e.length; i++){                var el = e[i];                var deg = Math.round(deg_val * i),                s = document.querySelector(el);                s.style.webkitTransform = 'rotate(' + deg + 'deg)';                s.style.mozTransform = 'rotate(' + deg + 'deg)';                s.style.msTransform = 'rotate(' + deg + 'deg)';                s.style.oTransform = 'rotate(' + deg + 'deg)';                s.style.transform = 'rotate(' + deg + 'deg)';                if (deg > 90 && deg < 270){                    var l = e.getElementsByTagName('a')[0];                    if (l){                        l.style.webkitTransform = 'rotate(' + 180 + 'deg)';                        l.style.mozTransform = 'rotate(' + 180 + 'deg)';                        l.style.msTransform = 'rotate(' + 180 + 'deg)';                        l.style.oTransform = 'rotate(' + 180 + 'deg)'; l.style.transform = 'rotate(' + 180 + 'deg)'; }               }            }        }    } };

Carnage.animatedSubnav = function{ var el = $('.WikiHeader > nav .subnav-2 li, .wikia-menu-button .drop, .wikia-menu-button.combined, .WikiaBarWrapper .mytools'); el.each(function{       if ($(this).is('.mytools') === true){            $(this).hover(function slideUp{ if ($(this).children('ul.tools-menu').is(':hidden') === true){ $(this).children('ul.tools-menu').animate({                       'bottom': '22px'                    }).fadeIn; }           }, function slideDown{ if ($(this).children('ul.tools-menu').is(':hidden') === false){ $(this).children('ul.tools-menu').animate({                       'bottom': '0'                    }).fadeOut; }           });        } else if ($(this).is('.wikia-menu-button .drop') === true){            $(this).click(function toggleWikiaMenuElement{ var menu_button = $(this).parent; if (menu_button.children('.WikiaMenuElement').is(':hidden') === true){ menu_button.children('.WikiaMenuElement').animate({                       'top': '19px'                    }).fadeIn; } else { menu_button.children('.WikiaMenuElement').animate({                       'top': '0'                    }).fadeOut; }           });        } else {            $(this).hover(function slideDown{ if ($(this).children('.subnav.subnav-3').is(':hidden') === true){ $(this).children('.subnav.subnav-3').animate({                       'top': '28px',                        'opacity': '1'                    }).fadeIn; }           }, function slideUp{ if ($(this).children('.subnav.subnav-3').is(':hidden') === false){ $(this).children('.subnav.subnav-3').animate({                       'top': '0',                        'opacity': '0'                    }).fadeOut; }           });        }    }); };

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

// 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 '' + '' + '' + '' + '' + ' User Data ' + ' ' +                   '' + '' + ' ' +                   '' + ' ' +                           '' + '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 =                                    ' ' +                                        '' +                                    ' ' +                                    ' ' +                                        ' ' + 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 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 class="edits-list" id="edits-list"></ul>' + '<form class="edits-list-form" id="edits-list-form" onsubmit="return false;">' + '<label for="edits-list-input" class="placeholder-overlay">Type Username ' + '' + '<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;

/* $('.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){ value = Number(value.split('.')[0]); if (!isNaN(value)){ return value; } else { return NaN; } } var browser = getBrowserName(navigator.info[0]), version = getBrowserVersion(navigator.info[1]); console.log('You are currently using ' + browser + ' ' + version + '!');