使用者:小躍/Live-Clock.js

Chhiùng Wikipedia lòi

Chu-yi: Chhai tú-chhùn yî-heu, ngì pit-sî khoai chhái-chhí chhîn-chhù hi-khí chhòi-nèn khon-tó chok-chhut ke kói-pien. Mozilla / Firefox / Safari: on-tén Shift chai tiám-kit Chhùng-sîn chṳ́n-lî (fe̍t-chá on-hâ Ctrl-Shift-R, chhai Phìn-kó Mac song on-hâ Cmd-Shift-R); IE: on-tén Ctrl chai tiám-kit Chhùng-sîn chṳ́n-lî, fe̍t-he on-hâ Ctrl-F5Konqueror: chak sî-yeu tiám-kit Chhùng-sîn chṳ́n-lî; Opera: yung-fu sî-yeu chhai kûng-khí-sat-thin chûng vàn-cháng-thi chhîn-chhù ke khoai-chhí.

//CST times
( function( $, undefined ) {

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

	var now = new Date();
	var hh = now.getUTCHours() + 8 > 23 ? now.getUTCHours() + 8 - 24 : 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( CSTLiveClockConfig ) === 'undefined' ) {
		window.CSTLiveClockConfig = {};
	}
	var portletId = CSTLiveClockConfig.portletId || 'p-personal';
	var nextNode = CSTLiveClockConfig.nextNodeId ? document.getElementById( CSTLiveClockConfig.nextNodeId ) : undefined;
	CSTLiveClockConfig.node = mw.util.addPortletLink(
		portletId,
		wgScript + '?title=' + encodeURIComponent( wgPageName ) + '&action=purge',
		'',
		'utcdate',
		undefined,
		undefined,
		nextNode
	);
	if( !CSTLiveClockConfig.node ) {
		return;
	}

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

} )( jQuery );