less fancy but better

This commit is contained in:
ed 2021-10-29 11:02:20 +02:00
parent 1cb0dc7f8e
commit 3d3bce2788
2 changed files with 23 additions and 10 deletions

View file

@ -490,21 +490,36 @@ function Donut(st) {
function svg(v) { function svg(v) {
var ico = v !== undefined, var ico = v !== undefined,
bg = ico ? '#' + r.bg : 'transparent'; bg = ico ? '#333' : 'transparent',
fg, fsz;
if (r.eta && r.eta > 99)
r.eta = null;
if (r.eta) {
fg = r.eta > 10 ? '#fff' : '#fa0';
fsz = ico && r.eta < 10 ? 64 : 56;
}
return ( return (
'<svg version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">\n' + '<svg version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">\n' +
(ico ? '<rect width="100%" height="100%" rx="32" fill="#333" />\n' : (ico ? '<rect width="100%" height="100%" rx="32" fill="#333" />\n' :
'<circle stroke="white" stroke-width="6" r="3" cx="32" cy="32" />\n') + '<circle stroke="white" stroke-width="6" r="3" cx="32" cy="32" />\n') +
(r.eta ? (
'<text x="50%" y="55%" dominant-baseline="middle" text-anchor="middle"' +
' font-family="sans-serif" font-weight="bold" font-size="' + fsz + 'px"' +
' fill="' + fg + '">' + r.eta + '</text></svg>'
) : (
'<circle class="donut" stroke="white" fill="' + bg + '<circle class="donut" stroke="white" fill="' + bg +
'" stroke-dashoffset="' + (ico ? v : o) + '" stroke-dasharray="' + o + ' ' + o + '" stroke-dashoffset="' + (ico ? v : o) + '" stroke-dasharray="' + o + ' ' + o +
'" transform="rotate(270 32 32)" stroke-width="12" r="20" cx="32" cy="32" /></svg>' '" transform="rotate(270 32 32)" stroke-width="12" r="20" cx="32" cy="32" /></svg>'
))
); );
} }
r.on = function (ya) { r.on = function (ya) {
r.fc = 99; r.fc = 99;
r.bg = '333'; r.eta = null;
r.base = st.bytes.finished; r.base = st.bytes.finished;
optab.innerHTML = ya ? svg() : optab.getAttribute('ico'); optab.innerHTML = ya ? svg() : optab.getAttribute('ico');
el = QS('#ops a .donut'); el = QS('#ops a .donut');
@ -520,7 +535,7 @@ function Donut(st) {
ofs = el.style.strokeDashoffset = o - o * v / t; ofs = el.style.strokeDashoffset = o - o * v / t;
if (favico.txt && ++r.fc > 4) { if (favico.txt && ++r.fc > 4) {
favico.upd(svg(ofs)); favico.upd('', svg(ofs));
r.fc = 0; r.fc = 0;
} }
}; };
@ -1118,9 +1133,7 @@ function up2k_init(subtle) {
continue; continue;
} }
if (a == t.length - 1) donut.eta = eta;
donut.bg = eta < 10 ? 'da0' : eta < 30 ? '380' : eta < 60 ? '048' : '333';
if (etaskip) if (etaskip)
continue; continue;

View file

@ -1239,7 +1239,7 @@ var favico = (function () {
); );
} }
r.upd = function (svg) { r.upd = function (txt, svg) {
if (!r.txt) if (!r.txt)
return; return;