「MediaWiki:Common.js」の版間の差分
提供: Wikimedia Conference Japan 2009
(時計表示) |
細 (+1) |
||
| (他の1人の利用者による、間の3版が非表示) | |||
| 18行目: | 18行目: | ||
} | } | ||
var now = new Date(); | var now = new Date(); | ||
| − | var | + | var month = now.getUTCMonth() + 1; |
| − | var | + | var day = now.getUTCDate(); |
| − | var | + | var hour = now.getUTCHours(); |
| − | var time = ( | + | 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 ); | node.firstChild.replaceChild( document.createTextNode( time ), node.firstChild.firstChild ); | ||
| − | window.setTimeout( | + | window.setTimeout(showClock, 1000); |
} | } | ||
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);
}