本WIKI为帮助各位传承者,更好的游玩斗罗大陆:逆转时空而建立,现处于建设中
来自斗罗大陆:逆转时空
Vickyhh讨论 | 贡献2024年4月28日 (日) 16:13的版本 (创建页面,内容为“try { eventTimers; } catch (e) { eventTimers = document.getElementsByClassName("eventTimer"); function eventTimerRun() { let nowBJ = new Date(new Date() - (8 + new Date().getTimezoneOffset() / 60) * 60 * 60 * 1000); for (let i = 0; i < eventTimers.length; i++) { let start = eventTimers[i].dataset.start.replace("%", ""); start = parseInt(start).toString() === start ? new Date(parseInt(start)) : new Date(start);…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
try {
    eventTimers;
} catch (e) {
    eventTimers = document.getElementsByClassName("eventTimer");
    function eventTimerRun() {
        let nowBJ = new Date(new Date() - (8 + new Date().getTimezoneOffset() / 60) * 60 * 60 * 1000);
        for (let i = 0; i < eventTimers.length; i++) {
            let start = eventTimers[i].dataset.start.replace("%", "");
            start = parseInt(start).toString() === start ? new Date(parseInt(start)) : new Date(start);
            let end = eventTimers[i].dataset.end.replace("%", "");
            end = parseInt(end).toString() === end ? new Date(parseInt(end)) : new Date(end);
            let info = eventTimers[i].dataset.info;
            let str = "距离" + info;
            let timeD = "";
            if (start > nowBJ) {
                timeD = start - nowBJ;
                str += "开始还有";
            } else if (end < nowBJ) {
                timeD = nowBJ - end;
                str += "结束已经过去";
            } else {
                timeD = end - nowBJ;
                str += "结束还有";
            }
            let format = dhms(timeD);
            if (format[0] > 0) {
                str += "<b>" + format[0] + "</b>天";
            }
            if (format[1] > 0) {
                str += "<b>" + format[1] + "</b>时";
            }
            if (format[2] > 0) {
                str += "<b>" + format[2] + "</b>分";
            }
            // str+=format[3]+"秒"
            eventTimers[i].innerHTML = str;
        }
    }
    function dhms(timeD) {
        let day = Math.floor(timeD / 1000 / 60 / 60 / 24);
        timeD -= day * 1000 * 60 * 60 * 24;
        let hour = Math.floor(timeD / 1000 / 60 / 60);
        timeD -= hour * 1000 * 60 * 60;
        let minute = Math.floor(timeD / 1000 / 60);
        timeD -= minute * 1000 * 60;
        let second = Math.floor(timeD / 1000);
        return [day, hour, minute, second];
    }
    setInterval(eventTimerRun, 1000);
}