MediaWiki:Common.js/SyntaxHighligtBackground.js

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

//Function to properly get the class name document.getElementsByClassNameC = function(cl) {	var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = this.getElementsByTagName('*'); for (var i = 0; i < elem.length; i++) {		var classes = elem[i].className; if (myclass.test(classes)) {				retnode.push(elem[i]); }	}	return retnode; };

// Check if there is at least one instance of the class "source-xml" on the page if(document.getElementsByClassNameC('source-xml')[0] && document.getElementsByClassNameC('source-xml')[0].innerHTML) {	// Cycle through each instance of the occurance for(var i=0; i < document.getElementsByClassNameC('source-xml').length; i++) {		// Make GAE Only features red document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- Start GAE Only --&gt;<\/span>\n?/gi, ' '); document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- End GAE Only --&gt;<\/span>\n?/gi, ' '); // Make MG Only features blue document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- Start MG Only --&gt;<\/span>\n?/gi, ' '); document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- End MG Only --&gt;<\/span>\n?/gi, ' '); // Make GAE + MG Only features purple document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- Start GAE\+MG Only --&gt;<\/span>\n?/gi, ' '); document.getElementsByClassNameC('source-xml')[i].innerHTML = document.getElementsByClassNameC('source-xml')[i].innerHTML.replace(/\n?\s* &lt;!-- End GAE\+MG Only --&gt;<\/span>\n?/gi, ' '); } }