MediaWiki:Gadget-UTCLiveClock.js: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 25: | Line 25: | ||
* 5. Add the following code to your wiki's [[MediaWiki:Gadgets-definition]]: |
* 5. Add the following code to your wiki's [[MediaWiki:Gadgets-definition]]: |
||
* |
* |
||
* * |
* * UTCLiveClock[ResourceLoader|type=general|dependencies=mediawiki.util,mediawiki.api|peers=UTCLiveClock-pagestyles]|UTCLiveClock.js|UTCLiveClock.css |
||
* * |
* * UTCLiveClock-pagestyles[hidden|skins=vector,monobook]|UTCLiveClock-pagestyles.css |
||
* |
* |
||
*/ |
*/ |
||
Line 42: | Line 42: | ||
// Set the time. |
// Set the time. |
||
var hh = now. |
var hh = now.getlocalHours(); |
||
var mm = now. |
var mm = now.getlocalMinutes(); |
||
var ss = now. |
var ss = now.getlocalSeconds(); |
||
var time = padWithZeroes( hh ) + ':' + padWithZeroes( mm ) + ':' + padWithZeroes( ss ); |
var time = padWithZeroes( hh ) + ':' + padWithZeroes( mm ) + ':' + padWithZeroes( ss ); |
||
$target.text( time ); |
$target.text( time ); |
||
Line 56: | Line 56: | ||
// good. By scheduling 100 ms after the tick, we will always be about 100 ms |
// good. By scheduling 100 ms after the tick, we will always be about 100 ms |
||
// late, but we are also very likely to display a new time every second. |
// late, but we are also very likely to display a new time every second. |
||
var ms = now. |
var ms = now.getUTCMilliseconds(); |
||
setTimeout( function () { |
setTimeout( function () { |
||
showTime( $target ); |
showTime( $target ); |
||
Line 65: | Line 65: | ||
// Set CSS styles. We do this here instead of on the CSS page because some |
// Set CSS styles. We do this here instead of on the CSS page because some |
||
// wikis load this page directly, without loading the accompanying CSS. |
// wikis load this page directly, without loading the accompanying CSS. |
||
mw.util.addCSS( '# |
mw.util.addCSS( '#utcdate a { font-weight:bolder; font-size:120%; }' ); |
||
// Reset whitespace that was set in the peer CSS gadget; this prevents the |
// Reset whitespace that was set in the peer CSS gadget; this prevents the |