跳转到内容

MediaWiki:Gadget-UTCLiveClock.js

维基百科,自由的百科全书

这是本页的一个历史版本,由Cdip150留言 | 贡献2008年2月20日 (三) 16:46 (取消Cdip150 (对话)的编辑;更改回Alexsh的最后一个版本)编辑。这可能和当前版本存在着巨大的差异。

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
function liveClock()
{

	liveClock.node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + wgPageName + '&action=purge', '', 'utcdate' );
//	liveClock.node.style.fontSize = 'larger';
	liveClock.node.style.fontWeight = 'bolder';

	showTime();
}
addOnloadHook(liveClock)

function showTime()
{

	var dateNode = liveClock.node;
	if( !dateNode ) {
		return;
	}
    var now = new Date();
	var hh = now.getUTCHours();
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
	dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild );

    window.setTimeout(showTime, 1000);
}