MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ /* */

/*** Cookie accessor functions ***/ function setCookie(name, value, expires) { var d = new Date; d.setDate(d.getDate + expires); document.cookie = name + '=' + escape(value) + ';path=/'; } function getCookie(name) { if (document.cookie.length > 0) { var start = document.cookie.indexOf(name + '='); if (start != -1) { start = start + name.length + 1; var end = document.cookie.indexOf(';', start); if (end == -1) { end = document.cookie.length; }			return unescape(document.cookie.substring(start, end)); } 	}	return ''; }

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

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

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT ",        "tagClose": "", "sampleText": "Insert text"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/central/images/4/4a/Button_table.png", "speedTip": "Insert a table", "tagOpen": '{| class="wikitable"\n|-\n', "tagClose": "\n|}", "sampleText": "! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": " ", "tagClose": "", "sampleText": ""};

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/1/12/Button_gallery.png", "speedTip": "Insert a picture gallery", "tagOpen": '\n ",         "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"};    } }

// ============================================================ // EDIT-INTRO FIX for Exchange articles // // This script is modified from English Wikipedia // Source: http://en.wikipedia.org/wiki/User:RockMFR/disambigeditintro.js // Function: Adds EditIntro to all Exchange pages //          when "edit this page" link is clicked // ============================================================

$(document).ready(function {	if (wgCanonicalNamespace == "Exchange") {		$editLinks = $('a#ca-edit,#ca-edit a');		$editLinks.attr('href', $editLinks.attr('href') + '&editintro=Template:ExchangeItemHelp');	} });

// ============================================================ // End of EDIT-INTRO FIX // ============================================================

// ============================================================ // BEGIN Dynamic Navigation Bars (experimantal) // This script is from Wikipedia. For author attribution, please see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history // ============================================================

/* Test if an element has a certain class ************************************** * * Description: Uses regular expressions and caching for better performance. * Maintainers: User:Mike Dillon, User:R. Koot, User:SG */

var hasClass = (function {    var reCache = {};    return function (element, className) {        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; });

// ===================================================================== // Collapsible Tables // // Description: Allows tables to be collapsed, showing only the header. // Reference:  Wikipedia:Wikipedia:NavFrame //             Wikipedia:Help:Collapsing // Maintainers: Wikipedia:User:R. Koot // // =====================================================================   var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; var maxHeight = 300; function collapseTable(tableIndex) { var Button = document.getElementById("collapseButton" + tableIndex); var Table = document.getElementById("collapsibleTable" + tableIndex); if (!Table || !Button) return false; var Rows = Table.getElementsByTagName("tr"); if (Button.firstChild.data == collapseCaption) { for (var i = 1; i < Rows.length; i++) { Rows[i].style.display = "none"; }           Button.firstChild.data = expandCaption; } else { for (var i = 1; i < Rows.length; i++) { Rows[i].style.display = Rows[0].style.display; }         Button.firstChild.data = collapseCaption; }   }    function createCollapseButtons { var tableIndex = 0; var navBoxes = new Object; var Tables = document.getElementsByTagName("table"); for (var i = 0; i < Tables.length; i++) { if (hasClass(Tables[i], "collapsible")) { /* Only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName("tr")[0]; if (!HeaderRow) continue;

var Header = HeaderRow.getElementsByTagName("th")[0]; if (!Header) continue;

navBoxes[tableIndex] = Tables[i]; Tables[i].setAttribute("id", "collapsibleTable" + tableIndex); var Button    = document.createElement("span"); var ButtonLink = document.createElement("a"); var ButtonText = document.createTextNode(collapseCaption); Button.style.styleFloat = "right"; Button.style.cssFloat = "right"; Button.style.fontSize = "90%"; Button.style.fontWeight = "normal"; Button.style.textAlign = "right"; Button.style.width = "6em"; ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute("id", "collapseButton" + tableIndex); ButtonLink.setAttribute("href", "javascript:collapseTable(" + tableIndex + ");"); ButtonLink.appendChild(ButtonText); Button.appendChild(document.createTextNode("[")); Button.appendChild(ButtonLink); Button.appendChild(document.createTextNode("]")); Header.insertBefore(Button, Header.childNodes[0]); tableIndex++; }       }        var j = 0; for (var i = 0; i < tableIndex; i++) { if (hasClass(navBoxes[i], "navbox") && hasClass(navBoxes[i], "collapsible") && hasClass(navBoxes[i], "autocollapse")) j++;

var h = 0; if (hasClass(navBoxes[i], "navbox") && hasClass(navBoxes[i], "collapsible")) h = navBoxes[i].clientHeight; if(h == null || h == undefined) h = 0;

// Does not collapse if: //  Contains "uncollapsed" // Collapses if: //  1. Contains "collapsed" //  2. If j>autoCollapse, and contains "navbox collapsible autocollapse" //  3. If table height > maxHeight, and contains "navbox collapsible" //  4. If there are "innercollapse" tables in "outercollapse" tables if (!hasClass(navBoxes[i], "uncollapsed")) { if (hasClass(navBoxes[i], "collapsed") || (j > autoCollapse) || (h > maxHeight)) { collapseTable(i); }               else if (hasClass(navBoxes[i], "innercollapse")) { var element = navBoxes[i]; while (element = element.parentNode) { if (hasClass(element, "outercollapse")) { collapseTable(i); break; }                   }                }            }        }    }

addOnloadHook(createCollapseButtons);

// ===================================================================== // End of Collapsible Tables // =====================================================================

/** Dynamic Navigation Bars (experimental) ************************************* * *  Description: See NavFrame. * Maintainers: UNMAINTAINED */ // set up the words in your language var NavigationBarHide = '[' + collapseCaption + ']'; var NavigationBarShow = '[' + expandCaption + ']'; // set up max count of Navigation Bars on page, // if there are more, all will be hidden // NavigationBarShowDefault = 0; // all bars will be hidden // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden var NavigationBarShowDefault = autoCollapse; // shows and hides content and picture (if available) of navigation bars // Parameters: //    indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) {    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; }    // if shown now if (NavToggle.firstChild.data == NavigationBarHide) { for (                var NavChild = NavFrame.firstChild;                 NavChild != null;                 NavChild = NavChild.nextSibling             ) { if ( hasClass( NavChild, 'NavPic' ) ) { NavChild.style.display = 'none'; }            if ( hasClass( NavChild, 'NavContent') ) { NavChild.style.display = 'none'; }        }     NavToggle.firstChild.data = NavigationBarShow; // if hidden now } else if (NavToggle.firstChild.data == NavigationBarShow) { for (                var NavChild = NavFrame.firstChild;                 NavChild != null;                 NavChild = NavChild.nextSibling             ) { if (hasClass(NavChild, 'NavPic')) { NavChild.style.display = 'block'; }            if (hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'block'; }        }     NavToggle.firstChild.data = NavigationBarHide; } }  // adds show/hide-button to navigation bars function createNavigationBarToggleButton {    var indexNavigationBar = 0; // iterate over all -elements var divs = document.getElementsByTagName("div"); for(            var i=0;              NavFrame = divs[i];              i++         ) { // if found a navigation bar if (hasClass(NavFrame, "NavFrame")) { indexNavigationBar++; var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); NavToggle.appendChild(NavToggleText); // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) for(              var j=0;                j < NavFrame.childNodes.length;                j++             ) { if (hasClass(NavFrame.childNodes[j], "NavHead")) { NavFrame.childNodes[j].appendChild(NavToggle); }            }             NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); }    }     // if more Navigation Bars found than Default: hide all if (NavigationBarShowDefault < indexNavigationBar) { for(                var i=1;                  i<=indexNavigationBar;                  i++         ) { toggleNavigationBar(i); }    }  }

addOnloadHook( createNavigationBarToggleButton );

function getElementsByClassName(oElm, strTagName, oClassNames){ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array; var arrRegExpClassNames = new Array; if(typeof oClassNames == "object"){ for(var i=0; i<oClassNames.length; i++){ arrRegExpClassNames[arrRegExpClassNames.length] = new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"); }	}	else{ arrRegExpClassNames[arrRegExpClassNames.length] = new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"); }	var oElement; var bMatchesAll; for(var j=0; j<arrElements.length; j++){ oElement = arrElements[j]; bMatchesAll = true; for(var k=0; k" + items[ti].innerHTML; } } addOnloadHook( createCheckboxes ); // ============================================================

// ===================================================================== // 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 = getElementsByClass('firstHeading', document.getElementById('content'), 'h1')[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);

/* Preloaded stuff */

importScript('MediaWiki:Functions.js');

// onload stuff var firstRun = true;

function loadFunc {   if(firstRun) firstRun = false; else return;

initFunctionsJS;

// DEPRECATED if(document.getElementById('infoboxinternal') != null && document.getElementById('infoboxend') != null) {       document.getElementById('infoboxend').innerHTML = '[Hide]'; }

addHideButtons;

if(document.getElementById('mp3-navlink') != null) {       document.getElementById('mp3-navlink').onclick = onArticleNavClick; document.getElementById('mp3-navlink').getElementsByTagName('a')[0].href = 'javascript:void(0)'; }

if(window.storagePresent) initVisibility;

fillEditSummaries;

var body = document.getElementsByTagName('body')[0]; var bodyClass = body.className;

if(!bodyClass || (bodyClass.indexOf('page-') == -1)) {       var page = window.pageName.replace(/\W/g, '_'); body.className += ' page-' + page; }

if(typeof(onPageLoad) != "undefined") {       onPageLoad; } }

function fillEditSummaries {   var label = document.getElementById("wpSummaryLabel");

if(label == null) return;

var comboString = "Summaries: "; comboString += " "; label.innerHTML = comboString + label.innerHTML;

requestComboFill('stdSummaries', 'Template:Stdsummaries'); }

function onStdSummaryChange {   var combo = document.getElementById("stdSummaries"); var value = combo.options[combo.selectedIndex].value;

if(value != "") {       if(skin == 'monaco') { document.getElementById("wpSummaryEnhanced").value = value; } else { document.getElementById("wpSummary").value = value; } } }

function onStdReasonChange {   var combo = document.getElementById("stdReasons"); var value = combo.options[combo.selectedIndex].value;

if(value != "") document.getElementById("wpReason").value = value; }

function initVisibility {   var storage = globalStorage[window.location.hostname];

var page = window.pageName.replace(/\W/g,'_'); var show = storage.getItem('infoboxshow-' + page);

if(show == 'false') {       infoboxToggle; }   var hidables = getElementsByClass('hidable'); for(var i = 0; i < hidables.length; i++) {       show = storage.getItem('hidableshow-' + i  + '_' + page); if(show == 'false') {           var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]); if(content != null && content.length > 0 &&               button != null && button.length > 0 && content[0].style.display != 'none') {               button[0].onclick('bypass'); }       }        else if(show == 'true') {           var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]); if(content != null && content.length > 0 &&               button != null && button.length > 0 && content[0].style.display == 'none') {               button[0].onclick('bypass'); }       }    } }

function addHideButtons {   var hidables = getElementsByClass('hidable'); for(var i = 0; i < hidables.length; i++) {       var box = hidables[i]; var button = getElementsByClass('hidable-button', box, 'span'); if(button != null && button.length > 0) {           button = button[0]; button.onclick = toggleHidable; button.appendChild(document.createTextNode('[Hide]'));

if(new ClassTester('start-hidden').isMatch(box)) button.onclick('bypass'); }   } }

function toggleHidable(bypassStorage) {   var parent = getParentByClass('hidable', this); var content = getElementsByClass('hidable-content', parent); var nowShown; if(content != null && content.length > 0) {       content = content[0]; if(content.style.display == 'none') {           content.style.display = content.oldDisplayStyle; this.firstChild.nodeValue = '[Hide]'; nowShown = true; }       else {           content.oldDisplayStyle = content.style.display; content.style.display = 'none'; this.firstChild.nodeValue = '[Show]'; nowShown = false; }       if(window.storagePresent && (typeof(bypassStorage) == 'undefined' || bypassStorage != 'bypass')) {           var page = window.pageName.replace(/\W/g, '_'); var items = getElementsByClass('hidable'); var item = -1; for(var i = 0; i < items.length; i++) {               if(items[i] == parent) {                   item = i;                    break; }           }            if(item == -1) {               return; }           var storage = globalStorage[window.location.hostname]; storage.setItem('hidableshow-' + item + '_' + page, nowShown); }   } }

//addOnloadHook(loadFunc);

$(document).ready(loadFunc);

// addOnloadHook(fillPreloads);

// ============================================================ // Collapsible sidebar portlets // Source: http://www.wikia.com/wiki/User:Splarka/tricks // ============================================================

function foldingPortlets { var portlets = getElementsByClassName(document.getElementById('column-one'), 'div', 'portlet'); var portskip = ['p-personal', 'p-cactions', 'p-logo', 'ads-top-left', 'p-search', 'p-tbx', 'p-wikicities-nav', 'p-lang']; var num = 0;

for (var i = 0; i < portlets.length; i++) { if (portskip.join(' ').indexOf(portlets[i].id) == -1) { var pd = portlets[i].getElementsByTagName('div')[0]; var ph = portlets[i].getElementsByTagName('h5')[0];

ph.className = 'portletCollapsible'; pd.setAttribute('id', 'pbody-' + i); pd.style.display = 'none';

var link = document.createElement('a'); var head = getAllText(ph);

while (ph.firstChild) { ph.removeChild(ph.firstChild); }

link.appendChild(document.createTextNode(head)); link.setAttribute('href', 'javascript:showPortlet(\'' + i + '\');'); link.setAttribute('id', 'plink-'+i); link.className = 'portletClosed'; ph.appendChild(link);

if (num++ < 3) { showPortlet(i); }       }    } }

if (skin == 'monobook' && !window.portletsNormal) { addOnloadHook(foldingPortlets); }

function getAllText(thing) { if (thing.nodeType == 3) { return thing.nodeValue; }

var text = new Array; var i = 0;

while (thing.childNodes[i]) { text[text.length] = getAllText(thing.childNodes[i]); i++; }

return text.join(''); }

function showPortlet(id) { var pd = document.getElementById('pbody-' + id); var pl = document.getElementById('plink-' + id);

if (pd.style.display == 'none') { pd.style.display = 'block'; pl.className = 'portletOpened'; } else { pd.style.display = 'none'; pl.className = 'portletClosed'; } }

// ============================================================ // End of Collapsible sidebar portlets // ============================================================

//////////////////////////////////////////////////////////////// // ADVANCED AJAX AUTO-REFRESHING ARTICLES // Code courtesy of "pcj" of WoWWiki. ////////////////////////////////////////////////////////////////

ajaxPages = new Array("Special:RecentChanges", "Special:Watchlist", "Special:Log", "Special:Contributions", "Forum:Yew_Grove");

function getXmlHttpRequestObject { if (window.XMLHttpRequest) { return new XMLHttpRequest; //Not Internet Explorer } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer } else { //fail silently } } getRCDataRO = getXmlHttpRequestObject; var cr = new RegExp("\r", "gm"); var lf = new RegExp("\n", "gm"); var endText = new RegExp(' [\t\s]*?[\t\s]*? ', "mi"); var rcTimer; var rcRefresh = 60000; function preloadAJAXRC { if (skin == "monaco") { s = 1; } else { s = 0; } ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; document.getElementsByTagName("h1")[0].innerHTML += ' Auto-refresh '; document.getElementById("ajaxRCtoggle").checked = ajaxRCCookie; if (getCookie("ajaxload-"+wgPageName)=="on") loadRCData; }

function toggleRC { if (document.getElementById("ajaxRCtoggle").checked == true) { setCookie("ajaxload-"+wgPageName, "on", 30); loadRCData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); clearTimeout(rcTimer); } }

function loadRCData { if (getRCDataRO.readyState == 4 || getRCDataRO.readyState == 0) { if (location.href.indexOf("/wiki/")) { rcURL = "http://" + location.hostname + "/wiki/" + wgPageName + location.search; } else { rcURL = "http://" + location.hostname + "/" + wgPageName + location.search; } getRCDataRO.open("GET", rcURL, true); getRCDataRO.onreadystatechange = parseRCdata; getRCDataRO.send(null); } }

function parseRCdata { if (getRCDataRO.readyState == 4) { textFilter = new RegExp(' .*? [\t\s]*?[\t\s]*? ', "i"); rawRCdata = getRCDataRO.responseText.replace(cr, "").replace(lf, ""); filteredRCdata = textFilter.exec(rawRCdata); updatedText = filteredRCdata[0].replace(' ', "").replace(endText, ""); document.getElementById("bodyContent").innerHTML = updatedText; rcTimer = setTimeout("loadRCData;", rcRefresh); } }

$(document).ready(function {	for (x in ajaxPages) {		if (wgPageName == ajaxPages[x] && wgAction == "view" && (typeof(window.enableAjaxRC) == 'undefined' || window.enableAjaxRC)) preloadAJAXRC;	} });

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// END OF AJAX AUTO-REFRESH

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled. // // If the date is in the format "x|January 01 2007 00:00:00 PST", then the timer is periodic with period x seconds using the given date as the starting time. function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = Math.floor((then.getTime-now.getTime)/1000); // catch bad date strings if(isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ; return; } // reduce modulo period if necessary if(timers[i].period > 0){ if(diff<0) diff = timers[i].period - ((-diff)%timers[i].period); else diff = diff%timers[i].period; } // 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'); timeouts = new Array; // generic holder for the timeouts, global if(timers.length == 0) return; for(var i in timers) { var str = timers[i].firstChild.nodeValue; var j = str.indexOf('|'); if(j == -1) timers[i].period = 0; else { timers[i].period = parseInt(str.substr(0, j)); if(isNaN(timers[i].period) || timers[i].period < 0) timers[i].period = 0; str = str.substr(j + 1); }   timers[i].eventdate = new Date(str); updatetimer(i); //start it up  } } addOnloadHook(checktimers);

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

// ============================================================ // Experimental EMBEDDING hack for multimedia files // // Used in: Template:Listen // Function: Embeds a file based if the DIV class is "embedMe" //          The "src" is located in the DIV id. // ============================================================

function embedMe { var allDivs = document.getElementsByTagName("div");

for (var i=0; i"; allDivs[i].innerHTML = embedString; }   } } addOnloadHook(embedMe);

// ============================================================ // End of Experimental EMBEDDING hack // ============================================================

// ============================================================ // wikiSiteMeter // // Function: Adds a counter from http://www.sitemeter.com/ // ============================================================

function wikiSiteMeter { if(skin == "monobook") { var sidebar = document.getElementById("p-wikicities-nav");

if(sidebar == null) return;

var comboString = " wiki site meter "; comboString += "  ";

sidebar.innerHTML += comboString; }

if(skin == "monaco") { var sidebar = document.getElementById("widget_101");

if(sidebar == null) return;

var comboString = " Wiki Site Meter"; comboString += " ";

sidebar.innerHTML += comboString; } } addOnloadHook(wikiSiteMeter);

// ============================================================ // End of wikiSiteMeter // ============================================================

// ================================================================== // Added SiteNotice Functionality // // 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 hideLink = document.getElementById( "collapseButton" + "0" ); hideLink.href = "javascript:hideSiteNotice;" hideLink.parentNode.style.width = "12em"; hideLink.parentNode.appendChild(document.createTextNode(' [')); hideLink.parentNode.appendChild(newLink); hideLink.parentNode.appendChild(document.createTextNode(']')); snbox.tBodies[0].rows[0].deleteCell(1);

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 // ==================================================================

// ================================================================== // Item Compare Overlays // ================================================================== $(document).ready(function {	if ($('.cioCompareLink').size > 0) {		importScript('MediaWiki:Common.js/compare.js');		importStylesheet('MediaWiki:Common.css/compare.css');	} }); // ================================================================== // End Item Compare Overlays // ==================================================================

// ================================================================== // Dynamic Templates // ================================================================== $(document).ready(function {	if ($('.jcConfig').size > 0) {		importScript('MediaWiki:Common.js/calc.js');		importStylesheet('MediaWiki:Common.css/calc.css');	} }); // ================================================================== // End Dynamic Templates // ==================================================================

// ================================================================== // Insert username // ================================================================== function UserNameReplace { if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName == null) return; $("span.insertusername").html(wgUserName); } addOnloadHook(UserNameReplace);

// ================================================================== // Changes 'article' to 'main page' on the monobook skin // ================================================================== function monobookMainPageFix { var nstab = document.getElementById("ca-nstab-main"); if (nstab && wgUserLanguage == "en") { while (nstab.firstChild) nstab = nstab.firstChild; nstab.nodeValue = "Main page"; } } if (wgPageName == "RuneScape_Wiki" || wgPageName == "Talk:RuneScape_Wiki") { addOnloadHook(monobookMainPageFix); }

// ================================================================== // Hide Auto-uploads // ================================================================== if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Log") { importScript('User:AzBot/HideBotUploads.js'); }

// ================================================================== // Description: Redirects from /User:UserName/skin.js or .css to the user's actual skin page // Maintainer: Cacycle // ================================================================== if (wgArticleId == 0 && wgUserName) { var slash = wgPageName.indexOf('/'); var norm = wgPageName.substr(0, slash) + wgPageName.substr(slash).toLowerCase; var test = 'User:' + wgUserName.replace(/ /g, '_') + '/skin.'; var ext = null; if (norm == test + 'js') ext = 'js'; else if (norm == test + 'css') ext = 'css'; if (ext != null) window.location.href = window.location.href.replace(/\/skin.(css|js)/i, '/' + skin + '.' + ext); }

// ================================================================== // Adds row marking to the penguin locations table on the DnD Locations article // ================================================================== $(document).ready(function {	var pengCookieLen = 20;	var pengCookie = getCookie('pengLocations').split('');

function rowHighlight(el, val) { var cssText = ''; if (val == '2') { cssText = 'background-color: #CCC !important'; } else if (val == '1') { cssText = 'background-color: #CFC !important'; }		$(el).children('td').css('cssText', cssText); }

function save { setCookie('pengLocations', pengCookie.join(''), 60 * 60 * 24 * 7); }

if (wgPageName == 'Distractions_and_Diversions_Locations') { while (pengCookie.length < pengCookieLen) { pengCookie.push('0'); }

$('#penglocations tr').each(function(i) {			rowHighlight(this, pengCookie[i]);

$(this).mouseover(function {				rowHighlight(this, 2);			}).mouseout(function {				rowHighlight(this, pengCookie[i]);			}).click(function {				pengCookie[i] = 1 - pengCookie[i];				rowHighlight(this, pengCookie[i]);				save;			}); });

$('#penglocations').append(			$(' ').append( $(' ').attr('colspan', '7').append(					$(' ').attr('type', 'button').val('Reset marked locations').click(function { $('#penglocations tr').each(function(i) {							pengCookie[i] = '0';							rowHighlight(this, pengCookie[i]);						}); save; })				)			)		);	} });

/* */