Skip to content

Commit

Permalink
ui: improve some eta/idle fields
Browse files Browse the repository at this point in the history
cpanel db-idle-time indicator would glitch on 0.0s

upload windowtitle was %.2f seconds, but the value is int
  • Loading branch information
9001 committed Dec 17, 2024
1 parent 73f7249 commit 01a3eb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion copyparty/web/up2k.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,9 @@ function Donut(uc, st) {
}

if (++r.tc >= 10) {
var s = r.eta === null ? 'paused' : r.eta > 60 ? shumantime(r.eta) : (r.eta + 's');
wintitle("{0}%, {1}, #{2}, ".format(
f2f(v * 100 / t, 1), shumantime(r.eta), st.files.length - st.nfile.upload), true);
f2f(v * 100 / t, 1), s, st.files.length - st.nfile.upload), true);
r.tc = 0;
}

Expand Down
7 changes: 5 additions & 2 deletions copyparty/web/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,11 @@ if (window.Number && Number.isFinite)

function f2f(val, nd) {
// 10.toFixed(1) returns 10.00 for certain values of 10
if (!isNum(val))
val = 999;
if (!isNum(val)) {
val = parseFloat(val);
if (!isNum(val))
val = 999;
}
val = (val * Math.pow(10, nd)).toFixed(0).split('.')[0];
return nd ? (val.slice(0, -nd) || '0') + '.' + val.slice(-nd) : val;
}
Expand Down

0 comments on commit 01a3eb2

Please sign in to comment.