「MediaWiki:Common.js」の版間の差分
提供: Wikimedia Conference Japan 2009
(関数間違えた) |
細 (+1) |
||
| 18行目: | 18行目: | ||
} | } | ||
var now = new Date(); | var now = new Date(); | ||
| − | var month = now.getUTCMonth(); | + | var month = now.getUTCMonth() + 1; |
var day = now.getUTCDate(); | var day = now.getUTCDate(); | ||
var hour = now.getUTCHours(); | var hour = now.getUTCHours(); | ||
2009年6月30日 (火) 23:53時点における最新版
/* ここに書いた JavaScript は全てのページ上で実行されます */
addOnloadHook(clock);
function clock()
{
clock.node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', '', 'time' );
clock.node.style.fontWeight = 'bolder';
showClock();
}
function showClock()
{
var node = clock.node;
if( !node ) {
return;
}
var now = new Date();
var month = now.getUTCMonth() + 1;
var day = now.getUTCDate();
var hour = now.getUTCHours();
var min = now.getUTCMinutes();
var sec = now.getUTCSeconds();
var time = ( month < 10 ? '0' + month : month )
+ '/' + ( day < 10 ? '0' + day : day )
+ ' ' + ( hour < 10 ? '0' + hour : hour )
+ ':' + ( min < 10 ? '0' + min : min )
+ ':' + ( sec < 10 ? '0' + sec : sec ) + ' (UTC)';
node.firstChild.replaceChild( document.createTextNode( time ), node.firstChild.firstChild );
window.setTimeout(showClock, 1000);
}