Admin留言 | 贡献
无编辑摘要
标签已被回退
Admin留言 | 贡献
无编辑摘要
 
(未显示同一用户的11个中间版本)
第1行: 第1行:
// 引入jQuery计时器插件[6](@ref)
// 引入jQuery计时器插件[6](@ref)
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');
function startTimer(duration, display) {
    var timer = duration, days, hours, minutes, seconds;
    setInterval(function() {
        days = Math.floor(timer / (60 * 60 * 24));
        hours = Math.floor((timer % (60 * 60 * 24)) / (60 * 60));
        minutes = Math.floor((timer % (60 * 60)) / 60);
        seconds = Math.floor(timer % 60);


        display.textContent = days + "天 " + hours + ":" + minutes + ":" + seconds;
// 维护开始时间戳(2025-04-05 03:00:00 UTC)
        if (--timer < 0) timer = duration;
// 维护开始时间(示例:2020-09-01 00:00:00 UTC)
     }, 1000);
const startTimestamp = 1743793200;
 
function updateMaintenanceTimer() {
    const now = Math.floor(Date.now() / 1000); // 当前时间戳(秒)
    const duration = now - startTimestamp;
 
    // 计算天、小时、分钟
    const days = Math.floor(duration / 86400);
    const hours = Math.floor((duration % 86400) / 3600);
    const minutes = Math.floor((duration % 3600) / 60);
    const seconds = duration % 60;
 
    // 更新页面显示
    const timerElement = document.getElementById("maintenance-timer");
    if (timerElement) {
        timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`;
     }
}
}
// 初始化30天倒计时
 
window.onload = function() {
// 首次加载更新
    var thirtyDays = 30 * 24 * 60 * 60,
updateMaintenanceTimer();
        display = document.querySelector('#timer');
// 每秒刷新
    startTimer(thirtyDays, display);
setInterval(updateMaintenanceTimer, 1000);
};