FANDOM


//
;(function (mw, $, w) {
 
    'use strict';
 
    var mainContent, localLink, globalLink, page;
 
    if (mw.config.get('wgCanonicalNamespace') !== 'Special' || mw.config.get('wgTitle') !== 'ScriptPreferences') {
        if (['view', 'history'].indexOf(mw.config.get('wgAction')) !== -1) {
            addSpecialPageLink();
        }
        return;
    }
 
    w.document.title = 'Special:ScriptPreferences';
 
    $(function () {
        loadCSS();
        modifyHeader();
        addSections();
        addTab('Demo 1', 'local preferences for addon "Demo 1"', true);
        addTab('Demo 2', 'local preferences for addon "Demo 2"', true);
        addTab('Demo 3', 'local preferences for addon "Demo 3"', true);
        addTab('Demo 4', 'local preferences for addon "Demo 4"', true);
        addTab('Demo 1', 'global preferences for addon "Demo 1"', false);
        addTab('Demo 2', 'global preferences for addon "Demo 2"', false);
        addTab('Demo 3', 'global preferences for addon "Demo 3"', false);
        addTab('Demo 4', 'global preferences for addon "Demo 4"', false);
        addPublicTab('public preferences for all addons');
    });
 
    function addSpecialPageLink () {
        $('#AccountNavigation')
        .find('ul.subnav')
        .find('li').has('a[data-id="preferences"]')
        .after('<li id="script-prefs"><a href="/wiki/Special:ScriptPreferences">My scripts</a></li>');
    }
 
    function addPublicTab (contents) {
        $('#contents-public').append(contents);
        if (w.location.hash === '#public') {
            $('#public-link').click();
        }
    }
 
    function evaluateHash () {
        var hash = $(this).attr('href');
        var matches = hash.match(/^#(\w+)(?:\:(local|global))?$/);
        if (!matches) return false;
        var addon = matches[1] === 'public' ? false : matches[1];
        var local = matches[2] === 'local';
        $('.addon-name')
        .removeClass('active')
        .find('[href="' + hash + '"]').parent()
        .addClass('active');
        if (!addon) {
            page.addClass('public')
            .removeClass('local').removeClass('global');
        } else {
            // add test to check if hash actually exists!
            localLink.attr('href', '#' + addon + ':local');
            globalLink.attr('href', '#' + addon + ':global');
            var contents = $('.script-contents');
            contents.children()
            .css('display', 'none');
            contents.find('[rel="' + hash + '"]')
            .css('display', 'block');
            if (local) {
                page.addClass('local')
                .removeClass('public').removeClass('global');
            } else {
                page.addClass('global')
                .removeClass('public').removeClass('local');
            }
        }
        w.location.replace(hash);
        return false;
    }
 
    function loadCSS () {
        mainContent = $('#WikiaMainContent');
        page = $('#WikiaPage');
        var code = '@import url(http://fonts.googleapis.com/css?family=Coda);body.script-prefs article#WikiaMainContent{min-height:400px}body.script-prefs article#WikiaMainContent{width:100%;margin:0}body.script-prefs header#WikiaPageHeader,body.script-prefs div#WikiaArticle,body.script-prefs div#WikiaArticleBottomAd,body.script-prefs div#WikiaRail,body.script-prefs section#WikiaSearchHeader,body.script-prefs header#AdminDashboardHeader,body.script-prefs section#WikiAnswers,body.script-prefs div.adm-dash-search{display:none}body.script-prefs #WikiHeader,body.script-prefs #WikiHeader h1.wordmark,body.script-prefs #WikiHeader h1.wordmark a{background-image:none;color:linkColor!important}body.script-prefs #WikiHeader h1.wordmark{font-family:Coda,Arial,Helvetica,sans-serif;font-size:26px;position:relative;top:38px}body.script-prefs #WikiHeader h1.wordmark:before{background:none repeat scroll 0 0 transparent}#WikiaPage.public #tabs-local,#WikiaPage.public #tabs-global,#WikiaPage.local #contents-public,#WikiaPage.local #tabs-global,#WikiaPage.global #tabs-local,#WikiaPage.global #contents-public{display:none}#WikiaPage.public #contents-public,#WikiaPage.local #tabs-local,#WikiaPage.global #tabs-global{display:block}#WikiaPage.public #public-link,#WikiaPage.local #local-link,#WikiaPage.global #global-link{color:textColor;cursor:default}#prefs-links{font-family:Coda,Arial,Helvetica,sans-serif;font-size:11px;left:12px;position:absolute;top:30px}#prefs-links span,#prefs-links a{border-left:1px solid textColor;height:10px;padding:0 8px}#prefs-links>*:first-child{border:medium none;padding-left:0}#preferences{margin:1em 0 0 0;padding:0}#preferences *{font-family:Coda,Arial,Helvetica,sans-serif;font-size:11px}.script-names{border-bottom:1px solid textColor;padding:20px 0 8px;list-style:none;list-style-position:outside}.script-names>li{display:inline-block}.script-names>li>a{text-decoration:none;outline:medium none;background-color:transparent;border:1px solid bgColor;border-bottom:0;border-radius:3px 3px 0 0;margin-left:6px;padding:.4em .6em 8px;cursor:pointer}.script-names>li>a:hover{border:1px solid textColor;border-bottom-color:transparent}.script-names>li.active>a,.script-names>li.active>a:hover{background-color:transparent;border:1px solid textColor;border-bottom-color:bgColor;cursor:default}.script-contents{min-height:300px;padding:30px 25px}.script-settings{display:none}#contents-public{border-top:1px solid textColor;margin-top:55px}';
        var linkColor = $('footer.CorporateFooter').find('ul').find('a:first').css('color');
        var textColor = mainContent.css('color');
        var bgColor = $('#WikiaPageBackground').css('background-color');
        if (!bgColor || 'transparent' === bgColor) {
            bgColor = page.css('background-color');
        } else if (!bgColor || 'transparent' === bgColor) {
            bgColor = $(w.document.body).css('background-color');
        }
        $('body.mediawiki').addClass('script-prefs');
        mw.util.addCSS(code
            .replace(/linkColor/g, linkColor)
            .replace(/textColor/g, textColor)
            .replace(/bgColor/g, bgColor)
        );
    }
 
    function modifyHeader () {
        $('#WikiHeader').find('h1.wordmark').find('a')
        .text('Script Preferences')
        .attr('href', '//dev.wikia.com/wiki/Preferences');
        $('<div id="prefs-links">' +
            '<a id="local-link">local [private]</a>' +
            '<a id="global-link">global [private]</a>' +
            '<a id="public-link" href="#public">public</a>' +
        '</div>')
        .prependTo('#WikiHeader')
        .children('a')
        .click(evaluateHash);
        localLink = $('#local-link');
        globalLink = $('#global-link');
    }
 
    function addTab (name, contents, local) {
        var internal = name.replace(/\W/g, '_') + (local ? ':local' : ':global');
        if (!w.location.hash) {
            w.location.replace('#' + internal);
        }
        if (local && !localLink.attr('href')) {
            localLink.attr('href', '#' + internal);
        }
        if (!local && !globalLink.attr('href')) {
            globalLink.attr('href', '#' + internal);
        }
        var li = $('<li class="addon-name"><a href="#' + internal + '">' + name + '</a></li>')
            .appendTo(local ? '#names-local' : '#names-global');
        $(w.document.body).prepend('<a name="' + internal + '"></a>');
        var settings = $('<div class="script-settings" rel="#' + internal + '">' + contents + '</div>')
        .appendTo(local ? '#contents-local' : '#contents-global');
        li.find('a').click(evaluateHash);
        if (w.location.hash === '#' + internal) {
            li.find('a').click();
        }
        return settings;
    }
 
    function addSections () {
        mainContent
        .prepend('<section id="preferences">' +
            '<div id="tabs-local"><ul class="script-names" id="names-local"></ul><div class="script-contents" id="contents-local"></div></div>' +
            '<div id="tabs-global"><ul class="script-names" id="names-global"></ul><div class="script-contents" id="contents-global"></div></div>' +
            '<div class="script-contents" id="contents-public"></div>' +
        '</section>')
        .addClass('local');
    }
 
}(mediaWiki, jQuery, window));
//

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.