跳转到内容

User:NigelSoft-Library/Scripts/CSTLiveClock.js:修订间差异

维基百科,自由的百科全书
删除的内容 添加的内容
NigelSoft-Library留言 | 贡献
无编辑摘要
NigelSoft-Library留言 | 贡献
无编辑摘要
第2行: 第2行:


function showTime( $target ) {
function showTime( $target ) {
var dateNode = CSTLiveClockConfig.node;
var dateNode = .node;
if( !dateNode ) {
if( !dateNode ) {
return;
return;
第25行: 第25行:
appendCSS( '#utcdate a { font-weight:bolder; font-size:120%; }' );
appendCSS( '#utcdate a { font-weight:bolder; font-size:120%; }' );


if ( typeof( CSTLiveClockConfig ) === 'undefined' ) {
if ( typeof( ) === 'undefined' ) {
window.CSTLiveClockConfig = {};
window. = {};
}
}
var portletId = CSTLiveClockConfig.portletId || 'p-personal';
var portletId = .portletId || 'p-personal';
var nextNode = CSTLiveClockConfig.nextNodeId ? document.getElementById( CSTLiveClockConfig.nextNodeId ) : undefined;
var nextNode = .nextNodeId ? document.getElementById( .nextNodeId ) : undefined;
if( !CSTLiveClockConfig.node ) {
if( !.node ) {
return;
return;
}
}

2014年1月10日 (五) 14:32的版本

( function( $, undefined ) {

function showTime( $target ) {
	var dateNode = UTCLiveClockConfig.node;
	if( !dateNode ) {
		return;
	}

	var now = new Date();
	var hh = now.getUTCHours() + 8;
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	if ( typeof $target === 'undefined' ) {
		$target = $( dateNode ).find( 'a:first' );
	}
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
	$target.text( time );

	setTimeout( function(){
		showTime( $target );	
	}, 1000 );
}

function liveClock() {
	appendCSS( '#utcdate a { font-weight:bolder; font-size:120%; }' );

	if ( typeof( UTCLiveClockConfig ) === 'undefined' ) {
		window.UTCLiveClockConfig = {};
	}
	var portletId = UTCLiveClockConfig.portletId || 'p-personal';
	var nextNode = UTCLiveClockConfig.nextNodeId ? document.getElementById( UTCLiveClockConfig.nextNodeId ) : undefined;
	if( !UTCLiveClockConfig.node ) {
		return;
	}

	showTime();
}
$( document ).ready( liveClock );

} )( jQuery );