summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhackademix <giorgio@maone.net>2016-07-19 18:57:39 +0200
committerhackademix <giorgio@maone.net>2016-07-19 18:57:39 +0200
commita59382f3e252850de4085d140d1302e842b623fa (patch)
treed3b991a5af690fb8172c7ea71cba4c839a614017
parent75806950cf596b416836344f83e193cbaf7a5f3d (diff)
Do not show "??? KB/s" and "0 MiB" on resume
-rw-r--r--tails-download-and-verify/data/download-page.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/tails-download-and-verify/data/download-page.js b/tails-download-and-verify/data/download-page.js
index 964889d..0c181f6 100644
--- a/tails-download-and-verify/data/download-page.js
+++ b/tails-download-and-verify/data/download-page.js
@@ -90,40 +90,46 @@ let updateBlobView = ({blob: info}) => {
updateDownloadView = ({downloadInfo: info, blob: blob}) => {
let elapsedSecs = Math.round((Date.now() - info.startTime) / 1000);
let size = info.size || blob.size || info.totalBytes;
- let speed = elapsedSecs > 0 ? Math.round(info.currentBytes / 1024 / elapsedSecs) : 0;
+ let currentBytes = info.currentBytes;
+ let speed = elapsedSecs > 0 ? Math.round(currentBytes / 1024 / elapsedSecs) : 0;
let speedKBs = speed || "???";
let speedKbs = speed ? speed * 8 : "???";
- let downloadedKB = Math.round(info.currentBytes / 1024);
- let downloadedMiB = sizeMiB(info.currentBytes);
- let eta = info.currentBytes > 0 ? Math.round(elapsedSecs / info.currentBytes * (size - info.currentBytes)) : 0;
+ let downloadedKB = Math.round(currentBytes / 1024);
+ let downloadedMiB = sizeMiB(currentBytes);
+ let eta = currentBytes > 0 ? Math.round(elapsedSecs / currentBytes * (size - currentBytes)) : 0;
let etaMins = Math.floor(eta / 60);
let progressKnown = info.hasProgress && typeof info.progress === "number";
let progress = progressKnown ? info.progress : 100;
+ let broken = info.error || (info.succeeded && currentBytes < info.totalBytes);
+ let state = broken ? "failed" : (info.stopped ? (info.succeeded ? "done" : "pause") : "going");
+ console.log(`Download state: ${state}`);
+ $("#download").dataset.state = state;
+
for(let el of $$('.iso-url')) el.href = info.url;
for(let el of $$('.iso-url-text')) el.textContent = info.url;
for(let el of $$('.download-path')) el.textContent = info.path;
for(let el of $$('.iso-size-KB')) el.textContent = Math.round(size / 1024);
for(let el of $$('.iso-size-MiB')) el.textContent = sizeMiB(size);
- for(let el of $$('.speed-Kbs')) el.textContent = el.parentNode.dataset.value = speedKbs;
- for(let el of $$('.speed-KBs')) el.textContent = el.parentNode.dataset.value = speedKBs;
- for(let el of $$('.downloaded-KB')) el.textContent = downloadedKB;
- for(let el of $$('.downloaded-MiB')) el.textContent = downloadedMiB;
for(let el of $$('.eta-secs')) el.textContent = el.parentNode.dataset.value = eta || "???";
for(let el of $$('.eta-mins')) el.textContent = el.parentNode.dataset.value = etaMins || "???";
- if (progressKnown || info.currentBytes > 0) {
+ if (currentBytes && speed || broken || info.stopped) {
+ for(let el of $$('.speed-Kbs')) el.textContent = el.parentNode.dataset.value = speedKbs;
+ for(let el of $$('.speed-KBs')) el.textContent = el.parentNode.dataset.value = speedKBs;
+ for(let el of $$('.downloaded-KB')) el.textContent = downloadedKB;
+ for(let el of $$('.downloaded-MiB')) el.textContent = downloadedMiB;
+ }
+
+ if (progressKnown || currentBytes > 0) {
for(let el of $$('#download-progress .progress-bar')) {
el.setAttribute("aria-value", `${progress}%`);
el.style.width = `${progress}%`;
}
for(let el of $$('#download-progress .progress-label')) el.textContent = progressKnown ? `${info.progress}%` : '???';
}
+
toggle('#download-eta, #download-path', true);
- let broken = info.error || (info.succeeded && info.currentBytes < info.totalBytes);
- let state = broken ? "failed" : (info.stopped ? (info.succeeded ? "done" : "pause") : "going");
- console.log(`Download state: ${state}`);
- $("#download").dataset.state = state;
},
updateVerifyView = ({phase, verifyInfo: info, error, failed }) => {