(// Edit via Wikiplus) |
小 (自User:Rpuboh/沙盒2合并Rpuboh的版本54449) |
||
第1行: | 第1行: | ||
<noinclude>仅供{{tl|Second Countdown}}使用。{{doc}}</noinclude><includeonly><!--{if !isset($wgCountdown) || !$wgCountdown}--><!--{assign var="wgCountdown" value=true scope="global"}--><script> |
<noinclude>仅供{{tl|Second Countdown}}使用。{{doc}}</noinclude><includeonly><!--{if !isset($wgCountdown) || !$wgCountdown}--><!--{assign var="wgCountdown" value=true scope="global"}--><script> |
||
window.RLQ ||= []; |
window.RLQ ||= []; |
||
window.RLQ.push( |
window.RLQ.push([["jquery", "moment"], function widgetCountdown(require) { |
||
"use strict"; |
|||
⚫ | |||
return new Promise((resolve, reject) => { |
|||
let time = 0; |
|||
const mwReadyTimer = setInterval(() => { |
|||
time++; |
|||
if (typeof mw === 'object' && typeof mw.loader?.using === 'function') { |
|||
clearInterval(mwReadyTimer); |
|||
resolve(true); |
|||
} else if (time > 3000) { |
|||
clearInterval(mwReadyTimer); |
|||
reject(false); |
|||
} |
|||
}, 0); |
|||
}); |
|||
} |
|||
await mwReady(); // wait methods to be ready |
|||
const require = await mw.loader.using('moment'); |
|||
⚫ | |||
const fromNow = (then, before, after, on) => { |
const fromNow = (then, before, after, on) => { |
||
const now = moment(); |
const now = moment(); |
||
第108行: | 第92行: | ||
run(); |
run(); |
||
window.setInterval(run, 1000); |
window.setInterval(run, 1000); |
||
}); |
}]); |
||
</script><!--{/if}--></includeonly> |
</script><!--{/if}--></includeonly> |