Add speed formatting to display appropriate units (KB/s, MB/s)
Some checks failed
Build and Push Docker Image / build (push) Successful in 37s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 31s
CI / Security audit (push) Successful in 54s
CI / Tests & coverage (push) Failing after 1m5s

This commit is contained in:
2026-05-20 01:07:52 +01:00
parent a562cfe9aa
commit 5fde69fcf5
2 changed files with 21 additions and 2 deletions

View File

@@ -879,7 +879,7 @@ function createDownloadCard(download) {
}
if (download.speed && download.speed > 0) {
const speed = createDetailItem('Speed', download.speed);
const speed = createDetailItem('Speed', formatSpeed(download.speed));
details.appendChild(speed);
}
@@ -936,6 +936,21 @@ function createDownloadCard(download) {
return card;
}
function formatSpeed(bytesPerSecond) {
if (!bytesPerSecond || bytesPerSecond === 0) return '0 B/s';
const units = ['B/s', 'KB/s', 'MB/s', 'GB/s'];
let value = bytesPerSecond;
let unitIndex = 0;
while (value >= 1024 && unitIndex < units.length - 1) {
value /= 1024;
unitIndex++;
}
return `${value.toFixed(2)} ${units[unitIndex]}`;
}
function createDetailItem(label, value) {
const item = document.createElement('div');
item.className = 'detail-item';