User:Ultimate Dark Carnage/wikia.js

importArticles({   type: 'style',    articles: [        'User:Ultimate_Dark_Carnage/advancedui.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); } };

Carnage.mastheadBackground = function{ if ($('#WikiaUserPagesHeader').length){ var url = '/wiki/User' + encodeURIComponent(wgUserName) + '/Masthead_settings'; $.get(url, function(data){           var article = $(data).find('.WikiaArticle')[0],                masthead_settings = article.find('div#masthead-settings').children('ul'),                settings = masthead_settings.children('li'),                settings_obj = {};            $(settings).each(function configure{ var s = $(this), settings_split = s.text.split(': '); settings_obj[settings_split[0]] = settings_split[1]; });           for (var j in settings_obj){                var val = (typeof val == "string") ? settings_obj[j] : String(settings_obj[j]);                switch (j){                    case 'mastheadBackground':                        $('#WikiaUserPagesHeader').css('background', ((val.match(/http:\/\/www\.(.*)/gi) ? 'url(' + val + ')' : val)));                       break;                    case 'mastheadShadow':                        $('#WikiaUserPagesHeader').css('box-shadow', val);                        break;                    case 'mastheadFont':                        $('#WikiaUserPagesHeader').css('font-family', val);                        break;                    default:                        return false;                }            }        }); } };

Carnage.ignoreList = {}; Carnage.ignoreList.init = function(users){ if ($.isArray(users)){ for (var i = 0; i < users.length; i++){ if (users[i]){ $('.ChatWindow [data-user="' + users[i] + '"]').hide; }       }    } };

Carnage.ignoreList.users = ["Jr Mime", "Josephyr", "TyA", "Callofduty4", "CCChatBot"]; /* Carnage.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 += ' '; var numberOfEdits, edited_since_base, edited_since, user, avatar; var moduleURL = '/User:Ultimate_Dark_Carnge'; $.get(moduleURL, function(data){                           var wikia_page = $(data).find('.WikiaSiteWrapper')[0],                                masthead = $(wikia_page).find('#UserProfileMasthead');                            if (masthead.length){                                numberOfEdits = masthead.find('.tally em').text;                                edited_since_base = masthead.find('.tally span').html;                                edited_since = edited_since_base.split(' ')[1];                               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);            }        }); } };

Carnage.playMusic = function(code){ if (code.match(/(.*?)/gi)){ var html = '<iframe src="https://www.youtube.com/watch?v=';       if (code){            html += code;        }        html += '&hl=en_US&theme=dark&color=white&loop=1&autoplay=0" frameborder="0" allowfullscreen="0"> '; var sel = $(html); if (sel.length){ $('.WikiaSiteWrapper').append(sel.hide); }   } };

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; }); // 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 +=                                     ' ' +                                    '<