مدیاویکی:Gadget-UTCLiveClock.js

ویکی‌پدیادان، آچیق بیلیک‌لیک‌دن

' 'قئید:' یازدیق‌دان سونرا دییشیک‌لیک‌لری گؤرمک اوچون براوزئرینیزین کئش یادداشیندا تمیزلمه‌نیز لازیم اولا بیلر.

  • 'فایرفاکس / سافاری:Shift دویمه‌سینه باسین "یئنی‌دن یوکله"-ا داخیل اولون یا دا Ctrl-F5 یا Ctrl-R ائدین (ماج اوچون ⌘-R).
  • 'گووگل کروم:'Ctrl+Shift+R باسین. (ماج اوچون ⌘-Shift-R)
  • 'اینترنت ایکسپئلور: کلید Ctrl باسین یئنی‌لئ 'یئ داخیل اولون یا دا Ctrl-F5 ائدین.
  • 'اوپئرا:' آلت‌لری → سئچیملر 'دن اؤنبئللیغی Tools → Preferences تمیزلیین.
/* Warning! Global gadget file! */
( function( $, undefined ) {
 
var $target;
 
function showTime( $target ) {
	var dateNode = UTCLiveClockConfig.node;
	if( !dateNode ) {
		return;
	}
 
	var now = new Date();
	var hh = now.getUTCHours();
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	if ( $target === undefined ) {
		$target = $( dateNode ).find( 'a:first' );
	}
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
        time  = time .replace(/1/g, "۱").replace(/2/g, "۲").replace(/3/g, "۳").replace(/4/g, "۴").replace(/5/g, "۵");
        time  = time .replace(/6/g, "۶").replace(/7/g, "۷").replace(/8/g, "۸").replace(/9/g, "۹").replace(/0/g, "۰")+'دونیاسال ساعات';
	$target.text( time );
 
	setTimeout( function(){
		showTime( $target );	
	}, 1000 );
}
 
function liveClock() {
	//mw.util.addCSS( '#utcdate a { font-weight:bolder; }' );
 
	if ( window.UTCLiveClockConfig === undefined ) {
		window.UTCLiveClockConfig = {};
	}
	var portletId = UTCLiveClockConfig.portletId || 'p-personal';
	var nextNode = UTCLiveClockConfig.nextNodeId ? document.getElementById( UTCLiveClockConfig.nextNodeId ) : ( document.getElementById( 'pt-flyout' ) || undefined );
	UTCLiveClockConfig.node = mw.util.addPortletLink(
		portletId,
		mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( mw.config.get('wgPageName') ) + '&action=purge',
		'',
		'utcdate',
		undefined,
		undefined,
		nextNode
	);
	if( !UTCLiveClockConfig.node ) {
		return;
	}
 
	showTime();
}
$( document ).ready( liveClock );
 
} )( jQuery );