「MediaWiki:Common.js」の版間の差分

提供: Wikimedia Conference Japan 2009
移動先: 案内検索
(時計表示)
 
(+1)
 
(他の1人の利用者による、間の3版が非表示)
18行目: 18行目:
 
}
 
}
 
     var now = new Date();
 
     var now = new Date();
var hh = now.getUTCHours();
+
var month = now.getUTCMonth() + 1;
var mm = now.getUTCMinutes();
+
var day = now.getUTCDate();
var ss = now.getUTCSeconds();
+
var hour = now.getUTCHours();
var time =      ( hh < 10 ? '0' + hh : hh )
+
var min = now.getUTCMinutes();
+ ':' + ( mm < 10 ? '0' + mm : mm )
+
var sec = now.getUTCSeconds();
+ ':' + ( ss < 10 ? '0' + ss : ss );
+
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(showTime, 1000);
+
     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);
}