MediaWiki:Common.js

/* */

/* Include Global Anime-Common.js Information */ document.write(' ');

/* if (skin == 'slate' || skin == 'smoke'){ document.write(' '); }

document.write(' ');

/* Allows toggle of game navigation */ var displayStates = new Array('none', ''); var displayText = new Array('show', 'hide');

function gamenav_init { var idnum = 0; // Find all tables with class gamenav var tables = getElementsByClassName(document, "table", "game nav"); for (var ti = 0; ti < tables.length ; ti++) { var tab = tables[ti];

tab.setAttribute('state', 1); // 1 is the show state var gameNavTog = document.createElement("a"); gameNavTog.setAttribute('href', 'javascript:toggleGameNav("' + tab.id + '");'); gameNavTog.setAttribute('id', 'tog_' + tab.id);

var gameNavTogText = document.createTextNode('hide'); gameNavTog.appendChild(gameNavTogText);

var spans = getElementsByClassName(tab, "span", "game nav tog"); for( var sj=0; sj < spans.length; sj++ ){ spans[sj].appendChild(gameNavTog); }	} } function toggleGameNav(tableID) { var nothing; var tab = document.getElementById(tableID); var newState = 1- tab.getAttribute('state'); tab.setAttribute('state', newState); for (var ti=0; ti < tab.rows.length; ti++){ var myRow = tab.rows[ti]; if (myRow.className != "nohide"){ myRow.style.display = displayStates[newState]; }	}	var togA = document.getElementById('tog_' + tableID); var togTxt = togA.firstChild; togTxt.data = displayText[newState]; }

addOnloadHook(gamenav_init);

/*

Open in new window code
*/ /* Function based on externalLinks as described at http://www.mediawiki.org/wiki/Manual:Opening_external_links_in_a_new_window

newWindowLinks = function { if (!document.getElementsByTagName) { return; }       var wrappers = document.getElementsByClassName("OpenNewWindow"); for (var j=0; j < wrappers.length; j++) { var anchors = wrappers[i].getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") != null){ anchor.target = "_blank"; }               }        } } if (window.addEventListener) { window.addEventListener("load", newWindowLinks, false); } else if (window.attachEvent) { window.attachEvent("onload", newWindowLinks ); }

function getElementsByClassName(className) { var result = []; var all = document.getElementsByTagName('*'); for (var i = 0; i < all.length; i++) { if (all[i].className == className) result.push(all[i]); }	return result; } /* */