MediaWiki:Common.js

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

function addWikiScript( src ) { return $.ajax( {       url: src,        dataType: 'script',        crossDomain: true,        cache: true    } ); }

function getPageName { return mw.config.get("wgPageName"); }

mw.loader.load( '/index.php?title=MediaWiki:' + getPageName + '.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/index.php?title=MediaWiki:' + getPageName + '.css&action=raw&ctype=text/css', 'text/css' );

if (getPageName.indexOf('UserProfile:CommanderMark')==0 && getPageName.indexOf('/')==-1) { document.getElementsByClassName('grouptags')[0].innerHTML += "True Jorge"; }

if (getPageName.indexOf('UserProfile:Regalis11')==0 && getPageName.indexOf('/')==-1) { document.getElementsByClassName('grouptags')[0].innerHTML += "Undertow Games"; }

//code for collapsing long comments on profiles function toggleCommentCollapse(elem) { var str = elem.childNodes[elem.childNodes.length-1].innerHTML; if (elem.getAttribute("data-collapsed") == "true") { elem.setAttribute("data-collapsed", "false"); elem.style.height = (parseInt(elem.getAttribute("data-origheight"))+40)+"px"; elem.childNodes[elem.childNodes.length-1].innerHTML = str.replace("Show full comment", "Collapse comment"); } else { elem.setAttribute("data-collapsed", "true"); elem.style.height = '100px'; elem.childNodes[elem.childNodes.length-1].innerHTML = str.replace("Collapse comment", "Show full comment"); } }

var elems = document.getElementsByClassName("commentbody"); for(var i=0; i150) { elems[i].setAttribute("data-collapsed", "true"); elems[i].setAttribute("data-origheight", elems[i].clientHeight); elems[i].style.height = '100px'; elems[i].style.overflow = 'hidden'; elems[i].style.position = 'relative'; elems[i].onclick = function{toggleCommentCollapse(this);};

var text = document.createElement("div"); text.style.width = '100%'; text.style.backgroundColor = '#222222'; text.style.color = '#999999'; text.style.textAlign = 'center'; text.style.position = 'absolute'; text.style.left = '0'; text.style.bottom = '0'; text.style.margin = '0'; text.style.verticalAlign = 'middle'; text.innerHTML = "Show full comment"; elems[i].appendChild(text); text.innerHTML = "Show full comment "; text.style.height = '25px'; } }

// Find Nesting Issues button. var editButtons = document.getElementsByClassName("editButtons"); var newButton; for(var i=0; i<editButtons.length; i++) { newButton = document.createElement("input"); newButton.id = "wpFindNestingIssues"; newButton.name = "wpFindNestingsIssues"; newButton.type = "button"; newButton.value = "Find nesting issues"; newButton.onclick = function{findNestingIssues}; var interSpan = document.createElement("span"); interSpan.innerHTML = "  -   "; editButtons[i].appendChild(interSpan); editButtons[i].appendChild(newButton); }

function findNestingIssues { var textbox = document.getElementById("wpTextbox1"); var nestList = []; var lineList = []; var tagToParse = ""; var shouldClose = false; var skipToCloseTag = false; var errorStr = ""; var tempErrorStr = ""; var lineNum = 1; for (var i=0;i=0;j--) { if (nestList[j].toLowerCase=="{") { if (j==nestList.length-1) { properClose = true; } else { properClose = false; tempErrorStr = "{ closed before child(ren) "; for (var k=j+1;k")==-1) { if (tagToParse=="<" && textbox.value.charAt(i)=="/") { shouldClose = true; skipToCloseTag = false; } else if (textbox.value.charAt(i)=="/") { tagToParse=""; skipToCloseTag = false; } else if (textbox.value.charAt(i)==" " || textbox.value.charAt(i)=="\n") { skipToCloseTag = true; } else if (textbox.value.charAt(i)==">") { if (shouldClose) { tagToParse = tagToParse.replace(" ",""); shouldClose = false; var properClose = false; tagToParse += ">"; tempErrorStr = tagToParse+" closed without an opening tag." for (var j=nestList.length-1;j>=0;j--) { if (nestList[j].toLowerCase==tagToParse.toLowerCase) { if (j==nestList.length-1) { properClose = true; } else { properClose = false; tempErrorStr = nestList[j].toLowerCase+" closed before child(ren) "; for (var k=j+1;k"; if (tagToParse.toLowerCase!=" ") { //special case: skip br                  nestList.push(tagToParse); lineList.push(lineNum); }           }            tagToParse = ""; skipToCloseTag = false; } else if (!skipToCloseTag) { tagToParse += textbox.value.charAt(i); }     }   }   if (nestList.length>0) { for (var i=0;i<nestList.length;i++) { errorStr+="Unclosed tag: "+nestList[i]+" (opened on line "+lineList[i]+")\n"; }  }   if (errorStr!="") { alert("You may have dun goofed at:\n"+errorStr+"\nIf you're editing a JS or CSS file then why did you click on that button?"); } else { alert("No nesting problems were found."); } }