MediaWiki:Common.js: Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
m (testing a possible variant on the collapsible boxes.)
mNo edit summary
(9 intermediate revisions by 3 users not shown)
Line 5: Line 5:
{
{
   var script  = document.createElement( 'script' );
   var script  = document.createElement( 'script' );
   script.src  = '/w/index.php?title=User:Poke/CollapsibleTables.js&action=raw&ctype=text/javascript';
   script.src  = '/w/index.php?title=User:Poke/CollapsibleTables.js&action=raw&ctype=text/javascript&smaxage=18000&action=raw&maxage=18000';
   script.type = 'text/javascript';
   script.type = 'text/javascript';
   document.getElementsByTagName( 'head' )[0].appendChild( script );
   document.getElementsByTagName( 'head' )[0].appendChild( script );
    
    
   hookEvent( 'load', function()
   addOnloadHook(function () { new CollapsibleTables(); });
  { new CollapsibleTables(); } );
}
}


Line 145: Line 144:
updateClocks();
updateClocks();
}
}
/* Hook that enables collapsing objects.
* Added 7/13/2008 by WhiteMystery on Encyclopedia Dramatica ([email protected]) */


addOnloadHook(createToggleLinks);
// Webmaster staff icons
addOnloadHook(function () {
if(
window.location.href.indexOf("/wiki/User:") == -1
) {
if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
return;
  }
};


/* Function that creates collapsing objects and toggle links.
// create div and set innerHTML to link
  * Added 7/13/2008 by WhiteMystery on Encyclopedia Dramatica (misterioblanco@gmail.com) */
var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="stafflink-WM" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Webmasters" title="This user is a Webmaster of Bulbagarden."><img src="http://cdn.bulbagarden.net/media/upload/0/01/IconBPWebmaster.png"></a></div>';


function createToggleLinks() {
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}


var stateArray = new Array();
});
var allObjects = document.getElementsByTagName('span');
 
var rCollapsingObject = new RegExp("^co;(.+?);(.+?);(.+?);(.+?)(;(.+?))?$");
// Editorial Board staff icons
addOnloadHook(function () {
for ( var i = 0; i < allObjects.length; i++ ) {
if(
window.location.href.indexOf("/wiki/User:") == -1
if ( rCollapsingObject.test(allObjects[i].className) ) {
) {
if(
var collapsingInformation = rCollapsingObject.exec(allObjects[i].className);
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
var collapseText = collapsingInformation[1];
return;
var expandText = collapsingInformation[2];
  }
var initialState = collapsingInformation[3];
};
var targetClass = collapsingInformation[4];
 
var linkColor = collapsingInformation[6];
// create div and set innerHTML to link
var divContainer = document.createElement("div");
var toggleLink = document.createElement("a");
divContainer.innerHTML = '<div class="stafflink-EB" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Editorial_Board" title="This user is a member of the Bulbapedia Editorial Board."><img src="http://cdn.bulbagarden.net/media/upload/3/3d/IconBPEditorialBoard.png"></a></div>';
 
if ( initialState == "0" ) {
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
toggleLink.appendChild(document.createTextNode(expandText));
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
stateArray[targetClass] = "none";
}
}
 
});
else {
 
// Bureaucrat staff icons
toggleLink.appendChild(document.createTextNode(collapseText));
addOnloadHook(function () {
stateArray[targetClass] = "inline";
if(
}
window.location.href.indexOf("/wiki/User:") == -1
) {
toggleLink.setAttribute("href", "javascript:toggleCollapse('" + targetClass + "','" + collapseText + "','" + expandText + "')");
if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
if ( linkColor != undefined && linkColor != "undefined" && linkColor != "" )
  ) {
toggleLink.style.color = linkColor;
return;
  }
allObjects[i].innerHTML = "";
};
allObjects[i].appendChild(toggleLink);
 
}
// create div and set innerHTML to link
var divContainer = document.createElement("div");
else if ( allObjects[i].className == "morphMaster" ) {
divContainer.innerHTML = '<div class="stafflink-BC" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Bureaucrats" title="This user is a Bulbapedia Bureaucrat."><img src="http://cdn.bulbagarden.net/media/upload/1/18/IconBPBureaucrat.png"></a></div>';
 
var spanID = allObjects[i].getAttribute("id");
// insert divContainer into the DOM below the h1
var targetID = spanID.substr(0, spanID.length - 6);
if(window.location.href.indexOf("&action=edit") == -1) {
var counter = 1;
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
// Create forward and backward paging if the paging elements exist
 
if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) {
});
 
// Create the forward link
// Senior Administrator staff icons
var nextLink = document.createElement("a");
addOnloadHook(function () {
nextLink.appendChild(document.createTextNode(returnObjById(targetID + "LinkNext").innerHTML));
if(
nextLink.setAttribute("href", "javascript:morphForward('" + targetID + "')");
window.location.href.indexOf("/wiki/User:") == -1
) {
returnObjById(targetID + "LinkNext").innerHTML = "";
if(
returnObjById(targetID + "LinkNext").appendChild(nextLink, 0);
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
// Create the backward link
return;
var prevLink = document.createElement("a");
  }
prevLink.appendChild(document.createTextNode(returnObjById(targetID + "LinkPrev").innerHTML));
};
prevLink.setAttribute("href", "javascript:morphBackward('" + targetID + "')");
 
// create div and set innerHTML to link
returnObjById(targetID + "LinkPrev").innerHTML = "";
var divContainer = document.createElement("div");
returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0);
divContainer.innerHTML = '<div class="stafflink-SA" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Senior_Administrators" title="This user is a Bulbapedia Senior Administrator."><img src="http://cdn.bulbagarden.net/media/upload/d/d5/IconBPSeniorAdministrator.png"></a></div>';
 
// Initialize content panes
// insert divContainer into the DOM below the h1
while ( returnObjById(targetID + "Content" + counter) ) {
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
if ( counter == 1 )
}
returnObjById(targetID + "Content" + counter).style.display = "inline";
 
else
});
returnObjById(targetID + "Content" + counter).style.display = "none";
 
// Administrator staff icons
counter++;
addOnloadHook(function () {
}
if(
}
window.location.href.indexOf("/wiki/User:") == -1
) {
if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
return;
  }
};
 
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="stafflink-AD" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Administrators" title="This user is a Bulbapedia Administrator."><img src="http://cdn.bulbagarden.net/media/upload/8/81/IconBPAdministrator.png"></a></div>';
 
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
 
});
 
// Junior Administrator staff icons
addOnloadHook(function () {
if(
window.location.href.indexOf("/wiki/User:") == -1
) {
if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
return;
  }
};
 
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="stafflink-JA" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Junior_Administrators" title="This user is a Bulbapedia Junior Administrator."><img src="http://cdn.bulbagarden.net/media/upload/5/5f/IconBPJuniorAdministrator.png"></a></div>';
 
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
 
});
 
// Inactive staff icons
addOnloadHook(function () {
if(
window.location.href.indexOf("/wiki/User:") == -1
) {
if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
return;
  }
};
 
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="stafflink-IN" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Inactive_Staff" title="This user is an inactive Bulbapedia staff member. Please direct your inquiries to an active staff member."><img src="http://cdn.bulbagarden.net/media/upload/8/8d/IconBPInactive.png"></a></div>';
 
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}
 
});
 
// This will add an [edit] link at the top of all pages except preview pages and the main page
// by User:Pile0nades (blatantly stolen from Wikipedia by User:The dark lord trombonator
 
// Add an [edit] link to pages
addOnloadHook(function () {
// if this is preview page or generated page, stop
if(
document.getElementById("wikiPreview") ||
document.getElementById("histlegend‎") ||
document.getElementById("difference‎") ||
document.getElementById("watchdetails") ||
document.getElementById("ca-viewsource") ||
window.location.href.indexOf("/wiki/Special:") != -1
) {
if(window.location.href.indexOf("&action=edit&section=0") != -1) {
document.getElementById("wpSummary").value = "/* Intro */ ";
}
return;
};
 
// get the page title
var pageTitle = wgPageName;


counter = 1;
// create div and set innerHTML to link
var divContainer = document.createElement("div");
// Whether or not there is paging, generate normal links
divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+encodeURI(pageTitle)+'&action=edit&section=0" title="Edit first section: '+pageTitle+'">edit top of page</a>]</div>';
while ( returnObjById(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter) ) {
var morphLink = document.createElement("a");
morphLink.appendChild(document.createTextNode(returnObjById(targetID + "Link" + counter).innerHTML));
morphLink.setAttribute("href", "javascript:performMorph('" + targetID + "','" + counter + "')");
returnObjById(targetID + "Link" + counter).innerHTML = "";
returnObjById(targetID + "Link" + counter).appendChild(morphLink, 0);
// Initialize content panes
if ( counter == 1 )
returnObjById(targetID + "Content" + counter).style.display = "inline";
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
allObjects[i].innerHTML = "1";
allObjects[i].style.display = "none";
}
}
// Set state of appropriate objects
allObjects = document.getElementsByTagName('*');
for ( var i = 0; i < allObjects.length; i++ ) {
if ( stateArray[allObjects[i].className] )
allObjects[i].style.display = stateArray[allObjects[i].className];
}
}


/* Function that toggles collapsing objects.
// insert divContainer into the DOM below the h1
  * Added 7/13/2008 by WhiteMystery on Encyclopedia Dramatica (misterioblanco@gmail.com) */
if(window.location.href.indexOf("&action=edit") == -1) {
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}


function toggleCollapse(targetClass, collapseText, expandText) {
});


var allObjects = document.getElementsByTagName('*');
// This will add an [+] (new section) link at the top of all pages except preview pages and the main page... because some people are having trouble finding it or something
var rCollapsingObject = new RegExp("^co;(.+?);(.+?);(.+?);" + targetClass + "(;(.+?))?$");
// Roughly edited from the above section by User:The dark lord trombonator
var linkType;
for ( var i = 0; i < allObjects.length; i++ ) {
if ( allObjects[i].className == targetClass ) {
if ( allObjects[i].style.display == "none" ) {
allObjects[i].style.display = "inline";
linkType = "Collapse";
}
else {
allObjects[i].style.display = "none";
linkType = "Expand";
}
}
}
allObjects = document.getElementsByTagName('span');
for ( var i = 0; i < allObjects.length; i++ ) {
if ( rCollapsingObject.test(allObjects[i].className) ) {
var collapsingInformation = rCollapsingObject.exec(allObjects[i].className);
var collapseText = collapsingInformation[1];
var expandText = collapsingInformation[2];
var linkColor = collapsingInformation[5];
var toggleLink = document.createElement("a");
if ( linkType == "Expand" )
toggleLink.appendChild(document.createTextNode(expandText));
else if ( linkType == "Collapse" )
toggleLink.appendChild(document.createTextNode(collapseText));
toggleLink.setAttribute("href", "javascript:toggleCollapse('" + targetClass + "','" + collapseText + "','" + expandText + "')");
if ( linkColor != undefined && linkColor != "undefined" && linkColor != "" )
toggleLink.style.color = linkColor;
allObjects[i].innerHTML = "";
allObjects[i].appendChild(toggleLink);
}
}
}


/* Functions that perform the morph operations.
// Add an [+] link to pages
  * Added 8/13/2008 by WhiteMystery on Encyclopedia Dramatica (misterioblanco@gmail.com) */
addOnloadHook(function () {
// if this is preview page or generated page, stop
if(
document.getElementById("wikiPreview") ||
document.getElementById("histlegend‎") ||
document.getElementById("difference‎") ||
document.getElementById("watchdetails") ||
document.getElementById("ca-viewsource") ||
document.getElementById("article") ||
  window.location.href.indexOf("/wiki/Special:") != -1
) {
if(window.location.href.indexOf("&action=edit&section=0") != -1) {
document.getElementById("wpSummary").value = "/* Intro */ ";
}
return;
};


function performMorph(targetID, targetNumber) {
// get the page title
var pageTitle = wgPageName;


var counter = 1;
// create div and set innerHTML to link
var divContainer = document.createElement("div");
while ( returnObjById(targetID + "Content" + counter) ) {
divContainer.innerHTML = '<div class="editsectionnew">[<a href="/w/index.php?title='+encodeURI(pageTitle)+'&action=edit&section=new" title="Start new section: '+pageTitle+'">+</a>]</div>';
if ( counter == targetNumber )
returnObjById(targetID + "Content" + counter).style.display = "block";
else
returnObjById(targetID + "Content" + counter).style.display = "none";
counter++;
}
returnObjById(targetID + "Master").innerHTML = targetNumber;
}


function morphForward(targetID) {
// insert divContainer into the DOM below the h1
if(window.location.href.indexOf("&action=edit") == -1) {
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
}


var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1;
});
if ( returnObjById(targetID + "Content" + nextPane) )
performMorph(targetID, nextPane);
else
performMorph(targetID, "1");
}


function morphBackward(targetID) {
// Checks if page has the parts of a countdown, then starts it if it does


var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1;
if(document.getElementById('countdown') && document.getElementById('countdown-big') && document.getElementById('countdown-small') && document.getElementById('countdown-target')) {
    startCountdown();
if ( prevPane > 0 )
performMorph(targetID, prevPane);
else {
var maxIndex = 1;
while ( returnObjById(targetID + "Content" + maxIndex) )
maxIndex++;
performMorph(targetID, maxIndex - 1);
}
}
}
/* </pre> */
/* </pre> */

Revision as of 22:36, 30 June 2016

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

if ( wgIsArticle || window.location.href.indexOf( 'action=submit' ) > -1 )
{
  var script  = document.createElement( 'script' );
  script.src  = '/w/index.php?title=User:Poke/CollapsibleTables.js&action=raw&ctype=text/javascript&smaxage=18000&action=raw&maxage=18000';
  script.type = 'text/javascript';
  document.getElementsByTagName( 'head' )[0].appendChild( script );
  
  addOnloadHook(function () { new CollapsibleTables(); });
}

function formatDate(t)
{
	var month = new Array();
	month[0] = 'January';
	month[1] = 'February';
	month[2] = 'March';
	month[3] = 'April';
	month[4] = 'May';
	month[5] = 'June';
	month[6] = 'July';
	month[7] = 'August';
	month[8] = 'September';
	month[9] = 'October';
	month[10] = 'November';
	month[11] = 'December';
	
	y = t.getUTCFullYear();
	M = t.getUTCMonth();
	D = t.getUTCDate();
	h = t.getUTCHours();
	m = t.getUTCMinutes();
	s = t.getUTCSeconds();
	
	if (h > 0 || m > 0 || s > 0)
	{
		hms = '';
		
		if (s > 10)
			hms = ':' + s;
		else if (s > 0)
			hms = ':0' + s;
		
		if (m > 10)
			hms = ':' + m + hms;
		else if (m > 0)
			hms = ':0' + m + hms;
			
		if (h > 12)
			hms = (h - 12) + hms + ' PM';
		else if (h > 0)
			hms = h + hms + ' AM';
		else
			hms = '12' + hms + ' AM';
		
		return hms + ', ' + month[M] + ' ' + D + ', ' + y;
	} else {
		return month[M] + ' ' + D + ', ' + y;
	}
}

function formatTime(h, m, s)
{
	var o = '';
	
	if (h != 1)
	{
		o = h + ' hours ';
	} else {
		o = '1 hour ';
	}
	
	if (m != 1)
	{
		o += m + ' minutes ';
	} else {
		o += '1 minute ';
	}
	
	if (s != 1)
	{
		o += s + ' seconds';
	} else {
		o += '1 second';
	}
	
	return o;
}

function updateClocks()
{
	var t = new Date();

	setTimeout(updateClocks, 1000);
	
	D = t.getUTCDate();
	M = t.getUTCMonth();
	y = t.getUTCFullYear();
	h = t.getUTCHours();
	m = t.getUTCMinutes();
	s = t.getUTCSeconds();

	t = Date.UTC(y, M, D, h, m, s);

	t = (T - t) / 1000;
	
	if (t < 0 && t > -86400 && (h > 0 || m > 0 || s > 0))
	{
		document.getElementById('countdown-big').innerHTML = 'Today';
		document.getElementById('countdown-small').innerHTML = '';
		document.getElementById('countdown-target').innerHTML = 'is ' + formatDate(new Date(T + tzOffset)) + ' ' + tz;
		
		return;
	} else if (t < 0) {
		document.getElementById('countdown-big').innerHTML = 'Past';
		document.getElementById('countdown-target').innerHTML = formatDate(new Date(T + tzOffset)) + ' ' + tz;	
		
		return;
	}
	
	D = Math.floor(t / 86400.0);
	h = Math.floor(t % 86400.0 / 3600.0);
	m = Math.floor(t % 3600.0 / 60.0);
	s = Math.floor(t % 60.0)

	if (D == 1)
	{
		document.getElementById('countdown-big').innerHTML = '1 day';
	} else if (D == 0) {
		document.getElementById('countdown-big').innerHTML = '';
	} else {
		document.getElementById('countdown-big').innerHTML = D + ' days';
	}
	
	document.getElementById('countdown-small').innerHTML = formatTime(h, m, s);
}

function startCountdown()
{
	document.getElementById('countdown-target').innerHTML = 'to ' + formatDate(new Date(T + tzOffset)) + ' ' + tz;
	document.getElementById('countdown').style.display = 'block';
	updateClocks();
}

// Webmaster staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-WM" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Webmasters" title="This user is a Webmaster of Bulbagarden."><img src="http://cdn.bulbagarden.net/media/upload/0/01/IconBPWebmaster.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Editorial Board staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-EB" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Editorial_Board" title="This user is a member of the Bulbapedia Editorial Board."><img src="http://cdn.bulbagarden.net/media/upload/3/3d/IconBPEditorialBoard.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Bureaucrat staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-BC" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Bureaucrats" title="This user is a Bulbapedia Bureaucrat."><img src="http://cdn.bulbagarden.net/media/upload/1/18/IconBPBureaucrat.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Senior Administrator staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-SA" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Senior_Administrators" title="This user is a Bulbapedia Senior Administrator."><img src="http://cdn.bulbagarden.net/media/upload/d/d5/IconBPSeniorAdministrator.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Administrator staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-AD" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Administrators" title="This user is a Bulbapedia Administrator."><img src="http://cdn.bulbagarden.net/media/upload/8/81/IconBPAdministrator.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Junior Administrator staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-JA" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Junior_Administrators" title="This user is a Bulbapedia Junior Administrator."><img src="http://cdn.bulbagarden.net/media/upload/5/5f/IconBPJuniorAdministrator.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// Inactive staff icons
addOnloadHook(function () {
 if(
 window.location.href.indexOf("/wiki/User:") == -1
 ) {
 if(
  window.location.href.indexOf("/wiki/User_talk:") == -1
  ) {
 return;
  }
 };

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="stafflink-IN" style="float:right; display:none;"><a href="/wiki/Bulbapedia:Inactive_Staff" title="This user is an inactive Bulbapedia staff member. Please direct your inquiries to an active staff member."><img src="http://cdn.bulbagarden.net/media/upload/8/8d/IconBPInactive.png"></a></div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// This will add an [edit] link at the top of all pages except preview pages and the main page
// by User:Pile0nades (blatantly stolen from Wikipedia by User:The dark lord trombonator

// Add an [edit] link to pages
addOnloadHook(function () {
 // if this is preview page or generated page, stop
 if(
 document.getElementById("wikiPreview") ||
 document.getElementById("histlegend‎") ||
 document.getElementById("difference‎") ||
 document.getElementById("watchdetails") ||
 document.getElementById("ca-viewsource") ||
 window.location.href.indexOf("/wiki/Special:") != -1
 ) {
 if(window.location.href.indexOf("&action=edit&section=0") != -1) {
 document.getElementById("wpSummary").value = "/* Intro */ ";
 }
 return;
 };

 // get the page title
 var pageTitle = wgPageName;

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+encodeURI(pageTitle)+'&action=edit&section=0" title="Edit first section: '+pageTitle+'">edit top of page</a>]</div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

// This will add an [+] (new section) link at the top of all pages except preview pages and the main page... because some people are having trouble finding it or something
// Roughly edited from the above section by User:The dark lord trombonator

// Add an [+] link to pages
addOnloadHook(function () {
 // if this is preview page or generated page, stop
 if(
 document.getElementById("wikiPreview") ||
 document.getElementById("histlegend‎") ||
 document.getElementById("difference‎") ||
 document.getElementById("watchdetails") ||
 document.getElementById("ca-viewsource") ||
 document.getElementById("article") ||
 window.location.href.indexOf("/wiki/Special:") != -1
 ) {
 if(window.location.href.indexOf("&action=edit&section=0") != -1) {
 document.getElementById("wpSummary").value = "/* Intro */ ";
 }
 return;
 };

 // get the page title
 var pageTitle = wgPageName;

 // create div and set innerHTML to link
 var divContainer = document.createElement("div");
 divContainer.innerHTML = '<div class="editsectionnew">[<a href="/w/index.php?title='+encodeURI(pageTitle)+'&action=edit&section=new" title="Start new section: '+pageTitle+'">+</a>]</div>';

 // insert divContainer into the DOM below the h1
 if(window.location.href.indexOf("&action=edit") == -1) {
 document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 }

});

 // Checks if page has the parts of a countdown, then starts it if it does

 if(document.getElementById('countdown') && document.getElementById('countdown-big') && document.getElementById('countdown-small') && document.getElementById('countdown-target')) {
    startCountdown();
}
/* </pre> */