MediaWiki:Common.js

/* */

/* ######################################################################## */ /* ### JavaScript here is loaded for all users and all skins. ### */ /* ######################################################################## */

/* ######################################################################## */ /* ### TITLE ICONS (Template:Games)                                    ### */ /* ### ### */ /* ### Description: Add icons to article title                          ### */ /* ### Credit:     User:Porter21                                       ### */ /* ######################################################################## */

function addTitleIcons { var iconBar = $('#va-titleicons'); var previewBar = $('#va-titleicons-preview');

if (skin != 'monobook' && skin != 'oasis' && skin != 'wikia') { return; }

if (iconBar.length > 0 && $('a', previewBar).length > 0) { if (skin == 'oasis' || skin == 'wikia') { var articleDiv = $('#WikiaArticle');

if (articleDiv.length > 0) { iconBar.css('display', 'block').prependTo(articleDiv); }     } else if (skin == 'monobook') { var firstHeading = $('#firstHeading').css('position', 'relative');

if (firstHeading.length > 0) { iconBar.css('display', 'block').appendTo(firstHeading.css('padding-right', previewBar.width + 25)); }     }

$('#va-titleicons-more').append('');

iconBar.hover(        function  {            $(this).addClass('va-titleicons-hover');         }, function  {            $(this).removeClass('va-titleicons-hover');         }); } }

/* ######################################################################## */ /* ### SHOW/HIDE                                                       ### */ /* ### ### */ /* ### Description: Collapsible tables using jQuery. Allows tables to  ### */ /* ###             be collapsed, showing only the header. ### */ /* ### Credit:     User:Dantman                                        ### */ /* ### Disclaimer: See http://dev.wikia.com/wiki/ShowHide/code.js      ### */ /* ######################################################################## */

var ShowHideConfig = { autoCollapse: 1, userLang: false }; importScriptPage( 'ShowHide/code.js', 'dev' );

/* ######################################################################## */ /* ### ARCHIVE TOOL                                                    ### */ /* ### ### */ /* ### Description: AJAX-archiving of talk pages via GUI                ### */ /* ### Credit:     User:Dantman (original)                             ### */ /* ###             User:Porter21 (Oasis & Monobook support)            ### */ /* ### Disclaimer: See http://dev.wikia.com/wiki/ArchiveTool/code.js   ### */ /* ######################################################################## */

function archiveTool { // Configuration var userconfig = (window.ArchiveToolConfig) ? window.ArchiveToolConfig : {}; var config = $.extend(true, {     archiveListTemplate: 'Archives',      archivePageTemplate: 'Archivepage',      archiveSubpage: 'Archive',      userLang: false,      // English      en: {         buttonArchiveTool: "Archive",         buttonArchiveToolTooltip: "Archive this page",         buttonSelectAll: "Select all",         buttonDeselectAll: "Deselect all",         buttonSaveArchive: "Save archive",         buttonAbort: "Abort",         labelLines: "Lines",         labelSections: "Sections",         summaryArchiveFrom: "ArchiveTool: Archiving from",         summaryArchiveTo: "ArchiveTool: Archiving to"      }   }, userconfig);

// Function for multi-language support function msg(name) { if ( config.userLang && wgUserLanguage in config && name in config[wgUserLanguage] ) return config[wgUserLanguage][name]; if ( wgContentLanguage in config && name in config[wgContentLanguage] ) return config[wgContentLanguage][name]; return config.en[name]; }  if (skin != "monaco" && skin != 'monobook' && skin != 'oasis' && skin != 'wikia') { return; }

if ((wgNamespaceNumber%2 != 0 && wgNamespaceNumber != 501) && (wgAction == "view" || wgAction == "purge")) { var skinConfig = { textCont: , pageControls: , controlsMarkup: '', buttonOpenPri: , buttonOpenSec: , buttonClose: '' };

switch(skin) { case 'monaco': skinConfig.textCont = '#bodyContent'; skinConfig.pageControls = '#page_controls'; skinConfig.controlsMarkup = '' + msg('buttonArchiveTool') + ''; skinConfig.buttonOpenPri = ''; skinConfig.buttonOpenSec = ''; skinConfig.buttonClose = ''; break; case 'monobook': skinConfig.textCont = '#bodyContent'; skinConfig.pageControls = '#p-cactions > div > ul'; skinConfig.controlsMarkup = '' + msg('buttonArchiveTool') + ''; skinConfig.buttonOpenPri = '';           break;         case 'oasis':         case 'wikia':            skinConfig.textCont = '#WikiaArticle';            skinConfig.pageControls = ($('#WikiaUserPagesHeader').length ? '.UserProfileActionButton' : '#WikiaPageHeader') + ' > .wikia-menu-button > ul';            skinConfig.controlsMarkup = '' + msg('buttonArchiveTool') + '</a></li>';            skinConfig.buttonOpenPri = '<a class="wikia-button">';            skinConfig.buttonOpenSec = '<a class="wikia-button secondary">';            skinConfig.buttonClose = '</a>';            break;      }

$(function {        function api(q, fn) {            q.format = 'json';            return $.post(wgScriptPath + '/api.php', q, fn, "json");         }         function token(page, fn) {            api({ action: 'query', query: 'prop', prop: 'info', titles: page, intoken: 'edit' }, function(q) { for ( var k in q.query.pages ) return fn(q.query.pages[k]); });        }         function startArchiving {            var c = config.archiveListTemplate.substr(0,1);            var archiveListRegex = '['+c.toUpperCase+c.toLowerCase+']'+config.archiveListTemplate.substr(1);            var bc = $(skinConfig.textCont).addClass('va-archiving').empty;

$('<img class="ajax" alt="Loading..." />') .attr({src: stylepath+'/common/progress-wheel.gif'}).appendTo(bc); api({              action: 'query',               prop: 'revisions',               titles: wgPageName,               rvprop: 'timestamp|content'            }, function(q) {               bc.empty;               var rev = q.query.pages[wgArticleId].revisions[0];               var time = rev.timestamp;               var talkToken, tokenTime;               var content = rev['*'];               token(wgPageName, function(p) { talkToken = p.edittoken; tokenTime = p.starttimestamp; });              var lines = content.split('\n');               var table = $(' ').appendTo(bc);               var ul = $(' ').appendTo(table);               for ( var l = 0; l < lines.length; l++ ) {                  var line = lines[l];                  $(' ').toggleClass('noarchive', (new RegExp('^\\{\\{'+archiveListRegex+'\}\}')).test(line))                     .attr({line:line})                     .append( $(' ').text(line).append(' ') ).appendTo(ul);               }               var sections = [];               var sectionEnd = lines.length-1;               for ( var l = lines.length-1; l >= 0; l-- ) {                  var line = lines[l];                  if ( /^=.+?=/.test(line) || l === 0 ) {                     var section = { start: l, end: sectionEnd };                     section.length = section.end - section.start + 1;                     sections.unshift(section); sectionEnd = l-1; }              }               var section; while( section = sections.shift ) { var tr = ul.children.eq(section.start); $(' ').attr({rowspan: section.length}).appendTo(tr); }              $(' ').append(                  $(skinConfig.buttonOpenSec + msg('buttonSelectAll') + skinConfig.buttonClose).click(function(e) { e.preventDefault; ul.children('tr').addClass('archive'); }), ' ',                 $(skinConfig.buttonOpenSec + msg('buttonDeselectAll') + skinConfig.buttonClose).click(function(e) { e.preventDefault; ul.children('tr').removeClass('archive'); }), ' ',                 $(skinConfig.buttonOpenPri + msg('buttonSaveArchive') + skinConfig.buttonClose).click(function(e) { archive; }), ' ',                 $(skinConfig.buttonOpenPri + msg('buttonAbort') + skinConfig.buttonClose).click(function(e) { bc.find('.ajax').remove; location = wgServer+wgScript+'?title='+encodeURI(wgPageName)+'&action=purge'; })              ).prependTo(bc).clone(true).appendTo(bc); var click = false; var add; table.mousedown(function(e) {                 e.preventDefault;                  var $li = $(e.target).closest('tr');                  if(!$li.length) return;                  var $section = $(e.target).closest('.section');                  if ( $section.length ) {                     var slist = $li.nextAll(':lt('+(parseInt($section.attr('rowspan'),10)-1)+')').andSelf;                     var sadd = slist.filter(function { return !$(this).hasClass('archive') }).length;                     slist.toggleClass('archive', !!sadd);                     return;                  }                  click = true;                  add = !$li.hasClass('archive');                  $li.toggleClass('archive', !!add);               }); table.mouseover(function(e) {                 if (!click) return;                  var $li = $(e.target).closest('tr');                  if(!$li.length) return;                  $li.toggleClass('archive', !!add);               }); $('body').mouseup(function(e) {                 click = false;               }); function archive { var talkLines = []; var archiveLines = []; ul.children.each(function {                    var arr = $(this).hasClass('noarchive') || !$(this).hasClass('archive')                        ? talkLines : archiveLines;                     arr.push( $(this).attr('line') );                  }); if ( !(new RegExp('^\\{\\{'+archiveListRegex+'\}\}')).test(talkLines[0]) ) talkLines = [, ].concat(talkLines); archiveLines = [, ].concat(archiveLines); bc.empty; $('<img class="ajax" alt="Loading..." />') .attr({src: stylepath+'/common/progress-wheel.gif'}).appendTo(bc); runArchive(talkLines.join('\n'), archiveLines.join('\n')); }              var archiveTitle; function runArchive(talkContent, archiveContent) { var archiveNo; function findArchives { var m = $(' Finding archive id: ').appendTo(bc); api({                       action: 'query',                        list: 'allpages',                        apnamespace: wgNamespaceNumber,                        apprefix: wgTitle+'/'+config.archiveSubpage,                        aplimit: 1,                        apdir: 'descending'                     }, function(q) {                        archiveNo = q.query.allpages.length ?                           parseInt(q.query.allpages[0].title.substr(wgPageName.length+("/"+config.archiveSubpage).length),10)+1 :                           1;                        archiveTitle = wgPageName+'/'+config.archiveSubpage+' '+archiveNo;                        m.append('done... (using '+archiveNo+')');                       saveArchive;                     }); }                 function saveArchive { var m = $(' Finding token for '+archiveTitle+': ').appendTo(bc); token(archiveTitle, function(p) {                       m.append('done...');                        m = $(' Saving archive page: ').appendTo(bc);                        api({ action: 'edit', title: archiveTitle, text: archiveContent, token: p.edittoken, summary: msg('summaryArchiveFrom') + " " + wgPageName + ".", minor: true, createonly: true }, function(q) { if ( q.error && q.error.code === "articleexists" ) { m.append('failed...'); bc.append(" The archive page we tried to create already exists. "); return abort; }                          m.append('done...'); saveTalk; });                    });                  }                  function saveTalk { var m = $(' Finding token for '+wgPageName+': ').appendTo(bc); m.append('done...'); m = $(' Updating talk page: ').appendTo(bc); api({                       action: 'edit',                        title: wgPageName,                        text: talkContent,                        token: talkToken,                        summary: msg('summaryArchiveTo') + " " + archiveTitle + ".",                        minor: true,                        basetimestamp: time,                        starttimestamp: tokenTime                     }, function(q) {                        if ( q.edit.result === "Success" ) {                           m.append('done...');                           bc.find('.ajax').remove;                           location = wgServer+wgScript+'?title='+encodeURI(wgPageName)+'&action=purge';                        } else {                           m.append('failed...');                           bc.append(" Failed to update talkpage, you may wish to have the archive subpage we just created deleted. ");                          return abort;                        }                     });                  }                  function abort {                     bc.find('.ajax').remove;                     bc.append(" Aborting... ");                     $(" You may want to ")                        .append( $('refresh</a>').attr({href: wgServer+wgArticlePath.replace('$1', encodeURI(wgPageName))}) )                        .append(' and try again.')                        .appendTo(bc);                  }                  // start                  findArchives;               }            });         }         $(skinConfig.controlsMarkup)            .click(startArchiving)            .appendTo(skinConfig.pageControls);      });   } }

/* ######################################################################## */ /* ### AJAX RC                                                         ### */ /* ### ### */ /* ### Description: Automatically refresh "Recent changes" via AJAX     ### */ /* ### Credit:     User:pcj (original)                                 ### */ /* ###             User:Grunny (bug fixes)                             ### */ /* ######################################################################## */

var ajaxIndicator = stylepath + '/common/progress-wheel.gif'; var ajaxPages = new Array("Special:RecentChanges", "Special:WikiActivity", "Fallout_Wiki:WikiActivity"); var ajaxTimer; var ajaxRefresh = 60000; var refreshText = 'Auto-refresh'; var refreshHover = 'Enable auto-refreshing page loads'; var doRefresh = true; var ajaxBC = ($('#WikiaArticle').length ) ? '#WikiaArticle' : '#bodyContent';

/** * Sets the cookie * @param c_name string Name of the cookie * @param value string 'on' or 'off' * @param expiredays integer Expiry time of the cookie in days */ function setCookie(c_name, value, expiredays) { var exdate = new Date; exdate.setDate(exdate.getDate + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toGMTString); }

/** * Gets the cookie * @param c_name string Cookie name * @return The cookie name or empty string */ function getCookie(c_name) { if (document.cookie.length > 0) { var c_start = document.cookie.indexOf(c_name + "="); if (c_start !== -1) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf(";", c_start); if (c_end === -1) { c_end = document.cookie.length; }        return unescape(document.cookie.substring(c_start, c_end)); }   }   return ""; }

/** * Main function to start the Auto-refresh process */ function preloadAJAXRL { var ajaxRLCookie = (getCookie("ajaxload-" + wgPageName) == "on") ? true : false; var appTo = ($('#WikiaPageHeader' ).length) ? $('#WikiaPageHeader > h1') : ($('#AdminDashboardHeader').length ? $('#AdminDashboardHeader > h1') : $('.firstHeading'));

appTo.append('&#160; <span style="border-bottom: 1px dotted; cursor: help;" id="ajaxToggleText" title="' + refreshHover + '">' + refreshText + ': <input type="checkbox" style="margin-bottom: 0;" id="ajaxToggle"> <img src="' + ajaxIndicator + '" style="float: none; vertical-align: baseline;" border="0" alt="Refreshing page" /> ');

$('#ajaxLoadProgress').ajaxSend(function(event, xhr, settings) {     if (location.href == settings.url) {         $(this).show;      }   } ).ajaxComplete(function(event, xhr, settings) {      if (location.href == settings.url) {         $(this).hide;

// Re-run certain functions if ($(ajaxBC + ' .mw-collapsible').length) { $(ajaxBC + ' .mw-collapsible').makeCollapsible; }        if (mw.config.get("wgNamespaceNumber") == -1             && mw.config.get("wgCanonicalSpecialPageName") == "Recentchanges") { mw.special.recentchanges.init; }     }   } );

$('#ajaxToggle').click(toggleAjaxReload).attr('checked', ajaxRLCookie);

if (getCookie("ajaxload-" + wgPageName) == "on") { loadPageData; } }

/** * Turn refresh on and off by toggling the checkbox */ function toggleAjaxReload { if ($('#ajaxToggle').prop('checked') === true) { setCookie("ajaxload-" + wgPageName, "on", 30); doRefresh = true; loadPageData; } else { setCookie("ajaxload-" + wgPageName, "off", 30); doRefresh = false; clearTimeout(ajaxTimer); } }

/** * Does the actual refresh */ function loadPageData { $(ajaxBC).load(location.href + " " + ajaxBC + " > *", function (data) {     if (doRefresh) {         ajaxTimer = setTimeout(loadPageData, ajaxRefresh);      }   }); }

/* ######################################################################## */ /* ### DISABLE ARCHIVE EDIT                                            ### */ /* ### ### */ /* ### Description: Remove section edit links and gray out main edit    ### */ /* ###             button on archived talk pages                       ### */ /* ### Credit:     User:Porter21                                       ### */ /* ######################################################################## */

function disableArchiveEdit { // Configuration var userconfig = (window.DisableArchiveEditConfig) ? window.DisableArchiveEditConfig : {}; var config = $.extend(true, {     archiveSubpage: 'Archive',      disableCompletely: false,      textColor: '#D9D9D9',      userLang: false,      // English      en: {         archived: "Archived",         archivedTooltip: "This page is an archive and should not be edited."      }   }, userconfig); // Function for multi-language support (by Daniel Friesen aka User:Dantman) function msg(name) { if ( config.userLang && wgUserLanguage in config && name in config[wgUserLanguage] ) return config[wgUserLanguage][name]; if ( wgContentLanguage in config && name in config[wgContentLanguage] ) return config[wgContentLanguage][name]; return config.en[name]; }  // Check whether page is an archive if ((new RegExp('\\/\[' + config.archiveSubpage.substr(0,1).toUpperCase     + config.archiveSubpage.substr(0,1).toLowerCase + '\]' + config.archiveSubpage.substr(1)      + '\\s\*\\d\*')).test(wgTitle)) { // Remove "add new section" links and prepare altering "edit" page control switch (skin) { case 'monaco': $('#control_addsection').remove; $('#fe_newsection').remove; editlink = $('#ca-edit'); break; case 'monobook': $('#ca-addsection').remove; editlink = $('#ca-edit > a'); break; case 'oasis': case 'wikia': var oasisButton = $(($('#WikiaUserPagesHeader').length ? '.UserProfileActionButton' : '#WikiaPageHeader') + ' > .wikia-menu-button'); oasisButton.children("a:first").prependTo($('ul:first', oasisButton)).wrap(' ').children('img').remove; oasisButton.prepend('<a />'); $('a[data-id="addtopic"]', oasisButton).parent.remove; editlink = $('a:first', oasisButton); break; }     // Remove "edit section" links $('span.editsection').remove; // Alter "edit" page control if (config.disableCompletely) { editlink.remove; } else { editlink.attr('title', msg('archivedTooltip')).css('color', config.textColor).text(msg('archived')); }  } } /* ######################################################################## */ /* ### COUNTDOWN                                                        ### */ /* ### ### */ /* ### Description: Adds countdown to specific date to a page. ### */ /* ###             (jQuery version of http://dev.wikia.com/Countdown)  ### */ /* ### Credit:     User:Splarka (original)                             ### */ /* ###             User:Porter21 (jQuery version)                      ### */ /* ######################################################################## */

// Usage example: // January 01 2020 00:00:00 PST

function updateCountdowns(targets, countdowns) { var now = new Date;

now = now.getTime;

countdowns.each(function(i) {     var diff = Math.floor((targets[i]-now)/1000);

// determine plus/minus if (diff < 0) { diff = -diff; }

// convert the difference into readable formatting var left = (diff%60) + ' seconds';

diff = Math.floor(diff/60); if (diff > 0) { left = (diff%60) + ' minute' + ((diff%60 == 1) ? ' ' : 's ') + left; }     diff = Math.floor(diff/60); if (diff > 0) { left = (diff%24) + ' hour' + ((diff%24 == 1) ? ' ' : 's ') + left; }     diff = Math.floor(diff/24); if (diff > 0) { left = diff + ' day' + (diff == 1 ? ' ' : 's ') + left; }

$(this).text(left); });

setTimeout(function { updateCountdowns(targets, countdowns); }, 1000); }

function addCountdowns { var targets = []; var countdowns = $('span.countdown').filter(function {     var content = $(this).text;      var converted = new Date(content);

if (content == "" || isNaN(converted)) { return false; } else { $(this).css("display", "inline"); targets[targets.length] = converted.getTime; return true; }  });

if (targets.length <= 0) { return; }

updateCountdowns(targets, countdowns); }

/* ######################################################################## */ /* ### DUPLICATE FILE LIST                                             ### */ /* ### ### */ /* ### Description: Finds duplicate files on the wiki. ### */ /* ### Credit:     User:pcj (http://www.wowpedia.org)                  ### */ /* ######################################################################## */

function findDupFiles(gf) { var fileDiv = $('#mw-dupfiles');

if (fileDiv.length) { dil = new Array; ajaxIndicator = stylepath + '/common/progress-wheel.gif'; output = ''; url = '/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=500&format=json';

if (!($('#dupFilesProgress').length)) { fileDiv.prepend(' <img src="' + ajaxIndicator + '" style="vertical-align: baseline;" border="0" alt="In progress..." /> '); }

if (gf) { url += "&gaifrom=" + gf; }

$.getJSON( url, function (data) {        if ( data.query ) {            pages = data.query.pages;

for (pageID in pages) { dils = "," + dil.join;

if ( dils.indexOf("," + pages[pageID].title) == -1                  && pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles ) { output += " <a href='/wiki/" + encodeURIComponent(pages[pageID].title).replace(/'/g, "%27") + "'>" + pages[pageID].title + "</a> \n<ul>\n";

for ( x = 0; x < pages[pageID].duplicatefiles.length; x++ ) { output += "<a href='/wiki/File:" + encodeURIComponent(pages[pageID].duplicatefiles[x].name).replace(/'/g, "%27") + "'>File:" + pages[pageID].duplicatefiles[x].name + "</a></li>\n"; dil.push("File:" + pages[pageID].duplicatefiles[x].name.replace(/_/g, " ")); }                 output += "</ul>\n\n" }           }

fileDiv.append(output);

if (data["query-continue"]) { setTimeout("findDupFiles('" + encodeURIComponent(data["query-continue"].allimages.gaifrom).replace(/'/g, "%27") + "');", 5000); } else { $('#dupFilesProgress').hide; }        }      } );   } }

/* ######################################################################## */ /* ### CHAT IMPROVEMENTS                                               ### */ /* ### ### */ /* ### Description: Improvements for Special:Chat                       ### */ /* ### Credit:     User:Porter21                                       ### */ /* ######################################################################## */

function openChatWindow { vaultChatWindow = window.open('/wiki/Special:Chat', 'wikiachat', 'width=600, height=600, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, toolbar=no'); return vaultChatWindow; }

function rewriteChatLink { $('#WikiHeader > nav > ul > li > ul.subnav > li > a[href="/wiki/Special:Chat"]').click(function(e){     e.preventDefault;      openChatWindow;      return false;   }); }

/* ######################################################################## */ /* ### JQUERY AJAX PATROL LINKS                                        ### */ /* ### ### */ /* ### Description: Mark pages as patrolled via AJAX                    ### */ /* ### Credit:     User:Grunny (http://dev.wikia.com)                  ### */ /* ######################################################################## */

function ajaxPatrolLinks { var ajaxIndicator = stylepath + '/common/progress-wheel.gif'; var patrolLinks = $('.patrollink');

if(!patrolLinks.length) { return; }

patrolLinks.click(function (e) {     var curLink = $(this);      var curURL = curLink.children('a').attr('href');

e.preventDefault; curLink.html('<img src="' + ajaxIndicator + '" style="vertical-align: baseline;" border="0" alt="Marking as patrolled..." />'); $.get(curURL, function (data) {        curLink.css('color', 'grey').text('[Marked as patrolled]');      }); }); }

/* ######################################################################## */ /* ### SCRIPT LOADER                                                   ### */ /* ### ### */ /* ### Description: Loads all the other scripts                         ### */ /* ### Credit:     User:Porter21                                       ### */ /* ######################################################################## */

function vaultScriptLoader { // Always loaded addCountdowns; rewriteChatLink; ajaxPatrolLinks;

// Only loaded for specific namespaces if ((wgNamespaceNumber == 0 || wgNamespaceNumber == 4 || wgNamespaceNumber == 110 || wgNamespaceNumber == 502) &&     !window.wgIsMainpage) { addTitleIcons; }

if (wgNamespaceNumber%2 != 0 && wgNamespaceNumber != 501) { archiveTool; disableArchiveEdit; }

// Only loaded for specific pages if (wgPageName == 'Fallout_Wiki:Duplicate_files') { findDupFiles; }

for (var x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) { preloadAJAXRL; }  } }

jQuery(function($) {  vaultScriptLoader; });

/* ######################################################################## */ /* ### IMAGE TOGGLER                                                   ### */ /* ### ### */ /* ### Description: Allows toggling of several images in infoboxes      ### */ /* ### Credit:     User:MarkvA                                         ### */ /* ######################################################################## */ $(document).ready(function { var infoboxHasImageToggler = $('table.va-infobox').hasClass('imagetoggler-enabled')

if(infoboxHasImageToggler == true) { var ImageToggler = {}; ImageToggler.count = 0; ImageToggler.images = []; function setupToggler { $('tr.va-infobox-row-mainimage').each(function(i) {			$(this).attr("id",'imagetoggler-'+i);			$(this).addClass("imagetoggler");			var currentToggler = $(this).closest("tr.va-infobox-row-mainimage").attr("id");		}); $('tr.va-infobox-row-mainimage .va-infobox-mainimage-image a').each(function(i) {			var currentToggler = $(this).closest("tr.va-infobox-row-mainimage").attr("id");			$(this).addClass('imagetoggler-image imagetoggler-image-'+i);			ImageToggler.images.push(currentToggler+'^'+$(this).attr('href'));			ImageToggler.count = ImageToggler.count + 1;		});

}	setupToggler; if(ImageToggler.count > 0) { $('.va-infobox-mainimage').prepend(' '); $('.imagetoggler').each(function(i) {		var currentToggler = $(this).attr("id");			$('#'+currentToggler + ' .imagetoggler-image').each(function(i) { if(i == 0) { $(this).css('display','inline'); }				else { $(this).css('display','none'); }			});		});		$(ImageToggler.images).each(function(i) {			var splitHref = ImageToggler.images[i].split('^');			var currentToggler = splitHref[0];			var currentHref = splitHref[1];

$('#' + currentToggler + ' .imagetoggler-thumbs').append('<img class="imagetoggler-thumb" src="'+currentHref+'" />'); $('#' + currentToggler + ' .imagetoggler-thumb-0').addClass('imagetoggler-active-thumb'); $('#' + currentToggler + ' .imagetoggler-thumb').css('width','auto'); $('#' + currentToggler + ' .imagetoggler-thumb').css('height','50px'); });		$('tr.va-infobox-row-mainimage').each(function(i) { $('.imagetoggler-thumb').each(function(i) {				$(this).addClass('imagetoggler-thumb-'+i);			}); });				$('.imagetoggler-thumb').on('click',function { var currentToggler = $(this).closest("tr").attr("id"); $('#' + currentToggler + ' .imagetoggler-thumb').removeClass('imagetoggler-active-thumb'); $(this).addClass('imagetoggler-active-thumb'); ImageToggler.activeclass = $(this).attr('class').split(' '); ImageToggler.activenumber = ImageToggler.activeclass[1].split('-');

$('#' + currentToggler + ' .imagetoggler-image').css('display','none'); $('#' + currentToggler + ' .imagetoggler-image-'+ImageToggler.activenumber[2]).css('display','inline'); });	} } });

/* ######################################################################## */ /* ### LANGUAGE DROP-DOWN MENU                                         ### */ /* ### ### */ /* ### Description: Adds a drop-down interlanguage button               ### */ /* ###             at the top of any page                              ### */ /* ### Credit:     User:JackiBackiBoy                                  ### */ /* ######################################################################## */ function appendLanguageDropdown { var borderColor = $('.WikiaPageHeader .comments').css('border-top-color'); var server = wgServer.replace("http://",""); var html = '<nav style="border: 1px solid '+borderColor+';" class="wikia-menu-button secondary combined chooselanguage"> <img style="margin-top: 3px; margin-left: 2px; margin-right: 4px;" class="chevron" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D"> <ul style="min-width: 42px; margin-top: 1px; border: 1px solid '+borderColor+'; border-top: none; text-align:center;" class="WikiaMenuElement" style="min-width:20px;"></ul> '; flags = {}; flags['en'] = '<img class="en-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/7/72/American_Flag.jpg/revision/latest?cb=20090205232650" alt="English">'; flags['de'] = '<img class="de-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/e/e6/Flag_of_Germany.png/revision/latest?cb=20120628095116" alt="German">'; flags['es'] = '<img class="es-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/9/9a/Flag_of_Spain.svg/revision/latest?cb=20150930201612" alt="Spanish">'; flags['ru'] = '<img class="ru-image" width="22" height="16" src="http://vignette2.wikia.nocookie.net/fallout/images/a/a5/Russia_Flag.svg/revision/latest?cb=20110323200500" alt="Russian">'; flags['pl'] = '<img class="pl-image" width="22" height="16" src="http://vignette2.wikia.nocookie.net/fallout/images/1/12/Flag_of_Poland.svg/revision/latest?cb=20170604205736" alt="Polish">'; flags['fr'] = '<img class="fr-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/5/57/France_Flag.png/revision/latest?cb=20091012172700" alt="French">'; flags['it'] = '<img class="it-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/b/b3/Flag_of_Italy.png/revision/latest?cb=20141130032211" alt="Italian">'; flags['pt'] = '<img class="pt-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/5/5c/Flag_of_Portugal.svg/revision/latest?cb=20170604210553" alt="Portuguese">'; flags['bg'] = '<img class="bg-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/9/9a/Flag_of_Bulgaria.svg/revision/latest?cb=20170604210840" alt="Bulgarian">'; flags['fa'] = '<img class="fa-image" width="22" height="16" src="http://vignette4.wikia.nocookie.net/fallout/images/c/ca/Flag_of_Iran.svg/revision/latest?cb=20170604211205" alt="Persian">'; flags['fi'] = '<img class="fi-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/a/af/Flag_of_Finland_svg.png/revision/latest?cb=20120820193045" alt="Finnish">'; flags['hu'] = '<img class="hu-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/3/3e/Flag_of_Hungary.jpg/revision/latest?cb=20170605080722" alt="Hungarian">'; flags['ja'] = '<img class="ja-image" width="22" height="16" src="http://vignette2.wikia.nocookie.net/fallout/images/3/37/Japan_Flag.png/revision/latest?cb=20090206000355" alt="Japanese">'; flags['ka'] = '<img class="ka-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/0/0f/Flag_of_Georgia.svg/revision/latest?cb=20170605081530" alt="Georgian">'; flags['ko'] = '<img class="ko-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/0/09/Flag_of_South_Korea.svg/revision/latest?cb=20170605081256" alt="Korean">'; flags['lv'] = '<img class="lv-image" width="22" height="16" src="http://vignette1.wikia.nocookie.net/fallout/images/1/11/Flag_of_Lithuania.svg/revision/latest?cb=20170605081824" alt="Lithuanian">'; flags['nl'] = '<img class="nl-image" width="22" height="16" src="http://vignette2.wikia.nocookie.net/fallout/images/d/d9/Flag_of_Netherlands.png/revision/latest?cb=20170605082506" alt="Dutch">'; flags['no'] = '<img class="no-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/f/f1/Flag_of_Norway.png/revision/latest?cb=20170605083313" alt="Norweigan">'; flags['sv'] = '<img class="sv-image" width="22" height="16" src="http://vignette2.wikia.nocookie.net/fallout/images/4/4c/Flag_of_Sweden.svg/revision/latest?cb=20170605083452" alt="Swedish">'; flags['tr'] = '<img class="tr-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/b/b4/Flag_of_Turkey.svg/revision/latest?cb=20170605083719" alt="Turkish">'; flags['zh'] = '<img class="zh-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/f/fa/Flag_of_the_People%27s_Republic_of_China.svg/revision/latest?cb=20081109202021" alt="Chinese">'; flags['uk'] = '<img class="uk-image" width="22" height="16" src="http://vignette3.wikia.nocookie.net/fallout/images/b/b9/Ukraine_Flag.svg/revision/latest?cb=20091012084658" alt="Ukrainian">'; $('.WikiaPageHeader .comments').after(html); languages = {}; $('.WikiaArticleInterlang ul li a').each(function {		var languageFull = $(this).text;		var href = $(this).attr('href');		var pageNameArray = href.split('/')		var pageName = pageNameArray[pageNameArray.length - 1];		switch (languageFull) {			case "English":				languages['en'] = href;				break;			case "Deutsch":				languages['de'] = href;				break;			case "Español":				languages['es'] = href;				break;			case "Русский":				languages['ru'] = href;				break;			case "Polski":				languages['pl'] = href;				break;			case "Français":				languages['fr'] = href;				break;			case "Italiano":				languages['it'] = href;				break;			case "Português":				languages['pt'] = href;				break;			case "Български":				languages['bg'] = href;				break;			case "فارسی":				languages['fa'] = href;				break;			case "Suomi":				languages['fi'] = href;				break;			case "Magyar":				languages['hu'] = href;				break; case "日本語": languages['ja'] = href; break; case "ქართული": languages['ka'] = href; break; case "한국어": languages['ko'] = href; break; case "Lietuvių": languages['lt'] = href; break; case "Nederlands": languages['nl'] = href; break; case "Norsk (bokmål)‬": languages['no'] = href; break; case "Svenska": languages['sv'] = href; break; case "Türkçe": languages['tr'] = href; break; case "中文": languages['zh'] = href; break; case "Українська": languages['uk'] = href; break; }	});	var language = wgContentLanguage;	$.each(flags, function (key, value) { if (key === language) { $('.WikiaPageHeader .chooselanguage').prepend(flags[key]); } 		else { if (languages[key]) { $('.WikiaPageHeader .chooselanguage ul').append('<a style="display: inline; padding: 0; height: 0; line-height: 0;" class="'+ key +'-link" href="' + languages[key] + '">' + flags[key] + '</li></a>'); }		}	});	$('.WikiaPageHeader .chooselanguage').on('click', function { if ($(this).hasClass('active') === false) { $(this).addClass('active'); } 		else { $(this).removeClass('active'); }	});	$('.WikiaPageHeader .chooselanguage').on('mouseleave', function { var that = this; var timeOut = setTimeout(function { $(that).removeClass('active'); }, 500); $('.chooselanguage').on('mouseenter', function {			clearTimeout(timeOut);		}); }); } if( $('.WikiaArticleInterlang').length > 0 ) {	addOnloadHook(appendLanguageDropdown); }

/* ######################################################################## */ /* ### COUNTDOWN TIMER                                                 ### */ /* ### ### */ /* ### Description: Adds a modifiable countdown timer to any page       ### */ /* ### Credit:     User:Sammylau                                       ### */ /* ######################################################################## */ importArticles({   type: "script",    articles: [        "w:c:dev:Countdown/code.js",        "w:c:dev:ReferencePopups/code.js"    ] });

/* */

/* ############################################################################ */ /* ### EDITHELP                                                            ### */ /* ### ### */ /* ### Description: Displays documentation about templates within the       ### */ /* ###             classic editor                                          ### */ /* ### Credit:     User:Mazn                                               ### */ /* ### Disclaimer: See http://fallout.wikia.com/wiki/MediaWiki:EditHelp.js ### */ /* ############################################################################ */ if ( /[?&]action=edit/.test( window.location.search ) ) { $.getScript('/load.php?mode=articles&only=scripts&articles=MediaWiki:EditHelp.js'); }

/* ############################################################################ */ /* ### Replaces with the name of the user browsing the page. ### */ /* ### Requires copying Template:USERNAME. ### */ /* ### Copied from templates.wikia.com                                     ### */ /* ############################################################################ */ $(function {   if (window.disableUsernameReplace || mw.config.get('wgUserName') === null) { return; }    $('span.insertusername').html(mw.config.get('wgUserName')); });

/* Ticker */ var $ticker = $('#ticker'), $ticker_div = $('#tickerdiv'), $ticker_text = $('#tickertxt'), ticker_text_outer_width, ticker_interval;

function createTicker { if ($ticker.length && $ticker_div.length && $ticker_text.length) { $ticker.css('display', 'block'); ticker_text_outer_width = $ticker_text.outerWidth; $ticker_div.css('left', parseInt($ticker.width) + 10 + 'px'); ticker_interval = setInterval("processTicker", 200); } }

function processTicker { var left_width = (parseInt($ticker_div.position.left) > (-10 - ticker_text_outer_width)) ? parseInt($ticker_div.position.left) - 10 + 'px' : parseInt($ticker.width) + 10 + 'px'; $ticker_div.css('left', left_width); }

createTicker;