From 29e64767009c3cb2be7113775adbe1cfae9293a9 Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sun, 6 Sep 2026 19:43:05 +0200 Subject: [PATCH] feat: Exakte Reset-Uhrzeit rechts unter Prozentzahl bei AG und MiniMax --- public/app.js | 39 +++++++++++++++++++++++++++++---------- public/index.html | 6 ++++++ public/style.css | 7 +++++++ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/public/app.js b/public/app.js index 7a3a05e..f5f0c7f 100644 --- a/public/app.js +++ b/public/app.js @@ -78,21 +78,38 @@ function updateRow(providerId, quota) { } // Detail text - const detailsId = `details-${quota.provider.toLowerCase().replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '')}`; + const providerId = quota.provider.toLowerCase().replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, ''); + const detailsId = `details-${providerId}`; const detailsEl = document.getElementById(detailsId); + const resetTimeEl = document.getElementById(`reset-time-${providerId}`); + + // Formats a timestamp as "Heute 14:30", "Morgen 09:00" or "Mo. 14:30" + function formatResetTime(ms) { + if (!ms) return ''; + const d = new Date(ms); + const now = new Date(); + const todayStr = now.toDateString(); + const tomorrowStr = new Date(now.getTime() + 86400000).toDateString(); + const timeStr = d.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' }); + if (d.toDateString() === todayStr) return `Heute ${timeStr}`; + if (d.toDateString() === tomorrowStr) return `Morgen ${timeStr}`; + const dayStr = d.toLocaleDateString('de-DE', { weekday: 'short' }); + return `${dayStr} ${timeStr}`; + } if (quota.provider.startsWith('MiniMax') && quota.meta) { statusText.innerText = `${Math.round(quota.used)}% / 100%`; - if (detailsEl) { - const resetTs = quota.meta.reset; - const targetMs = (typeof resetTs === 'number' && resetTs < 9999999999) ? resetTs * 1000 : resetTs; - const countdownId = `countdown-${detailsId}`; + const resetTs = quota.meta.reset; + const targetMs = (typeof resetTs === 'number' && resetTs < 9999999999) ? resetTs * 1000 : resetTs; + const countdownId = `countdown-${detailsId}`; + if (resetTimeEl) resetTimeEl.innerText = formatResetTime(targetMs); + + if (detailsEl) { if (quota.provider.includes('5h')) { detailsEl.innerHTML = `
Reset in: --:--:--
`; if (targetMs) startCountdown(countdownId, targetMs); } else { - // Weekly: show countdown if in the future, else formatted date if (targetMs && targetMs > Date.now()) { detailsEl.innerHTML = `
Reset in: --:--:--
`; startCountdown(countdownId, targetMs); @@ -104,11 +121,13 @@ function updateRow(providerId, quota) { } } else if (quota.provider.startsWith('AG ') && quota.meta) { statusText.innerText = `${Math.round(quota.used)}% / 100%`; - if (detailsEl) { - const resetTs = quota.meta.resetTime; - const targetMs = resetTs ? new Date(resetTs).getTime() : null; - const countdownId = `countdown-${detailsId}`; + const resetTs = quota.meta.resetTime; + const targetMs = resetTs ? new Date(resetTs).getTime() : null; + const countdownId = `countdown-${detailsId}`; + if (resetTimeEl) resetTimeEl.innerText = formatResetTime(targetMs); + + if (detailsEl) { if (targetMs && targetMs > Date.now()) { detailsEl.innerHTML = `
Reset in: --:--:--
`; startCountdown(countdownId, targetMs); diff --git a/public/index.html b/public/index.html index 1de63c6..0a70749 100644 --- a/public/index.html +++ b/public/index.html @@ -74,6 +74,7 @@
0% Loading... +
@@ -96,6 +97,7 @@
0% Loading... +
@@ -118,6 +120,7 @@
0% Loading... +
@@ -140,6 +143,7 @@
0% Loading... +
@@ -162,6 +166,7 @@
0% Loading... +
@@ -184,6 +189,7 @@
0% Loading... +
diff --git a/public/style.css b/public/style.css index 62beb94..a2f63ac 100644 --- a/public/style.css +++ b/public/style.css @@ -201,6 +201,13 @@ header p { color: var(--text-muted); } +.reset-time { + font-size: 0.78em; + color: var(--text-muted); + opacity: 0.75; + font-variant-numeric: tabular-nums; +} + .charts { background-color: var(--row-bg); border: 1px solid var(--row-border);