“File:最常见的单孔处女膜.jpeg”与“MediaWiki:Gadget-Purgecache.js”:页面之间的差异
(页面间差异)
跳到导航
跳到搜索
创建页面,内容为“// <pre> $(function(){ mw.loader.using("moment").then(function() { var li = $('<li/>').appendTo("#p-personal > ul"), textNode = $('<span/>'),…”
imported>DavidYin (最常见的单孔处女膜) |
imported>=海豚= (创建页面,内容为“// <pre> $(function(){ mw.loader.using("moment").then(function() { var li = $('<li/>').appendTo("#p-personal > ul"), textNode = $('<span/>'),…”) |
||
第1行: | 第1行: | ||
== | // <pre> | ||
$(function(){ | |||
mw.loader.using("moment").then(function() { | |||
var li = $('<li/>').appendTo("#p-personal > ul"), | |||
textNode = $('<span/>'), | |||
containerNode; | |||
if (mw.config.get('wgNamespaceNumber') === -1) { | |||
containerNode = $('<span/>'); | |||
containerNode.css({ | |||
'cursor': 'default', | |||
'user-select': 'none' | |||
}); | |||
containerNode.append('特殊页面(').append(textNode).append(')'); | |||
} else { | |||
containerNode = $('<a/>'); | |||
var statusNode = $('<span/>').text('强制刷新页面'), | |||
runningStatus = false; | |||
containerNode.attr("href", 'javascript:void(0);'); | |||
containerNode.append(statusNode).append('(').append(textNode).append(')'); | |||
containerNode.on('click', function() { | |||
if (runningStatus) return; | |||
statusNode.text('正在强制刷新页面……'); | |||
statusNode.prepend('<img src="https://static.mengniang.org/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">'); | |||
runningStatus = true; | |||
var api = new mw.Api(), | |||
opt = { | |||
action: 'purge', | |||
format: 'json', | |||
forcelinkupdate: true, | |||
titles: mw.config.get('wgPageName') | |||
}; | |||
api.post(opt).then(function() { | |||
setTimeout(function() { | |||
api.post(opt).then(function() { | |||
statusNode.text('强制刷新页面成功!'); | |||
setTimeout(location.reload.bind(location), 1000); | |||
}, function() { | |||
statusNode.text('强制刷新页面失败,点击可重试!'); | |||
runningStatus = false; | |||
setTimeout(function() { | |||
if (!runningStatus) statusNode.text('强制刷新页面'); | |||
}, 5000); | |||
}); | |||
}, 370); | |||
}, function() { | |||
statusNode.text('强制刷新页面失败,点击可重试!'); | |||
runningStatus = false; | |||
setTimeout(function() { | |||
if (!runningStatus) statusNode.text('强制刷新页面'); | |||
}, 5000); | |||
}); | |||
}); | |||
} | |||
li.append(containerNode); | |||
textNode.text(moment().format('A h[:]mm[:]ss')); | |||
var date = new Date(); | |||
var now = date.getTime(); | |||
date.setMilliseconds(0); | |||
date.setSeconds(date.getSeconds() + 1); | |||
setTimeout(function() { | |||
setInterval(function() { | |||
textNode.text(moment().format('A h[:]mm[:]ss')); | |||
}, 1e3); | |||
textNode.text(moment().format('A h[:]mm[:]ss')); | |||
}, date.getTime() - now); | |||
}); | |||
}); | |||
// </pre> |