modified: app.py
modified: templates/itemeditor_command_storage.html
This commit is contained in:
@@ -547,25 +547,30 @@ function startCountdown(expiresAt) {
|
||||
const expiryTime = document.getElementById('expiryTime');
|
||||
const endTime = new Date(expiresAt).getTime();
|
||||
|
||||
// If expiry is in the past, show expired immediately
|
||||
if (endTime < new Date().getTime()) {
|
||||
expiryTime.innerHTML = '<span style="color: #ff5555;">Expired</span>';
|
||||
return;
|
||||
}
|
||||
|
||||
const interval = setInterval(() => {
|
||||
// Update countdown immediately
|
||||
function updateCountdown() {
|
||||
const now = new Date().getTime();
|
||||
const distance = endTime - now;
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(interval);
|
||||
expiryTime.innerHTML = '<span style="color: #ff5555;">Expired</span>';
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||
expiryTime.textContent = `${minutes}m ${seconds}s`;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update immediately
|
||||
if (!updateCountdown()) return;
|
||||
|
||||
// Then update every second
|
||||
const interval = setInterval(() => {
|
||||
if (!updateCountdown()) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user