مستخدم:Salam32/friendlyclock.js
![]() | يمكن توفير توثيق لسكربت المستخدم هذا في الصفحة : مستخدم:Salam32/friendlyclock. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
// If FriendlyConfig aint exist.
if( typeof( FriendlyConfig ) == 'undefined' ) {
FriendlyConfig = {};
}
/**
FriendlyConfig.enableClock ( boolean )
*/
if( typeof( FriendlyConfig.enableClock ) == 'undefined' ) {
FriendlyConfig.enableClock = true;
}
/**
FriendlyConfig.clockStyle ( String )
*/
if( typeof( FriendlyConfig.clockStyle ) == 'undefined' ) {
FriendlyConfig.clockStyle = 'dynamic';
}
friendlyclock = {
showClock: function() {
var query = {
'action': 'purge',
'title': wgPageName
};
friendlyclock.clockNode = mw.util.addPortletLink( 'p-personal', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), '--:--:-- UTC', 'friendly-clock', 'نظّف هذه الصفحة', '' );
friendlyclock.clockNode.style.fontSize = 'normal';
friendlyclock.clockNode.style.textTransform = 'uppercase';
friendlyclock.updateTime();
if( FriendlyConfig.clockStyle != 'static' ) {
friendlyclock.intervalId = window.setInterval(friendlyclock.updateTime, 1000);
}
},
updateTime: function() {
var dateNode = friendlyclock.clockNode;
if(!dateNode) {
return;
}
var now = new Date();
var stabilizer = now.getUTCMilliseconds()/10;
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 ) + '، ' + now.getUTCDate() + ' ' + ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"][now.getUTCMonth()] + ' ' + now.getUTCFullYear() + ' (UTC)';
dateNode.firstChild.replaceChild(document.createTextNode(time), dateNode.firstChild.firstChild);
friendlyclock.clockNode.firstChild.innerHTML = time;
}
}
$( function() {
if( FriendlyConfig.enableClock ) {
friendlyclock.showClock();
}
}
);