mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 02:36:15 +03:00
WebUI: simplify code
This commit is contained in:
parent
3bb47a5410
commit
1c5af96ad8
1 changed files with 8 additions and 10 deletions
|
@ -120,18 +120,16 @@ window.qBittorrent.ProgressBar = (function() {
|
|||
value = parseFloat(value);
|
||||
if (isNaN(value))
|
||||
value = 0;
|
||||
if (value > 100)
|
||||
value = 100;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
value = Math.min(Math.max(value, 0), 100);
|
||||
this.vals.value = value;
|
||||
this.vals.dark.empty();
|
||||
this.vals.light.empty();
|
||||
this.vals.dark.appendText(value.round(1).toFixed(1) + "%");
|
||||
this.vals.light.appendText(value.round(1).toFixed(1) + "%");
|
||||
|
||||
const displayedValue = `${value.round(1).toFixed(1)}%`;
|
||||
this.vals.dark.textContent = displayedValue;
|
||||
this.vals.light.textContent = displayedValue;
|
||||
|
||||
const r = parseInt(this.vals.width * (value / 100));
|
||||
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.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)`);
|
||||
}
|
||||
|
||||
function ProgressBar_setWidth(value) {
|
||||
|
|
Loading…
Reference in a new issue