MediaWiki:Common.js

/* Collapsible classes * See w:c:dev:ShowHide for info and attribution */

importScriptPage('ShowHide/code.js', 'dev');

/* Auto updating recent changes opt-in * See w:c:dev:AjaxRC for info & attribution */

AjaxRCRefreshText = 'Auto-refresh'; AjaxRCRefreshHoverText = 'Automatically refresh the page'; ajaxPages = ["Special:RecentChanges"]; importScriptPage('AjaxRC/code.js', 'dev');

/** Archive edit tab disabling ************************************* * Disables the edit tab on old forum topic pages to stop new people bumping old topics. * Page can still be edited by going via the edit tab on the history etc, or by * typing the edit address manually. * By Spang * Monaco support by Uberfuzzy * Oasis support by Uberfuzzy */ if(wgNamespaceNumber == 110) { function disableOldForumEdit { if( typeof( enableOldForumEdit ) != 'undefined' && enableOldForumEdit ) { return; }	if( !document.getElementById('old-forum-warning') ) { return; }	if( skin == 'oasis' ) {		$('#WikiaPageHeader .wikia-menu-button a:first').html('Archived').removeAttr('href'); return; }	if( !document.getElementById('ca-edit') ) { return; }	var editLink = null; if( skin == 'monaco' ) {		editLink = document.getElementById('ca-edit'); }	else if( skin == 'monobook' ) {		editLink = document.getElementById('ca-edit').firstChild; }	else {		return; }	editLink.removeAttribute('href', 0); editLink.removeAttribute('title', 0); editLink.style.color = 'gray'; editLink.innerHTML = 'Archived'; $('span.editsection-upper').remove; } addOnloadHook( disableOldForumEdit ); }

/* //////////////////////////////////////////////////////////////////// // THE BELOW CODE ADDS CUSTOM BUTTONS TO THE JAVASCRIPT EDIT TOOLBAR //////////////////////////////////////////////////////////////////// if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/youngjustice/images/5/57/CIT_Button.png", "speedTip": "Canon-In-Training", "tagOpen": "", "sampleText": "Insert text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/2/2f/TS_Button.png", "speedTip": "Timestamp", "tagOpen": "", "sampleText": "Place"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/c/ce/Ep_ref_Button.png", "speedTip": "Episode/issue reference tag", "tagOpen": " ", "sampleText": "number"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/youngjustice/images/2/24/AG_Button.png", "speedTip": "Ask Greg reference", "tagOpen": " ", "sampleText": "QID"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/marvel_dc/images/2/29/Character_Button.png", "speedTip": "Insert character template", "tagOpen": "\{\{Character\r| name       = ", "tagClose": "\r| image      = \r| real name   = \r| alias       = \r| age         = \r| species     = \r| designation = \r| gender      = \r| hair color  = \r| eye color   = \r| relatives   = \r| affiliation = \r| powers      = \r| weaknesses  = \r| equipment   = \r| first       = \r| voice       = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/marvel_dc/images/d/de/Film_Button.png", "speedTip": "Insert episode template", "tagOpen": "\{\{Episode\r| episode = ", "tagClose": "\r| image   = \r| airdate  = \r| director = \r| writer   = \r| prev     = \r| next     = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/marvel_dc/images/5/5d/Team_Button.png", "speedTip": "Insert organization template", "tagOpen": "\{\{Organization\r| name      = ", "tagClose": "\r| image     = \r| location   = \r| leader     = \r| goal       = \r| members    = \r| attributes = \r| first      = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/youngjustice/images/d/dc/Image_Button.png", "speedTip": "Insert filebox template", "tagOpen": "\{\{Filebox\r| description = ", "tagClose": "\r| season     = \r| episode     = \r| source      = \r| origin      = \r| license     = screenshot\r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/1/1d/Copyrights_needed_Button.png", "speedTip": "Uncredited image tag", "tagOpen": "\{\{subst:Unknown/ukn|", "tagClose": "}}", "sampleText": "both"}; }

/* Ability to change full page title * See w:c:dev:DISPLAYTITLE for info and attribution */

function fixPageName{ var newPageTitle = getElementsByClassName(document, 'span', 'changePageTitle')[0]; // Find the span with the new title if(newPageTitle == null) return; // If not found exit var oldPageTitle = getElementsByClassName(document, 'header', 'WikiaPageHeader')[0].getElementsByTagName( "h1" )[0]; //Find the page's title if(oldPageTitle == null) return; // If not found exit oldPageTitle.innerHTML = newPageTitle.innerHTML; // Set the title } addOnloadHook(fixPageName);

/* support for the Countdown template */ var oldTime = new Date; var timerID = null; var entry = 0; var target; var dst; var jan = new Date(oldTime.getFullYear, 0, 1); var jul = new Date(oldTime.getFullYear, 6, 1); var stdOffset = Math.max(jan.getTimezoneOffset, jul.getTimezoneOffset); if (oldTime.getTimezoneOffset < stdOffset) {    dst = 60; } else {    dst = 0; }

function Timecount { entry++; var basedate = oldTime; if (entry == 1) { if (document.getElementById('TimeLeftCounter') != null) { target = new Date(document.getElementById('TimeLeftCounter').innerHTML); }               else { return; }           }           var now = new Date; oldTime = now; var diff = new Date; var days = 0; var hours = 0; var minutes = 0; var seconds = 0; var daystring = ""; var hourstring = ""; var minutestring = ""; var secondstring = ""; diff.setTime(target.getTime - basedate.getTime); if (diff.getTime > new Date("January 1, 1970 00:00:00")) { days = Math.floor((diff.getTime-((now.getTimezoneOffset+dst)*60000)) / 86400000); hours = diff.getHours; minutes = diff.getMinutes; seconds = diff.getSeconds;

if (days != 0) { daystring = days.toString + "d, "; }

if (hours != 0) { hourstring = hours.toString + "h "; }                   else { if (days != 0) hourstring = hours.toString + "h "; }

if (minutes != 0) { minutestring = minutes.toString + "m "; }                   else { if ((hours != 0) || (days != 0)) minutestring = minutes.toString + "m "; }

secondstring = seconds.toString + "s";

document.getElementById("TimeLeftCounter").innerHTML = daystring + hourstring + minutestring + secondstring; timerID = self.setTimeout(Timecount, 1000); }               else { document.getElementById("TimeLeftCounter").innerHTML = "0s"; }           } addOnloadHook(Timecount);

/* Automatically fills the summary field in upload form with filebox * by: User:Xiao Qiao */ if ( wgCanonicalSpecialPageName == "Upload" ) { document.write(' '); } if ( wgCanonicalSpecialPageName == "MultipleUpload" ) { document.write(' '); }

/* Add "IRC" link to "On the Wiki" menu * From RuneScape Wiki, modified by: User:The 888th Avatar and User:Thailog */

$(document).ready(function {   if ( skin == 'oasis' && $.inArray("staff", wgUserGroups) == -1) {        $('.WikiHeaderRestyle nav ul li.marked ul').prepend('Chatroom');        $('.WikiHeaderRestyle nav ul li.marked ul').append('Ask Us');    } });

/** * LockOldBlogs * See w:c:dev:LockOldBlogs/code.js for info and attribution */ window.LockOldBlogs = { expiryCategories: ['Blog posts', 'Site news'] }; importArticle({   type: 'script',    article: 'w:c:dev:LockOldBlogs/code.js' });