MediaWiki:Common.js

/******************************************************************************/ /*            SCRIPTS EXECUTED AFTER THE HTML DOCUMENT IS LOADED             */ /******************************************************************************/

$(function {

"use strict";

////////////////////////////////////////////////////////////////////////////   //                                GENERAL                                 // ////////////////////////////////////////////////////////////////////////////

/*****************/   /* Spoiler Alert */ /*****************/

// This script must always be the very first executed

// Enables the alerts only in articles within the category "Spoilers" if ($.inArray("Spoilers", mw.config.get('wgCategories')) > -1) {

// Alert var alert = '' + ' ' +       ' ';

// Inserts the alert var lastVisit = window.localStorage.getItem('spoilerCache'); // Gets the timestamp of the last visit stored in the cache var thisVisit = Date.now; // Returns the current time in milliseconds var howLong = thisVisit - lastVisit; // Checks how much time has passed since the last visit if (howLong > 2592000000) { // Inserts the alert if it's been more than one month since the last visit or the user has never visited the site $('#WikiaMainContentContainer').before(alert); document.getElementById("WikiaMainContentContainer").style.filter = "blur(15px)"; // Sets a blurring of 15px document.getElementById("WikiaMainContentContainer").style.WebkitFilter = "blur(15px)"; // Sets blurring in Webkit browsers var opacity = $('#WikiaPageBackground').css('opacity'); // Saves the original value of the opacity of the background document.getElementById("WikiaPageBackground").style.opacity = "1"; // Temporarily disables the opacity

// Actions when clicking yes or no           $('#yes').click(function  {                $('#spoiler-container').remove; // Removes the alert                document.getElementById("WikiaMainContentContainer").style.filter = "none"; // Removes the blurring                document.getElementById("WikiaMainContentContainer").style.WebkitFilter = "none"; // Removes the blurring in Webkit browsers                document.getElementById("WikiaPageBackground").style.opacity = opacity; // Restores the original opacity                localStorage.setItem("spoilerCache", thisVisit); // Saves the timestamp of this visit            }); $('#no').click(function {                $('#spoiler-alert').remove; // Removes the alert            }); }

// Adds button to rehide spoilers to the row of buttons $('#WikiaPageHeader').append('Rehide spoilers'); $('#reset-spoilers').click(function {            localStorage.removeItem('spoilerCache');            location.reload;        }); }

/********************************************/   /* Inserts links to blogs in navigation bar */ /********************************************/

$('.subnav-2').first.append('Blogs');

/********************************/   /* Tooltips for the media icons */ /********************************/

$("#media-icons a").tooltip;

////////////////////////////////////////////////////////////////////////////   //                               HOMEPAGE                                 // ////////////////////////////////////////////////////////////////////////////

if (mw.config.get('wgIsMainPage') === true) {

/*******************************/       /* Random Episode and Calendar */ /*******************************/

var parse = function (page, div) { $.ajax({               dataType: 'text',                data: {                    action: 'parse',                    format: 'xml',                    disablepp: '1',                    prop: 'text',                    text: page                    },                url: '/api.php',                success: function (data) {                    $(div).html($('text', $(data)[1]).text);                }            }); };       var values = [ ['', 'div#RandomEpisode'], ['', 'div#Calendar'] ];       values.forEach(function (args) {            parse.apply(null, args);        });

/**************************/       /* Homepage Social Module */ /**************************/

var homeSocial = ' ';

$('div#social-module').html(homeSocial);

/***************************/       /* Homepage Discord Module */ /***************************/

/*var homeDiscord = ' ';

$('div#discord-module').html(homeDiscord);*/

}

});

/******************************************************************************/ /*  SCRIPTS EXECUTED AFTER THE WHOLE PAGE AND ALL OBJECTS HAVE BEEN LOADED   */ /******************************************************************************/

$(window).load(function {

'use strict';

/*****************/   /* Social Module */ /*****************/

// Module var socialModule = '' + '' + '' +       '' + ' ' +   '' + ' Follow us! ' +       ' ' +    ' ';

// Variables var namespaces = [ 2, // User profiles 1200 // Message Walls ];   var pagenames = ['Special:WikiActivity', 'Special:Following']; var pathname = window.location.pathname.split('/'); // Returns /wiki/rest/of/path and splits it in "/" to work with them below

// Inserts the module if (mw.config.get('wgIsMainpage') !== true) { // Checks if it's not the homepage

// Inserts module above Recent Wiki Activity in most pages $('#WikiaRecentActivity').before(socialModule);

// Inserts it in different places in forum and blogs if (mw.config.get('wgPageName') !== 'Special:WikiActivity') { //Checks if it's not Wiki Activity if (mw.config.get('wgUserGroups').indexOf('user') > -1) { // If it's a registered user if ($('.ForumActivityModule').length) { // Checks if it's the forum $('.ChatModule').before(socialModule); // Inserts module above Chat }           } else { // If it's an anonymous user $('.ForumActivityModule').first.before(socialModule); // Inserts module above either Forum Activity or Related Threads $('.WikiaBlogListingBox').before(socialModule); // Inserts module above Popular blog posts }       }

// Inserts it above Chat in other pages if ((namespaces.indexOf(mw.config.get('wgNamespaceNumber')) > -1 && pathname[3] === 'undefined') || pagenames.indexOf(mw.config.get('wgPageName')) > -1 || pathname[2] === 'Special:Contributions') { // If it's Message Walls, WikiActivity, Following or Contributions $('.ChatModule').before(socialModule); // Inserts module above Chat }

}

/******************/   /* Discord widget */ /******************/

/*var discordWidget = '' + ' Live Chat ' + ' ' + ' ';

$('.ChatModule').before(discordWidget);*/

/*********************************************/   /* Moves Community, Trending Fandom Articles */ /* Insights and HotSpots below Chat         */ /*********************************************/

$('.ChatModule').after($('.community-page-entry-point-module, #RECIRCULATION_RAIL, .insights-module, .HotSpotsModule'));

/************************************************/   /* Adds option to refresh page to edit dropdown */ /************************************************/

var url = '//' + location.host + location.pathname + '?action=purge'; $('.WikiaMenuElement').append('Refresh</a></li>');

});

/******************************************************************************/ /*                             IMPORTED SCRIPTS                              */ /******************************************************************************/

//////////////////////////////////////////////////////////////////////////////// //                             CONFIGURATIONS                                // ////////////////////////////////////////////////////////////////////////////////

/*************/ /* User Tags */ /*************/

// Core configuration window.UserTagsJS = { modules: {}, tags: { bureaucrat: { u: 'Bureaucrat', link: 'Project:Administrators', order: -7 },       sysop: { u: 'Administrator', link: 'Project:Administrators', order: -6 },       threadmoderator: { link: 'Project:Discussions Moderators', order: -5 },       'content-moderator': { u: 'Content Moderator', link: 'Project:Content Moderators', order: -4 },       chatmoderator: { link:'Project:Chat Moderators', order: -3 },       rollback: { u: 'Rollbacker', link: 'Project:Rollbackers', order: -2 },       reporter: { u: 'Reporter', link: 'Project:Reporters', order: -1 },       bot: { u: 'Bot', link: 'Project:Bots' }

} };

// Adds users' MediaWiki groups to the internal group list UserTagsJS.modules.mwGroups = [ 'bureaucrat', 'sysop', 'threadmoderator', 'content-moderator', 'chatmoderator', 'rollback', 'bot' ];

// Custom ranks UserTagsJS.modules.custom = { 'Sim0n2170': ['reporter'], 'Manuel de la Fuente': ['reporter'], 'JinxTheFunhouse': ['reporter'] };

// Removes certain groups UserTagsJS.modules.metafilter = { 'sysop': ['bot'] // Removes admin tag from all bots };

// Marks users as inactive if they haven't edited in a month or more UserTagsJS.modules.inactive = 30;

/********************/ /* AutoEditDropdown */ /********************/

window.AutoEditDropdownConfig = { expandedAreaContribute: true, expandedAreaEdit: true };

/****************/ /* Auto Refresh */ /****************/

window.AjaxRCRefreshText = 'Auto-Refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page'; window.ajaxPages = [ 'Special:WikiActivity', 'Special:RecentChanges', 'Special:Log' ]; window.ajaxRefresh = 30000;

/************/ /* AjaxDiff */ /************/

window.AjaxDiff = { expiry: 'infinite', reason: 'Vandalism' };

//////////////////////////////////////////////////////////////////////////////// //                             LIST OF IMPORTS                               // ////////////////////////////////////////////////////////////////////////////////

importArticles({   type: 'script',    articles: [        'u:dev:UserTags/code.js', // User tags        'u:dev:AjaxRC/code.js', // Auto Refresh        'u:dev:AjaxDiff/code.js', // Allows to inspect diffs and stay in WikiActivity        'u:dev:ReferencePopups/code.js', // Displays content of references on hover        'u:dev:BackToTopButton/code.js', // Adds 'Back to top' button in pages        'u:dev:View_Source/code.js', // Adds 'view source' link to edit dropdown        'u:dev:RevealAnonIP/code.js', // Replaces 'a wikia contributor' with IP address        'u:dev:AutoEditDropdown/code.js', // Automatically opens edit menu on hover        'u:dev:Countdown/code.js' // Countdown (this script must always be the last one to load)    ] });