Size in toolbar

This commit is contained in:
2020-01-21 17:01:26 +01:00
parent ef063bbe26
commit 8bff81ce6c
7 changed files with 31 additions and 29 deletions

View File

@@ -90,3 +90,17 @@ function domainURL() {
}
return url;
}
function formatDataVolume(amt = 0, precision = 3) {
if (precision < 3) { precision = 3; }
if (amt >= 1e12) {
return (amt/1e12).toPrecision(precision) + " TB";
} else if (amt >= 1e9) {
return (amt/1e9).toPrecision(precision) + " GB";
} else if (amt >= 1e6) {
return (amt/1e6).toPrecision(precision) + " MB";
} else if (amt >= 1e3) {
return (amt/1e3).toPrecision(precision) + " kB";
}
return amt + " B"
}