有兽档案馆
搜索
切换搜索
切换菜单
切换个人菜单
查看“Widget:Countdown”的源代码
来自有兽档案馆
更多语言
阅读
查看源代码
查看历史
微件
讨论
更多操作
←
Widget:Countdown
因为以下原因,您没有权限编辑该页面:
您所请求的操作,仅限具有
注册用户
、
自动确认用户
、
管理员
、
界面管理员
、
优质编辑者
、
确认用户
、
巡查员
、
档案理事员
等
权限
的
用户
执行。
若您尚未登录有兽档案馆账号,请您
登录
有兽档案馆账号后操作。
您没有权限编辑
Widget
命名空间内的页面。
您尚未完成电子邮件确认,因此操作受限,请尽快
完成电子邮件确认
。
若您无法完成前述手续,请通过适当渠道请求管理员或档案理事员协助。
您可以查看和复制此页面的源代码。
若您无权编辑本页面,您可以
提出编辑请求
,提请有权限者代为编辑。
<noinclude>仅供{{tl|Second Countdown}}使用。{{doc}}</noinclude><includeonly><!--{if !isset($wgCountdown) || !$wgCountdown}--><!--{assign var="wgCountdown" value=true scope="global"}--><script> window.RLQ ||= []; window.RLQ.push([["jquery", "moment"], function widgetCountdown(require) { "use strict"; const moment = require("moment"); const fromNow = (then, before, after, on) => { const now = moment(); const 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(), day = isBefore ? now.date() - then.date() : then.date() - now.date(), hour = isBefore ? now.hour() - then.hour() : then.hour() - now.hour(), minute = isBefore ? now.minute() - then.minute() : then.minute() - now.minute(), second = isBefore ? now.second() - then.second() : then.second() - now.second(); if (second<0) { minute--; second += 60; } if (minute<0) { hour--; minute += 60; } if (hour<0) { day--; hour += 24; } if (day<0) { month--; if (monthsHave31Days.includes((isBefore ? then : now).month())) { day += 31; } else if ((isBefore ? then : now).month() === 1) { if ((isBefore ? then : now).year() % 4 === 0) { day += 29; } else { day += 28; } } else { day += 30; } } if (month<0) { year--; month += 12; } let result = ''; if (year>0) { result += `${year}年`; } if (month>0) { result += `${month}月`; } else if (result !== '') { result += `${0}月`; } if (day>0) { result += `${day}日`; } else if (result !== '') { result += `${0}日`; } if (hour>0) { result += `${hour}小时`; } else if (result !== '') { result += `${0}小时`; } if (minute>0) { result += `${minute}分`; } else if (result !== '') { result += `${0}分`; } if (second>0) { result += `${second}秒`; } else if (result !== '') { result += `${0}秒`; } return (result === '' ? on : isBefore ? before : after).replace('$1', result.replace(/(\d) /g, '$1')); }; const run = () => { $(".countdownNode:not(.disabled)").each((_, ele) => { const self = $(ele); self.text(fromNow(self.data("target"), ele.dataset.before || "$1前", ele.dataset.after || "还剩$1", ele.dataset.on || "就是现在!")); }); }; $(".countdownNode").each((_, ele) => { const self = $(ele), time = moment(ele.dataset.target); if (!time || !time.isValid()) { self.addClass("error disabled").text("(发生了致命错误!)"); return; } self.data("target", time); }); run(); window.setInterval(run, 1000); }]); </script><!--{/if}--></includeonly>
该页面使用的模板:
Template:Doc
(
查看源代码
)
Template:Documentation
(
查看源代码
)
Template:Tl
(
查看源代码
)
Module:Arguments
(
查看源代码
)
Module:Documentation
(
查看源代码
)
Module:Fullurl
(
查看源代码
)
Module:No globals
(
查看源代码
)
Module:Page name
(
查看源代码
)
Module:Tl
(
查看源代码
)
Module:Yesno
(
查看源代码
)
返回
Widget:Countdown
。