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'; $('.page-header__contribution-buttons .wds-list, .WikiaMenuElement').append('Refresh');

});

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

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

/********************/ /* 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' };