跳转到内容

User:Liangent/Gadgets/Toolkit/onlinestatus.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// '''Compressed version''' // [[User:Liangent/Gadgets/Toolkit/onlinestatus.uncompressed.js|Uncompressed version]] //

require(['jquery','jquery_cookie','mediawiki'],function(){(function($){$(function(){var cookieName='zhwiki_online_status_'+encodeURIComponent(wgUserName);var cookieLife=5844;var statusCodePage=new MediaWiki.Page('User:'+wgUserName+'/OnlineStatus/Code');var statusCodeText='{\{#ifexpr:{\{#time:U}}-{\{subst:#time:U}}<120|+|-}}';var defaultStatus='hidden';function update(){if($.cookie(cookieName)=='online'){statusCodePage.text({text:statusCodeText},undefined,update);}}
function updateStatus(){setTimeout(updateStatus,60000);update();}
function updateDisplay(){$('#pt-switchstatus').remove();if($.cookie(cookieName)==null){$.cookie(cookieName,defaultStatus,{expires:cookieLife,path:'/'});}
if($.cookie(cookieName)=='online'){$('#pt-userpage').after('<li id="pt-switchstatus">'+'<a href="#" title="Switch to Hidden [`]" accesskey="`">'+'(Online)</a></li>');$('#pt-switchstatus a').click(function(event){event.preventDefault();$.cookie(cookieName,'hidden',{expires:cookieLife,path:'/'});updateDisplay();});}else if($.cookie(cookieName)=='hidden'){$('#pt-userpage').after('<li id="pt-switchstatus">'+'<a href="#" title="Switch to Online [`]" accesskey="`">'+'(Hidden)</a></li>');$('#pt-switchstatus a').click(function(event){event.preventDefault();$.cookie(cookieName,'online',{expires:cookieLife,path:'/'});updateDisplay();update();});}}
function updateUI(){setTimeout(updateUI,10000);updateDisplay();}
updateStatus();updateUI();});})(jQuery);});