MediaWiki:Common.js:修订间差异
外观
无编辑摘要 |
无编辑摘要 |
||
第4行: | 第4行: | ||
// 维护开始时间戳(2025-04-05 03:00:00 UTC) | // 维护开始时间戳(2025-04-05 03:00:00 UTC) | ||
// MediaWiki:Common.js (安全增强版) | // MediaWiki:Common.js (安全增强版) | ||
'use strict'; | |||
'use strict'; | |||
const startTimestamp = 1743793200; | const startTimestamp = 1743793200; | ||
第23行: | 第24行: | ||
} | } | ||
// | // 更新页面显示 | ||
const timerElement = document.getElementById("maintenance-timer"); | |||
if (timerElement) { | |||
} | timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`; | ||
} | |||
} | } | ||
// 首次加载更新 | |||
updateMaintenanceTimer(); | |||
// 每秒刷新 | |||
setInterval(updateMaintenanceTimer, 1000); |
2025年4月13日 (日) 07:40的版本
// 引入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)
// MediaWiki:Common.js (安全增强版)
'use strict';
const startTimestamp = 1743793200;
function updateMaintenanceTimer() {
const safeElement = document.getElementById("maintenance-timer");
if (!safeElement) return;
const now = Math.floor(Date.now() / 1000);
const duration = now - startTimestamp;
// 使用模板字符串防止注入
safeElement.textContent = `距离本赛季已维护${
Math.floor(duration / 86400)}天${
Math.floor((duration % 86400) / 3600)}时${
Math.floor((duration % 3600) / 60)}分${
duration % 60}秒`;
}
// 更新页面显示
const timerElement = document.getElementById("maintenance-timer");
if (timerElement) {
timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`;
}
}
// 首次加载更新
updateMaintenanceTimer();
// 每秒刷新
setInterval(updateMaintenanceTimer, 1000);