ui: improve some eta/idle fields

cpanel db-idle-time indicator would glitch on 0.0s

upload windowtitle was %.2f seconds, but the value is int
This commit is contained in:
ed 2024-12-17 22:01:36 +01:00
parent 73f7249c5f
commit 01a3eb29cb
2 changed files with 7 additions and 3 deletions

View file

@ -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;
}

View file

@ -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;
}