MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ //IIFE to prevent polluting global namespace //Variables: var debug = true;//set to false for released code //Actual Code: /*Utility Functions:*/ //use this function for debugging to the console function log{ debug && console && console.log && console.log.apply(console, Array.prototype.slice.call(arguments)); }   //executes a function when the DOM is ready function ready(fn){ /in/.test(document.readyState)?setTimeout(ready.bind(null, fn), 10):fn; }   /*Polyfills:*/ Array.isArray || (Array.isArray = function(obj){       return {}.toString.call(obj) == "[object Array]";    }); })(this, this.console);
 * (function(root, console, udf){

window.UserTagsJS = { modules: { mwGroups: [ 'bureaucrat', 'sysop', 'content-moderator', 'chatmoderator', 'threadmoderator', 'rollback', 'bot', 'bot-global' ],       metafilter: { sysop: ['bureaucrat'], 'content-moderator': ['bureaucrat', 'sysop'], chatmoderator: ['bureaucrat', 'sysop', 'content-moderator'], threadmoderator: ['bureaucrat', 'sysop', 'content-moderator', 'chatmoderator'], rollback: ['bureaucrat', 'sysop', 'content-moderator', 'chatmoderator', 'threadmoderator'] }   } };

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:WikiActivity.js',    ] }); /*Quiz:*/ var quizName = "Quiz"; var quizLang = "en"; var resultsTextArray = [ "You know nothing about Ak-Elfs! Come back once you're smarter!", "At least you know a little bit about me :)",   "You are my new best friend for finishing this!" ]; var questions = [    ["When did Ak join the wiki?",    "August 6 2020",    "August 5 2020",    "August 7th 2020",    "August 8th 2020"],     ["Who is Ak's best wiki friend?",    "ZachOWott",    "Swasimcool",    "Spyroclub1"],    ["When did Ak-Elfs get mod?",    "September 30 2020",    "October 1 2020"] ]; importArticles({ type: 'script', articles: [ 'u:dev:Quiz/code.js' ] });

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:UserAccountAge/code2.js',    ] });

// /** GameSlider by Luqgreg **/ /* Scripts used and modifed under CC-BY-SA license: - "Slider.js" by Pecoes & Vuh (https://elderscrolls.fandom.com/pl/wiki/MediaWiki:Slider.js) - "sliders using jquery" by Tierre (https://dragonage.fandom.com/wiki/MediaWiki:Common.js) */ // Slider if (mediaWiki.config.get('wgAction') === 'view') (function  {    'use strict';    var data_template;    function createSlider  {        /*jshint validthis:true*/        var scrollPane = $(this),            scrollPaneWidth = scrollPane.width,            scrollContent = scrollPane.find('.scroll-content'),            scrollContentWidth = 0,            data_startPos = defaultValue(scrollContent.data("startpos"), 0);            data_template = defaultValue(scrollContent.data("template"), "GameSlider/Content");        scrollContent.find('img').each(function  { var $this = $(this), width = $this.width; if (width) { scrollContentWidth += width; } else { $this.on('load', function {                    scrollContentWidth += $this.width;                }); }           var img_link = $this.parent; var param = img_link.attr("href").substr(1); img_link.attr("href", "javascript:void(0)"); img_link.click(function {                createContent(param);                 $(".content-active").removeClass("content-active");                 $(this).addClass("content-active");             }); });       var scrollbar = scrollPane.find('.scroll-bar').slider({ value: data_startPos, slide: function(event, ui) { if (scrollContentWidth > scrollPaneWidth) { scrollContent.css('margin-left', Math.round( ui.value / 100 * (scrollPaneWidth - scrollContentWidth) ) + 'px'); } else { scrollContent.css('margin-left', 0); }           }        });        scrollPane.css("overflow", "hidden");        if (scrollContentWidth > scrollPaneWidth) {            scrollContent.css('margin-left', Math.round(                data_startPos / 100 * (scrollPaneWidth - scrollContentWidth)            ) + 'px');        } else {            scrollContent.css('margin-left', 0);        }        scrollbar.find('.ui-slider-handle').css({ width: '60px', marginLeft: '-30px' });   }    function createContent (game) {        var gameSlider = $('.game-slider'),            gameContent = $('.game-content'),            gameContentMain = $('.game-content-main'),            gameContentLoader = $('.loader');        if (gameContent.length) {            gameContent.animate({ opacity: 0, }, 150);       } else {            gameSlider.after('    ');            gameContentMain = $('.game-content-main');            gameContent = $('.game-content');            gameContentLoader = $('.loader');            var targetHeight = gameContent.outerHeight;            gameContentMain.animate({ height: targetHeight }, 100);       }        if (gameContentLoader.length) {            gameContentLoader.animate({ opacity: 1, }, 250);       }        var api = new mw.Api;        api.get({ action: 'parse', format: 'json', text: '' }).done(function(data) { if(!data.error) { var code = data.parse.text['*']; if (gameContentLoader.length) { gameContentLoader.animate({                       opacity: 0,                    }, 100); }               gameContent.html(code); createContentSlider; gameContent.animate({                   opacity: 1,                }, 150); }       });    }    $(function  { var gameSlider = $('.game-slider'); if (!gameSlider.length) return; $('head').append(''); importArticle({           type: "style",            article: "u:dev:MediaWiki:GameSlider.css"        }); gameSlider .wrap(' ') .addClass('scroll-content') .before('  '); mediaWiki.loader.using('jquery.ui.slider', function {            $('.scroll-pane').each(createSlider);        }); }); }); function createContentSlider { mw.loader.using(['jquery.cookie']); mw.loader.using(['jquery.ui.tabs'], function {       $("[class^=portal_vtab]").tabs.addClass("ui-tabs-vertical ui-helper-clearfix");        var $tabs = $("#portal_slider").tabs({ fx: {opacity:'toggle', duration:100}});        $("[class*=portal_sliderlink-]").click(function { $tabs.tabs('select', this.className.match(/portal_sliderlink-(\d+)/)[1]); return false; });       $(".game-content .ui-corner-all").removeClass("ui-corner-all");        $(".game-content .ui-corner-left").removeClass("ui-corner-left");        $(".game-content .ui-corner-right").removeClass("ui-corner-right");        $(".game-content .ui-corner-top").removeClass("ui-corner-top");        $(".game-content .ui-corner-bottom").removeClass("ui-corner-bottom");        $(".game-content .ui-widget-content").removeClass("ui-widget-content");    }); } function defaultValue(variable, defaultVal) { if(variable !== undefined && variable !== null) return variable; return defaultVal; }