跳转到内容

User:Liangent/Gadgets/Toolkit/clock.js

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

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

// '''Compressed version''' // [[User:Liangent/Gadgets/Toolkit/clock.uncompressed.js|Uncompressed version]] //

require(['jquery','mediawiki'],function(){jQuery(function(){var serverTimeDelta;var atag=jQuery('#pt-userpage').parent().append('<li id="pt-utcclock"><a href="'+wgScript+'?action=purge&title='+encodeURIComponent(wgPageName)+'" title="Purge server cache">Loading...</a></li>').find('#pt-utcclock a');function updateClockDisplay(){function formatDate(date){var h=date.getUTCHours();var m=date.getUTCMinutes();var s=date.getUTCSeconds();return(h<10?'0'+h:h)+':'+
(m<10?'0'+m:m)+':'+
(s<10?'0'+s:s)+' UTC';}
var date=new Date();date.setTime(date.getTime()+serverTimeDelta);atag.text(formatDate(date));setTimeout(updateClockDisplay,1000);}
MediaWiki.currentTime({},function(date){serverTimeDelta=date-new Date();updateClockDisplay();},function(){serverTimeDelta=0;jQuery('#pt-utcclock').append('<small>(<abbr title="Local machine">LM</abbr>)</small>');updateClockDisplay();});});});