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