MediaWiki:Common.js

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

$(function {

"use strict";

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

/*******************/   /* Spoiler overlay */ /*******************/

// This script must always be the very first executed

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) { // If it's been less than one month since the last visit $('#spoiler-overlay').remove; // Removes the alert }   $('#show-spoilers').click(function  { // When clicking the button to remove spoilers    $('#spoiler-overlay').remove; // Removes the alert        localStorage.setItem("spoilerCache", thisVisit); // Saves the timestamp of this visit    });

// Adds button to rehide spoilers to the row of buttons if ($.inArray("Spoilers", mw.config.get('wgCategories')) > -1) { $('#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);

}

});

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

$(window).load(function {

'use strict';

/*****************/   /* Social module */ /*****************/

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

// Inserts the module if (mw.config.get('wgIsMainpage') !== true) { // Checks if it's not the homepage if ($('#TOP_RIGHT_BOXAD').length) { // Checks if there are ads $('#TOP_RIGHT_BOXAD').after(socialModule, $('#WikiaRecentActivity')); // Inserts module and Recent Wiki Activity (if there is) below ads } else if (mw.config.get('wgPageName') === 'Special:WikiActivity') { // If there are no ads, checks if it's Special:WikiActivity $('#WikiaRail').prepend(socialModule, $('.CommunityCornerModule')); // Inserts module and Community Corner at the top of the sidebar } else { // If there are no ads and it isn't Special:WikiActivity $('#WikiaRail').prepend(socialModule, $('#WikiaRecentActivity')); // Inserts modules at the top of the sidebar }   }

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

var url = '//' + location.host + location.pathname + '?action=purge'; $('#WikiaPage .wds-list, .WikiaMenuElement').append('Refresh');

});

/******************************************************************************/ /*                             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'], 'JinxTheFunhouse': ['reporter'], 'GodKingReiss': ['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)    ] });