跳转到内容
该网站目前正在建设进行中,如果您想提供帮助,请查看入门指南。如果你会wiki编辑语法,注册后即可开始编辑创建内容。

MediaWiki:Common.js:修订间差异

来自流放之路2Wiki
Admin留言 | 贡献
无编辑摘要
Admin留言 | 贡献
无编辑摘要
标签已被回退
第27行: 第27行:
// 每秒刷新
// 每秒刷新
setInterval(updateMaintenanceTimer, 1000);
setInterval(updateMaintenanceTimer, 1000);
// 动态加载{{CSS}}模板嵌入的样式
$(document).ready(function() {
    $('.css-embed').each(function() {
        var cssContent = $(this).text();
        $('<style>').text(cssContent).appendTo('head');
    });
});

2025年4月24日 (四) 13:24的版本

// 引入jQuery计时器插件[6](@ref)
mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js');

// 维护开始时间戳(2025-04-05 03:00:00 UTC)
// 维护开始时间(示例:2020-09-01 00:00:00 UTC)
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}秒`;
    }
}

// 首次加载更新
updateMaintenanceTimer();
// 每秒刷新
setInterval(updateMaintenanceTimer, 1000);

// 动态加载{{CSS}}模板嵌入的样式
$(document).ready(function() {
    $('.css-embed').each(function() {
        var cssContent = $(this).text();
        $('<style>').text(cssContent).appendTo('head');
    });
});