1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 13:04:23 +00:00

Merge pull request #6751 from thalieht/webuiUnitPrecision

WebUI: Increase the number of digits after the decimal point
This commit is contained in:
Mike Tzou 2017-05-17 12:48:03 +08:00 committed by GitHub
commit d80abeb10f

View File

@ -20,11 +20,18 @@ function friendlyUnit(value, isSpeed) {
value /= 1024.; value /= 1024.;
++i; ++i;
} }
function friendlyUnitPrecision(sizeUnit) {
if (sizeUnit <= 2) return 1; // KiB, MiB
else if (sizeUnit === 3) return 2; // GiB
else return 3; // TiB, PiB, EiB
}
var ret; var ret;
if (i == 0) if (i == 0)
ret = value + " " + units[i]; ret = value + " " + units[i];
else else
ret = (Math.floor(10 * value) / 10).toFixed(1) //Don't round up ret = (Math.floor(10 * value) / 10).toFixed(friendlyUnitPrecision(i)) //Don't round up
+ " " + units[i]; + " " + units[i];
if (isSpeed) if (isSpeed)