diff --git a/index.html b/index.html index 9753a6d..2a27395 100644 --- a/index.html +++ b/index.html @@ -9133,12 +9133,26 @@ ${vpnBadgeTopo} const usageStr = lim.usage_bytes_str || formatBytes(usageBytes); let qVal = parseFloat($('inputQuotaValue') ? $('inputQuotaValue').value : 0) || 0; - const qUnit = $('selectQuotaUnit') ? $('selectQuotaUnit').value : 'GB'; - const qBytes = qUnit === 'GB' ? Math.round(qVal * 1073741824) : Math.round(qVal * 1048576); + const unit = $('selectQuotaUnit') ? $('selectQuotaUnit').value : 'GB'; + let mult = 1073741824; + if (unit === 'MB') mult = 1048576; + else if (unit === 'TB') mult = 1099511627776; + const quotaBytes = qVal * mult; - const exceeded = qBytes > 0 && usageBytes >= qBytes; - const pct = qBytes > 0 ? Math.min(100, Math.round((usageBytes / qBytes) * 100)) : 0; - const remaining = Math.max(0, qBytes - usageBytes); + const period = $('selectQuotaPeriod') ? $('selectQuotaPeriod').value : 'total'; + const periodLabels = { total: 'Total', monthly: 'Ce mois-ci', weekly: 'Cette semaine', daily: "Aujourd'hui" }; + const pLabel = periodLabels[period] || period; + + if ($('quotaUsageSummaryText')) { + $('quotaUsageSummaryText').textContent = `${usageStr} consommés (${pLabel})`; + } + + let pct = 0; + if (quotaBytes > 0) { + pct = Math.min(100, Math.round((usageBytes / quotaBytes) * 100)); + } + const remaining = Math.max(0, quotaBytes - usageBytes); + const exceeded = (quotaBytes > 0 && usageBytes >= quotaBytes); if ($('quotaUsageBar')) { $('quotaUsageBar').style.width = `${pct}%`;