1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| let newYearTimer = null; var newYear = () => { clearTimeout(newYearTimer); if (!document.querySelector('#newYear')) return; let newYear = new Date('2023-01-22 00:00:00').getTime() / 1000, week = { 0: '周日', 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六' }
time();
function nol(h) { return h > 9 ? h : '0' + h; };
function time() { let now = new Date();
document.querySelector('#newYear .today').innerHTML = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + ' ' + week[now.getDay()]
let second = newYear - Math.round(now.getTime() / 1000);
if (second < 0) { document.querySelector('#newYear .title').innerHTML = 'Happy New Year!'; document.querySelector('#newYear .newYear-time').innerHTML = '<span class="happyNewYear">新年快乐</p>'; } else { document.querySelector('#newYear .title').innerHTML = '距离2023年春节:'
if (second > 86400) { document.querySelector('#newYear .newYear-time').innerHTML = `<span class="day">${Math.ceil(second / 86400)}<span class="unit">天</span></span>` } else { let h = nol(parseInt(second / 3600)); second %= 3600; let m = nol(parseInt(second / 60)); second %= 60; let s = nol(second); document.querySelector('#newYear .newYear-time').innerHTML = `<span class="time">${h}:${m}:${s}</span></span>`; newYearTimer = setTimeout(time, 1000); } } }
jQuery(document).ready(function ($) { $('#newYear').wpSuperSnow({ flakes: ['https://tuchuang.voooe.cn/images/2023/01/02/yb1.webp', 'https://tuchuang.voooe.cn/images/2023/01/02/yb2.webp', 'https://tuchuang.voooe.cn/images/2023/01/02/yb3.webp'], totalFlakes: '100', zIndex: '999999', maxSize: '30', maxDuration: '20', useFlakeTrans: false }); }); }
document.addEventListener('pjax:complete', newYear); document.addEventListener('DOMContentLoaded', newYear);
|