无编辑摘要 |
无编辑摘要 |
||
第2行: | 第2行: | ||
mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js'); | mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js'); | ||
// 维护开始时间(示例:2020-09-01 00:00:00 UTC) | // 维护开始时间(示例:2020-09-01 00:00:00 UTC) | ||
const | // 活动截止时间戳(2025-04-23 23:59:00 UTC+8) | ||
const endTimestamp = Date.parse("2025-04-23T23:59:00+08:00"); | |||
function | function updateCountdown() { | ||
const now = | const now = new Date().getTime(); | ||
const duration = now | const duration = endTimestamp - now; | ||
if (duration <= 0) { | |||
document.getElementById("timer").innerText = "活动已结束"; | |||
return; | |||
} | |||
// | const days = Math.floor(duration / (1000 * 60 * 60 * 24)); | ||
const | const hours = Math.floor((duration % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60)); | |||
const seconds = Math.floor((duration % (1000 * 60)) / 1000); | |||
document.getElementById("timer").innerText = | |||
`距离全角色限免结束还有${days}天${hours}时${minutes}分${seconds}秒`; | |||
} | } | ||
// | // 每秒更新一次 | ||
setInterval(updateCountdown, 1000); | |||
setInterval( |