MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ /* If you don't know what you are doing, do not edit this page */ /* */

// ********* // IRC Login // *********

$(function {	var nick = (wgUserName == null) ? ('Wikian' + Math.floor(Math.random * 10)) : wgUserName.replace(/ /g, '_'); 	$('#IRClogin').html(' '); });

// ************* // END IRC Login // *************

// ******************* // BEGIN Template:Game // *******************

// credit to Fallout wiki

function addTitleIcons { if (skin == 'monaco' || skin == 'monobook' || skin == 'oasis') { var insertTarget;

switch (skin) { case 'monobook': insertTarget = $('#firstHeading'); break; case 'monaco': insertTarget = $('#article > h1.firstHeading'); break; case 'oasis': if (wgAction != 'submit' && wgNamespaceNumber != 112) { insertTarget = $('#WikiaArticle'); }           break; }

if (insertTarget) { $('#gametemplate').css('display', 'block').prependTo(insertTarget); }  } }

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

// ***************** // END Template:Game // *****************

// ***************** // Collapsible stuff // *****************

/* */

var ShowHideConfig = { userLang: false, en: { show: "expand", hide: "hide", showAll: "expand all", hideAll: "hide all" } };

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

// ********************* // END Collapsible stuff // *********************

// *************** // Editing buttons // ***************

if (wgAction == "edit" || wgAction == "submit") {

/***** Custom edit buttons *****/ if (mwCustomEditButtons) {

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/central/images/4/4a/Button_welcome.png", "speedTip": "Welcome user", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/c/cd/Button_welcome_anon.png", "speedTip": "Welcome IP", "tagOpen": "", "tagClose": "", "sampleText": "THANKSFOR:"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/callofduty/images/5/5e/Button_welcome_141.png", "speedTip": "Welcome user (TF141)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/callofduty/images/8/8e/Button_welcome_letlev.png", "speedTip": "Welcome user (Letlev)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/callofduty/images/b/b6/Button_welcome_reznov.png", "speedTip": "Welcome user (Reznov)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/callofduty/images/3/34/Button_welcome_foley.png", "speedTip": "Welcome user (Foley)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/callofduty/images/6/60/Button_welcome_price.png", "speedTip": "Welcome user (Price)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/__cb20100809201046/callofduty/images/a/a5/Button_welcome_woods.png", "speedTip": "Welcome user (Woods)", "tagOpen": "", "tagClose": "", "sampleText": "YOURNAME"};

} }

// ******************* // END Editing buttons // *******************

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled.

function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = count=Math.floor((then.getTime-now.getTime)/1000);

// catch bad date strings if(isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ; return; }

// determine plus/minus if(diff<0) { diff = -diff; var tpm = 'T plus '; } else { var tpm = 'T minus '; }

// calcuate the diff var left = (diff%60) + ' seconds'; diff=Math.floor(diff/60); if(diff > 0) left = (diff%60) + ' minutes ' + left; diff=Math.floor(diff/60); if(diff > 0) left = (diff%24) + ' hours ' + left; diff=Math.floor(diff/24); if(diff > 0) left = diff + ' days ' + left timers[i].firstChild.nodeValue = tpm + left;

// a setInterval is more efficient, but calling setTimeout // makes errors break the script rather than infinitely recurse timeouts[i] = setTimeout('updatetimer(' + i + ')',1000); }

function checktimers { //hide 'nocountdown' and show 'countdown' var nocountdowns = getElementsByClassName(document, 'span', 'nocountdown'); for(var i in nocountdowns) nocountdowns[i].style.display = 'none' var countdowns = getElementsByClassName(document, 'span', 'countdown'); for(var i in countdowns) countdowns[i].style.display = 'inline'

//set up global objects timers and timeouts. timers = getElementsByClassName(document, 'span', 'countdowndate'); //global timeouts = new Array; // generic holder for the timeouts, global if(timers.length == 0) return; for(var i in timers) { timers[i].eventdate = new Date(timers[i].firstChild.nodeValue); updatetimer(i); //start it up  } } addOnloadHook(checktimers);

// ************************************************** // - end -  Experimental javascript countdown timer // **************************************************

// ************************************************* // Pagetitle rewrite // // Rewrites the page's title, used by Template:Title // by Sikon // ************************************************* function rewriteTitle { if(typeof(SKIP_TITLE_REWRITE) != 'undefined' && SKIP_TITLE_REWRITE) return; var titleDiv = document.getElementById('title-meta'); if(titleDiv == null || titleDiv == undefined) return; // For the title in the Monaco masthead if (skin == "monaco" && (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk")) { var mastheadUser = document.getElementById("user_masthead_head"); var mastheadSince = document.getElementById("user_masthead_since"); var titleString = ' ' + titleDiv.innerHTML; titleString += '' + mastheadSince.innerHTML; titleString += ' '; mastheadUser.innerHTML = titleString; } else { var cloneNode = titleDiv.cloneNode(true); var firstHeading = getElementsByClassName(document.getElementById('content'), 'h1', 'firstHeading')[0]; var node = firstHeading.childNodes[0]; // new, then old! firstHeading.replaceChild(cloneNode, node); cloneNode.style.display = "inline"; var titleAlign = document.getElementById('title-align'); firstHeading.style.textAlign = titleAlign.childNodes[0].nodeValue; } } addOnloadHook(rewriteTitle, false);

/* */

// ********************* // END Pagetitle rewrite // *********************

// **************** // Duplicate images // ****************

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

// ******************** // END Duplicate images // ********************

// ======================================================================= // Added SiteNotice Functionality, credit to RuneScape wiki for the code // // Functions: //  * Moves the dismiss link into the SiteNotice table. //  * Saves the show/hide status of the SiteNotice in a cookie. //  * Automatically expands the SiteNotice when the ID is updated. // ======================================================================= var dCookieName = "dismissSiteNotice="; var msgClose = "dismiss"; var hCookieName = "hideSiteNotice="; var hCookiePos = document.cookie.indexOf(hCookieName); var hCookieValue = ""; function editSiteNotice { var snbox = document.getElementById('mw-dismissable-notice'); if (snbox != null){ if (hCookiePos > -1) { hCookiePos = hCookiePos + hCookieName.length; var hideEndPos = document.cookie.indexOf(";", hCookiePos); if (hideEndPos > -1) { hCookieValue = document.cookie.substring(hCookiePos, hideEndPos); } else { hCookieValue = document.cookie.substring(hCookiePos); }       }        var newLink = document.createElement('a'); newLink.setAttribute('href', "javascript:dismissNotice;"); newLink.setAttribute('title', 'Dismiss this notice.'); newLink.innerHTML = msgClose; var newSpan = document.createElement('span'); newSpan.id = 'siteNoticeDismiss'; newSpan.appendChild(document.createTextNode(' [')); newSpan.appendChild(newLink); newSpan.appendChild(document.createTextNode(']')); var hideLink = document.getElementById( "collapseButton" + "0" ); hideLink.href = "javascript:hideSiteNotice;" hideLink.parentNode.style.width = "12em"; hideLink.parentNode.appendChild(newSpan); if (hCookieValue != siteNoticeID && hideLink.innerHTML == "show") { collapseTable(0); }       if (hCookieValue == siteNoticeID && hideLink.innerHTML == "hide") { collapseTable(0); }   } } function hideSiteNotice { var hideLink = document.getElementById( "collapseButton" + "0" ); var date = new Date; if (hideLink.innerHTML == 'hide'){ date.setTime(date.getTime + 30*86400*1000); } else { date.setTime(date.getTime - 30*86400*1000); }   document.cookie = hCookieName + siteNoticeID + "; expires="+date.toGMTString + "; path=/"; collapseTable(0); } addOnloadHook(editSiteNotice); // ================================================================== // End of Added SiteNotice Functionality // ==================================================================