User talk:Davidgothberg/monobook.js
Appearance
David's old JavaScript repository
[edit]Note: Some of this code works, some don't.
/* Modified version of MediaWiki:Gadget-UTCLiveClock.js
that only ticks once per minute and also notes the time
the page was loaded. */
function liveClock()
{
/* Makes it so if you click the clock the pages is purged. */
liveClock.node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', '', 'utcdate' );
// liveClock.node.style.fontSize = 'larger';
liveClock.node.style.fontWeight = 'bolder';
liveClock.node2 = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', '', 'utcdate' );
showTime();
}
addOnloadHook(liveClock)
var firstTime = 1;
function showTime()
{
var dateNode = liveClock.node;
if( !dateNode ) {
return;
}
var now = new Date();
var hh = now.getUTCHours();
var mm = now.getUTCMinutes();
var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm );
dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild );
if( firstTime ) {
firstTime = 0;
var dateNode2 = liveClock.node2;
if( !dateNode2 ) {
return;
}
dateNode2.firstChild.replaceChild( document.createTextNode( time ), dateNode2.firstChild.firstChild );
}
window.setTimeout(showTime, 300000); /* 5 minutes sleep. */
}
addOnloadHook( function () {
/* Add a "My talk page history" link to the "navigation" menu". */
addPortletLink( 'p-navigation', wgScript + '?title=User_talk:' + wgUserName + '&action=history', 'My talk page history', 'pt-usertalkhist', 'My user talk page history' );
/* Add a "history" link to the "You have new messages". */
var messdivlist = getElementsByClassName( document, "div", "usermessage" );
var messdiv = messdivlist[0];
if( messdiv ) {
var link = document.createElement( "a" );
link.appendChild( document.createTextNode( 'history' ) );
link.href = wgServer + wgScript + '?title=User_talk:' + wgUserName + '&action=history';
messdiv.insertBefore( document.createTextNode( ', ' ), messdiv.lastChild );
messdiv.insertBefore( link, messdiv.lastChild );
}
/*
Code for [[MediaWiki:Youhavenewmessages]]:
You have $1 ($2).
You have $1 ($2<span id="usermessagehistory"></span>).
*/
var userhist = document.getElementById( 'usermessagehistory' );
if( userhist ) {
var link = document.createElement( "a" );
link.appendChild( document.createTextNode( 'history' ) );
link.href = wgServer + wgScript + '?title=User_talk:' + wgUserName + '&action=history';
userhist.appendChild( document.createTextNode( ', ' ) );
userhist.appendChild( link );
}
// Add "Group notice" and "Page notice" links.
addPortletLink( "p-tb", wgScript + "?title=Template:Editnotices/Group/"
+ wgPageName + "&action=edit", "Group notice", "pt-groupnotice", "Group notice" );
addPortletLink( "p-tb", wgScript + "?title=Template:Editnotices/Page/"
+ wgPageName + "&action=edit", "Page notice", "pt-pagenotice", "Page notice" );
if( wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User talk" ) {
addPortletLink( "p-tb", wgScript + "?title=" + wgPageName + "/Editnotice"
+ "&action=edit", "User notice", "pt-usernotice", "User notice" );
}
} );
--David Göthberg (talk) 03:54, 16 September 2008 (UTC)
Legacy JavaScript
[edit]Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook( ... )
needs to be replaced with $( ... )
or $( function() { ... } )
(depending on use); all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' )
; and addPortletLink
needs to be called with mw.util.addPortletLink
. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. — {{U|Technical 13}} (e • t • c)
21:06, 19 January 2015 (UTC)