This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,35 @@
define([], function () {
'use strict';
return function (config, element) {
var end = new Date(element.getAttribute('data-end')).getTime();
var timer;
function setValue(unit, value) {
var target = element.querySelector('[data-time="' + unit + '"]');
if (target) {
target.textContent = String(Math.max(0, value)).padStart(2, '0');
}
}
function update() {
var distance = Math.max(0, end - Date.now());
setValue('days', Math.floor(distance / 86400000));
setValue('hours', Math.floor((distance % 86400000) / 3600000));
setValue('minutes', Math.floor((distance % 3600000) / 60000));
setValue('seconds', Math.floor((distance % 60000) / 1000));
if (distance === 0 && timer) {
window.clearInterval(timer);
}
}
if (!Number.isFinite(end)) {
return;
}
update();
timer = window.setInterval(update, 1000);
};
});