User:.jun/global.js

require(['wikia.window', 'mw'], function(context, mw) {   document.getElementsByClassName('wds-global-navigation__search-input')[0].addEventListener('blur', function(elem) { if (!elem.srcElement.value) { document.getElementById('globalNavigation').classList.remove('wds-search-is-active'); }   });    if (mw.config.get('wgCanonicalSpecialPageName') == 'Recentchanges') {        Array.prototype.forEach.call(document.querySelectorAll('.rc-conntent a'), function(elem) { if (elem.getAttribute('href') !== '#') { elem.setAttribute('target', '_blank'); }       });    }    context.ajaxCallAgain = context.ajaxCallAgain || [];    context.ajaxCallAgain.push(function { Array.prototype.forEach.call(document.querySelectorAll('.rc-conntent a'), function(elem) {           if (elem.getAttribute('href') !== '#') {                elem.setAttribute('target', '_blank');            }        }); });   context.ajaxPages = ['Special:RecentChanges', 'Special:WikiActivity'],    context.ajaxRefresh = 30000;    Array.prototype.forEach.call(document.querySelectorAll('a[data-canonical="wikiactivity"]'), function(elem) { elem.href = '/wiki/Special:Recentchanges'; elem.innerHTML = 'Recent changes'; });   var links = {        debug: 'debug=true',        nocss: 'useusercss=0',        nojs: 'useuserjs=0',        qqx: 'uselang=qqx',        vector: 'useskin=vector',        mercury: 'useskin=mercury',        monobook: 'useskin=monobook'    },        parent = document.getElementsByClassName('wds-global-navigation__links-and-search')[0];    for (var i = 0; i < parent.childNodes.length; i++) {        if (parent.childNodes[i].classList && parent.childNodes[i].classList.value !== 'wds-global-navigation__search') {            parent.removeChild(parent.childNodes[i]);        }    }    for (i in links) {        if (links.hasOwnProperty(i)) {            var elem = document.createElement('a');            elem.href = mw.config.get('wgArticlePath').replace(/\$1/g, mw.config.get('wgPageName') + (!!context.location.search ? (!(context.location.search.indexOf(links[i]) > -1) ? (context.location.search + '&' + links[i]) : context.location.search) : ('?' + links[i])) + (!!context.location.hash ? context.location.hash : ''));           elem.className = 'wds-global-navigation__link';            elem.innerHTML = i;            parent.insertBefore(elem, parent.firstChild);        }    }    var persistentParameterList = ['useskin', 'uselang', 'usesitecss', 'usesitejs', 'useusercss', 'useuserjs', 'usevector'];    mw.util.addCSS( '#source-code, #source-toc {' + 'font-family: monaco, monospace !important;' + '}' +       '#source-code > a {' + 'color: ' + context.getComputedStyle(document.getElementsByTagName('a')[0]).color + ' !important;' + 'font-weight: bold;' + '}'   );    importArticles({ type: 'script', articles: [ 'u:dev:AjaxRC/code.js', 'u:dev:PersistentParameters/code.js', 'u:dev:LastEdited/code.js', 'u:dev:QuickDiff/code.js', 'u:dev:View_Source/code.js' ]   }); });

/* classification thing */ if (mw.config.get('wgCanonicalNamespace') == 'Template') { require(['mw', 'wikia.nirvana'], function(mw, nirvana) {       var types = {            192: 'infobox', // `            49: 'quote', // 1            50: 'navbox', // 2            51: 'notice', // 3            52: 'context-link', // 4            53: 'infoicon', // 5            54: 'scrollbox', // 6            55: 'references', // 7            56: 'media', // 8            57: 'data', // 9            48: 'design', // 0            189: 'navigation', // -            187: 'nonarticle' // =        };        document.addEventListener('keyup', function(event) { var type = types[event.which || event.keyCode]; nirvana.sendRequest({               controller: 'TemplateClassificationApi',                method: 'classifyTemplate',                data: {                    pageId: mw.config.get('wgArticleId'),                    type: type,                    editToken: mw.user.tokens.values.editToken                },                callback: function {                    document.getElementsByClassName('template-classification-type-label')[0].innerHTML = type;                    var notification = new BannerNotification('Successfully changed template type to: ' + type, 'confirm');                    notification.show;                }            }); });   }); }