User:X-Spider2/monobook.js
From Homestar Runner Wiki
(Difference between revisions)
| Line 67: | Line 67: | ||
if (window.addEventListener) window.addEventListener("load",dostuff,false); | if (window.addEventListener) window.addEventListener("load",dostuff,false); | ||
else if (window.attachEvent) window.attachEvent("onload",dostuff); | else if (window.attachEvent) window.attachEvent("onload",dostuff); | ||
| + | |||
| + | function addPurgeButton() | ||
| + | { | ||
| + | var href = document.location.href; | ||
| + | { | ||
| + | var historyHref = document.getElementById( "ca-history" ).firstChild.href; | ||
| + | var div = document.getElementById( "p-cactions" ); | ||
| + | var ul = div.getElementsByTagName( "ul" )[0]; | ||
| + | var newLi = document.createElement( "li" ); | ||
| + | var newA = document.createElement( "a" ); | ||
| + | newA.setAttribute( "href" , historyHref.replace( "=history" , "=purge" ) ); | ||
| + | var text = document.createTextNode( "purge" ); | ||
| + | newA.appendChild( text ); | ||
| + | newLi.appendChild( newA ); | ||
| + | ul.appendChild( newLi ); | ||
| + | } | ||
| + | } | ||
| + | if ( window.addEventListener ) window.addEventListener( "load" , addPurgeButton , false ); | ||
| + | else if ( window.attachEvent ) window.attachEvent( "onload", addPurgeButton ); | ||
Revision as of 09:55, 10 June 2006
function addQuickbarLink(href, title, before)
{
var li = document.createElement('li');
var a = document.createElement('a');
a.appendChild(document.createTextNode(title));
a.href = href;
li.appendChild(a);
if (!before)
{
document.getElementById('pt-logout').parentNode.appendChild(li);
}
else
{
before = document.getElementById('pt-'+before);
before.parentNode.insertBefore(li, before);
}
}
function addLinks()
{
addQuickbarLink("javascript:history.back()", "back", "userpage");
addQuickbarLink("javascript:history.forward()", "forward", "userpage");
addQuickbarLink("javascript:location.reload()", "refresh", "userpage");
}
if (window.addEventListener) window.addEventListener('load', addLinks, false);
else if (window.attachEvent) window.attachEvent('onload', addLinks);
// Add Sydney time just below the "personal menu" list at the top of the page.
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay
//
function getTime() {
var time = new Date();
var hours = time.getUTCHours();
if (hours < 14) { hours = 10 + hours; }
else if (hours > 13)
{
hours = hours - 14;
if (hours < 10) { hours = "0" + hours; }
}
var minutes = time.getUTCMinutes();
if (minutes < 10) { minutes = "0" + minutes; }
var seconds = time.getUTCSeconds();
if (seconds < 10) { seconds = "0" + seconds; }
var currentTime = hours + ":" + minutes + " and " + seconds + " seconds";
document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 20, currentTime);
doTime = window.setTimeout("getTime()", 1000);
}
function makeTime() {
var div = document.createElement( 'div' );
div.id = 'pt-time';
var mySpan = document.createElement( 'span' );
mySpan.appendChild( document.createTextNode( 'loading time...' ) );
// The text node above will appear for a second before the actual time is received, so I made its value "loading time...".
div.appendChild( mySpan );
document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
doTime = window.setTimeout("getTime()", 1000);
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);
// include utility functions
document.write('<script type="text/javascript" src="/index.php?title=User:Phlip/utilities.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function dostuff()
{
with (utilities) { addMonobookBottomTabs() }
}
if (window.addEventListener) window.addEventListener("load",dostuff,false);
else if (window.attachEvent) window.attachEvent("onload",dostuff);
function addPurgeButton()
{
var href = document.location.href;
{
var historyHref = document.getElementById( "ca-history" ).firstChild.href;
var div = document.getElementById( "p-cactions" );
var ul = div.getElementsByTagName( "ul" )[0];
var newLi = document.createElement( "li" );
var newA = document.createElement( "a" );
newA.setAttribute( "href" , historyHref.replace( "=history" , "=purge" ) );
var text = document.createTextNode( "purge" );
newA.appendChild( text );
newLi.appendChild( newA );
ul.appendChild( newLi );
}
}
if ( window.addEventListener ) window.addEventListener( "load" , addPurgeButton , false );
else if ( window.attachEvent ) window.attachEvent( "onload", addPurgeButton );
