Difference between revisions of "MediaWiki:Common.js"

From CSLabsWiki
(Added script to remove "Main Page" firstHeading)
 
(Changed the Main Page title removal script. The old one seemed to have stopped working.)
Line 2: Line 2:
 
//BEGIN remove Main Page title
 
//BEGIN remove Main Page title
   
  +
function clearMainPage(){
var mpTitle = "Main Page";
 
  +
if (wgTitle == 'Main Page') {
var isMainPage = (/(title=|\/wiki\/)([Tt]alk:|)[Mm]ain[ _][Pp]age/.test(document.location));
 
  +
var h1tags = document.getElementsByTagName("h1");
var isMainPageFront = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
 
  +
var h = h1tags[0];
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
 
  +
var parent = h.parentNode;
   
  +
parent.removeChild(h);
if (isMainPage && isMainPageFront && !isDiff)
 
  +
}
{
 
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
 
 
}
 
}
  +
  +
addOnloadHook(clearMainPage);
   
 
//END remove Main Page title
 
//END remove Main Page title

Revision as of 14:03, 5 July 2009

/* Any JavaScript here will be loaded for all users on every page load. */
//BEGIN remove Main Page title

function clearMainPage(){
     if (wgTitle == 'Main Page') {
          var h1tags = document.getElementsByTagName("h1");
          var h = h1tags[0];
          var parent = h.parentNode;

          parent.removeChild(h);
     }
}

addOnloadHook(clearMainPage);

//END remove Main Page title