MediaWiki:Common.js

/** Username replace function (Template:USERNAME) ******************************* * Inserts user name into * Originally by Splarka * New version by Spang */ function UserNameReplace { if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName == null) return; var n = YAHOO.util.Dom.getElementsByClassName('insertusername', 'span', document.getElementById('bodyContent')); for ( var x in n ) { n[x].innerHTML = wgUserName; } } addOnloadHook(UserNameReplace);

/** Title 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; var cloneNode = titleDiv.cloneNode(true); var firstHeading = document.getElementById('firstHeading'); 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; } YAHOO.util.Event.onDOMReady(rewriteTitle);

// The code marked below was taken from // http://mel-green.com/2009/02/javascript-1337-speak-translator/ // with a few minor translation improvements and tweaks to fit // the wiki framework. // BEGINNING OF CODE

var PhrasesEnglish = new Array('the', 'dude', 'hacker',                 'hacks', 'you', 'cool', 'oh my gosh',                  'fear', 'power', 'own',                  'what the heck', 'elite', 'for the win',                   'loser', 'good game', 'sucks',                  'sucker', 'is', 'rocks', 'winner'); var PhrasesLeet = new Array('teh', 'dood', 'haxxor', 'hax', 'u',                 '1337', 'zomg', 'ph43', 'powwah', 'pwn',                   'wth', 'leet', 'ftw', 'n00b', 'gg',                  'sux', 'suxxor', 'iz', 'rox', 'pwnster');

var LettersEnglish = new Array('n', 'b', 'k', 'd', 'e', 'f', 'g', 'h',                 'p', 'm', 'r', 'l', 'o', 'q', 's', 't',                  'u', 'x', 'w', 'y', 'z', 'c', 'a', 'j',                   'i', 'v', ' '); var LettersLeet = new Array('/\\/', '|3', '|<', '[)', '3', '|=', '6', '|-|', '|*', '|\\/|', '|2', '|_', '0', '0.', '5', '+',                 '|_|', '><', '\\/\\/', '\'/', '2', '(', '/\\', '_|',                   '1', '\\/', '  ');

function translateText(inputString) { inputString = inputString.replace(/&gt;/gi,'<'); inputString = inputString.replace(/&lt;/gi,'>'); inputString = inputString.replace(/&amp;/gi,'&');

for (i = 0; i < PhrasesEnglish.length; ++i) inputString = inputString.replace(                       new RegExp(PhrasesEnglish[i], "gi"),                        PhrasesLeet[i]                        ); for (i = 0; i < LettersEnglish.length; ++i) inputString = inputString.replace(                       new RegExp(LettersEnglish[i], "gi"),                        LettersLeet[i]                        ); return inputString; }

// END OF CODE

function LeetTrigger { var leet_divs = YAHOO.util.Dom.getElementsByClassName('leet', 'div', document.getElementById('bodyContent')); for (var e in leet_divs) { leet_divs[e].innerHTML = translateText(leet_divs[e].innerHTML); } } addOnloadHook(LeetTrigger);

// Apply disclaimer

var t = 'LEGO&reg; is a trademark of the LEGO Group. MLNWiki is not owned or operated by the LEGO Group. '; document.getElementById("wikia_page").innerHTML += t;

// Easter egg function chicken {alert("Cluck cluck.");} if (document.getElementById("chicken")) addOnloadHook(chicken);