LLWiki正在建设中,欢迎加入我们

“Widget:Countdown”的版本间差异

跳转到导航 跳转到搜索
window.addEventListener('load', function () {
var timeObj = {};
const fromNow = function (then, before, afterele) {
const now = moment();,
const isBefore = then.isBefore = moment(nowele.dataset.target);,
before = ele.children[1],
const monthsHave31Days = [0, 2, 4, 6, 7, 9, 11]; // 月份从0开始
after = ele.children[2],
isBefore = then.isBefore(now),
const monthsHave31Days = [0, 2, 4, 6, 7, 9, 11]; // 月份从0开始
let year = isBefore ? now.year() - then.year() : then.year() - now.year(),
month = isBefore ? now.month() - then.month() : then.month() - now.month(),
}
if (hour > 0) {
result += `<span class="countdown-num">${hour}</` + 'span>小时' + ele.children[0].innerHTML;
} else if (result !== "") {
result += `<span class="countdown-num">${0}</` + 'span>小时' + ele.children[0].innerHTML;
}
if (minute > 0) {
result += `<span class="countdown-num">${0}</` + 'span>秒';
}
return if(isBefore ? before : after).replace("$1", result.replace(/(\d) /g, "$1"));{
before.innerHTML = before.innerHTML.replace("$1", result.replace(/(\d) /g, "$1"));
after.style.display = "none";
});
else {
afet.innerHTML = after.innerHTML.replace("$1", result.replace(/(\d) /g, "$1"));
before.style.display = "none";
}
};
const run = () => {
document.querySelectorAll(".countdownNode:not(.disabled)").forEach( fromNow(ele) => {);
ele.innerHTML = fromNow(timeObj[ele.id], ele.dataset.before || "$1前", ele.dataset.after || "还剩$1");
});
};
document.querySelectorAll(".countdownNode").forEach((ele) => {