LLWiki正在建设中,欢迎加入我们!
“Widget:Countdown”的版本间差异
跳转到导航
跳转到搜索
标签:撤销 |
小 |
||
<noinclude>{{doc|content={{CCnotice|MGP=widget:countdown}}
请使用{{tl|countdown}}调用。}}</noinclude><includeonly><!--{if !isset($wgCountdown) || !$wgCountdown}--><!--{assign var="wgCountdown" value=true scope="global"}--
//</includeonly>JavaScript脚本:<pre lang=js>
"use strict";
window.addEventListener('load', function () {
const fromNow = function (ele) {
let now =
then =
before = ele.children[0],
after = ele.children[1],
i18n = ele.dataset.title,
isBefore =
monthsHave31Days = [0, 2, 4, 6, 7, 9, 11], // 月份从0开始
year = isBefore ? now.
month = isBefore ? now.
day = isBefore ? now.
hour = isBefore ? now.
minute = isBefore ? now.
second = isBefore ? now.
result = "";
if (second < 0) {
if (day < 0) {
month--;
if (monthsHave31Days.includes( (isBefore ? then : now).
else if ((isBefore ? then : now).
if ((isBefore ? then : now).
else { day += 28; }
}
month += 12;
}
if (year > 0) { result += `<span class="countdown-num">${year}</
if (month > 0) { result += `<span class="countdown-num">${month}</
else if (result !== "") { result += `<span class="countdown-num">
if (day > 0) { result += `<span class="countdown-num">${day}</
else if (result !== "") { result += `<span class="countdown-num">
if(year == 0 && month == 0) {
if (hour > 0) { result += `<span class="countdown-num">${hour}</
else if (result !== "") { result += `<span class="countdown-num">
if(day == 0) {
if (minute > 0) { result += `<span class="countdown-num">${minute}</
else if (result !== "") { result += `<span class="countdown-num">
if (second > 0) { result += `<span class="countdown-num">${second}</
else if (result !== "") { result += `<span class="countdown-num">
}
}
};
document.querySelectorAll( '.countdownNode' ).forEach((ele) => {
const time =
if (
ele.classList.add("error", "disabled")
ele.textContent = "(时间格式错误!)";
|