User:Darth Stabro/clock.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
// If FriendlyConfig aint exist.
if( typeof( FriendlyConfig ) == 'undefined' ) {
FriendlyConfig = {};
}
/**
FriendlyConfig.enableClock ( boolean )
*/
if( typeof( FriendlyConfig.enableClock ) == 'undefined' ) {
FriendlyConfig.enableClock = true;
}
/**
FriendlyConfig.clockStyle ( String )
*/
if( typeof( FriendlyConfig.clockStyle ) == 'undefined' ) {
FriendlyConfig.clockStyle = 'dynamic';
}
friendlyclock = {
showClock: function() {
var query = {
'action': 'purge',
'title': wgPageName
};
friendlyclock.clockNode = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?' + QueryString.create( query ), '--:--:-- UTC', 'friendly-clock', 'Purge this page', '' );
friendlyclock.clockNode.style.fontSize = 'normal';
friendlyclock.clockNode.style.fontWeight = 'bold';
friendlyclock.clockNode.style.textTransform = 'uppercase';
friendlyclock.updateTime();
if( FriendlyConfig.clockStyle != 'static' ) {
friendlyclock.intervalId = window.setInterval(friendlyclock.updateTime, 1000);
}
},
updateTime: function() {
if( !friendlyclock.clockNode ) {
return;
}
var now = new Date();
var hh = now.getUTCHours();
var mm = now.getUTCMinutes();
var ss = now.getUTCSeconds();
var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss) + ' UTC';
friendlyclock.clockNode.firstChild.innerHTML = time;
}
}
addOnloadHook( function() {
if( FriendlyConfig.enableClock ) {
friendlyclock.showClock();
}
}
);