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 = `