Gadget:Xb3countdown.js
来自乐园数据管理室
var target = 1659020400000;
function getDiff() {
return target - new Date().getTime();
}
function format(ts) {
if (ts > 0) {
var days = Math.floor(ts / 1000 / 3600 / 24);
var hours = Math.floor((ts / 1000 / 3600) % 24);
var minutes = String(Math.floor((ts / 1000 / 60) % 60)).padStart(2, "0");
var seconds = String(Math.floor((ts / 1000) % 60)).padStart(2, "0");
return days + " 天 " + hours + " 时 " + minutes + " 分 " + seconds + " 秒";
} else {
return '<a class="external text" target="_blank" href="https://3.xenoblade.cn">异度神剑3资料站项目启动</a>'
}
}
function start(el) {
el.innerHTML = format(getDiff());
setInterval(function () {
el.innerHTML = format(getDiff());
}, 1000);
}
var el = $("#xb3countdown");
if (el.length) {
start(el[0]);
}