MediaWiki:Common.js/User:Bawolff/sandbox/MainPageHeader collapse

if (!window.Bawolff) var Bawolff = {}; //just so it doesn't collide w/any other js Bawolff.hideMainPageEmptyDates = function () { //This is kinda of crappily done, and will break with changes //in main page formatting, or in how mediawiki outputs html var node = document.getElementById('Latest_Headlines') var passedFirstHeader; var passedHeader2;

for (var i = 0; i< 12; i++) { if (typeof node !== "object" || typeof node.nextSibling !== "object" ) break; node = node.nextSibling; if (node.nodeType !== 1/*not an element*/) continue; if (node.tagName === 'H3' && !passedFirstHeader) {

passedFirstHeader = true;
continue;

} else if (!passedHeader2 && node.tagName === 'H3') { passedHeader2 = node; continue; }

if (node.tagName === "UL") break;

if (node.tagName === "P") { passedHeader2.style.display = 'none'; node.style.display = "none"; } } } $(Bawolff.hideMainPageEmptyDates);