「MediaWiki:Common.js」の版間の差分
提供: Wikimedia Conference Japan 2009
(日付も表示) |
(関数間違えた) |
||
| 18行目: | 18行目: | ||
} | } | ||
var now = new Date(); | var now = new Date(); | ||
| − | var month = now. | + | var month = now.getUTCMonth(); |
| − | var day = now. | + | var day = now.getUTCDate(); |
var hour = now.getUTCHours(); | var hour = now.getUTCHours(); | ||
var min = now.getUTCMinutes(); | var min = now.getUTCMinutes(); | ||
2009年6月25日 (木) 15:22時点における版
/* ここに書いた 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();
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);
}