diff --git a/shell.html b/shell.html
index 42709f6..70af878 100644
--- a/shell.html
+++ b/shell.html
@@ -230,9 +230,15 @@
const xhr = new XMLHttpRequest();
const pdiv = document.getElementById("progress");
let showTimer = 0;
+ let abortTimer = 0;
+
+ const retry = () => {
+ xhr.abort();
+ getLazyAsset(url, filename, callback);
+ }
xhr.onreadystatechange = function() {
- if (xhr.readyState == XMLHttpRequest.DONE) {
+ if (xhr.readyState == XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status < 400) {
pdiv.innerHTML = `${filename} - done`;
hideTimer = setTimeout(() => {
pdiv.style.opacity = '0';
@@ -241,12 +247,16 @@
callback();
clearTimeout(showTimer);
+ clearTimeout(abortTimer);
}
}
xhr.onprogress = function (event) {
const loaded = Math.round(event.loaded / 1024);
const total = Math.round(event.total / 1024);
pdiv.innerHTML = `${filename} - ${loaded}KB / ${total}KB`;
+
+ clearTimeout(abortTimer);
+ abortTimer = setTimeout(retry, 3000);
};
xhr.open('GET', url);
xhr.send();
@@ -257,6 +267,8 @@
pdiv.style.opacity = '0.5';
}, 100);
+ abortTimer = setTimeout(retry, 3000);
+
if (hideTimer) {
clearTimeout(hideTimer);
hideTimer = 0;