MediaWiki:Functions.js

/* */

window.storagePresent = (typeof(globalStorage) != 'undefined');

String.prototype.trim = function { return this.replace(/^\s+|\s+$/g, ""); };

// BEGIN getElementsByClass - http://www.dustindiaz.com/getelementsbyclass/ function getElementsByClass(searchClass, node, tag) {	var classElements = new Array;

if ( node == null ) node = document;

if ( tag == null ) tag = '*';

var els = node.getElementsByTagName(tag); var elsLen = els.length;

var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; }	}	return classElements; } // END getElementsByClass

// ================================================== //  Begin temporary per-page unique CSS (Splarka) // ================================================== // The following script sort of emulates the per-page // unique class functionality that is added to future // version of MediaWiki. // // This takes  text.Content // and makes it a class in the format: // page-Page_Title_Here // with all spaces and non-alphanumeric characters // converted to underscores. // // So one can style Special:Contributions with a css // command like: body.page-User_Contributions {} // // Query string debugging tools: // &useclass=xxx     lets you overwrite the class // &debug=true         popup tells you the pageclass

function bodyClassAdd { var bodyclass = document.getElementsByTagName('body')[0].className; var page = pageName;

if(queryString('useclass')) page = queryString('useclass') page = page.replace(/\W/g,'_');  // page = 'page-' + page; if(queryString('debug')) alert('This page has an extra CSS body class:\n' + page+ '\nIt will be applied as soon as you close this alert') document.getElementsByTagName('body')[0].className = bodyclass + ' ' + page; }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }	}	return null; } // ================================================== //   End temporary per-page unique CSS (Splarka) // ==================================================

function getRequest {   if(typeof(XMLHttpRequest) != 'undefined') {       return new XMLHttpRequest; }   else if(typeof(ActiveXObject) != 'undefined') {       return new ActiveXObject("Msxml2.XMLHTTP"); }

return null; }

function iAmAlive {    alert('I am alive!'); }

/* */