User:Gimmetrow/clock.js

/* Modified version of MediaWiki:Gadget-UTCLiveClock.js that only ticks once per minute and also notes the time the page was loaded. From User:Davidgothberg/monobook.js*/ function liveClock { /* Makes it so if you click the clock the pages is purged. */ liveClock.node = mw.util.addPortletLink( 'p-personal', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=purge', '', 'utcdate' ); // liveClock.node.style.fontSize = 'larger'; liveClock.node.style.fontWeight = 'bolder'; liveClock.node2 = mw.util.addPortletLink( 'p-personal', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=purge', '', 'utcdate' ); showTime; } $(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, 60000);   /* 1 minutes sleep. */ }