mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 23:37:59 +00:00
Make value formatting consistent with GUI
This commit is contained in:
parent
97b4e4a3d3
commit
0f6dff6315
@ -30,9 +30,12 @@ function friendlyUnit(value, isSpeed) {
|
|||||||
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(friendlyUnitPrecision(i)) //Don't round up
|
var precision = friendlyUnitPrecision(i);
|
||||||
+ " " + units[i];
|
var offset = Math.pow(10, precision);
|
||||||
|
// Don't round up
|
||||||
|
ret = (Math.floor(offset * value) / offset).toFixed(precision) + " " + units[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (isSpeed)
|
if (isSpeed)
|
||||||
ret += "QBT_TR(/s)QBT_TR[CONTEXT=misc]";
|
ret += "QBT_TR(/s)QBT_TR[CONTEXT=misc]";
|
||||||
@ -70,7 +73,7 @@ function friendlyPercentage(value) {
|
|||||||
percentage = 0;
|
percentage = 0;
|
||||||
if (percentage > 100)
|
if (percentage > 100)
|
||||||
percentage = 100;
|
percentage = 100;
|
||||||
return percentage + "%";
|
return percentage.toFixed(1) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -78,8 +78,8 @@ function ProgressBar_setValue(value) {
|
|||||||
this.vals.value = value;
|
this.vals.value = value;
|
||||||
this.vals.dark.empty();
|
this.vals.dark.empty();
|
||||||
this.vals.light.empty();
|
this.vals.light.empty();
|
||||||
this.vals.dark.appendText(value + '%');
|
this.vals.dark.appendText(value.round(1).toFixed(1) + '%');
|
||||||
this.vals.light.appendText(value + '%');
|
this.vals.light.appendText(value.round(1).toFixed(1) + '%');
|
||||||
var r = parseInt(this.vals.width * (value / 100));
|
var r = parseInt(this.vals.width * (value / 100));
|
||||||
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
|
this.vals.dark.setStyle('clip', 'rect(0,' + r + 'px,' + this.vals.height + 'px,0)');
|
||||||
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
|
this.vals.light.setStyle('clip', 'rect(0,' + this.vals.width + 'px,' + this.vals.height + 'px,' + r + 'px)');
|
||||||
|
Loading…
Reference in New Issue
Block a user