Embed: retry failed CSS load (3x)

This commit is contained in:
Cat 2021-05-05 10:37:41 +02:00 committed by Thulinma
parent e96799d5ac
commit 8cd51e5e7d
2 changed files with 25 additions and 14 deletions

File diff suppressed because one or more lines are too long

View file

@ -453,19 +453,30 @@ var MistUtil = {
else { else {
//retrieve file contents //retrieve file contents
cache[url] = [onCSSLoad]; cache[url] = [onCSSLoad];
MistUtil.http.get(url,function(d){
for (var i in cache[url]) {
cache[url][i](d);
}
cache[url] = d;
},function(){
var d = "/*Failed to load*/";
for (var i in cache[url]) {
cache[url][i](d);
}
cache[url] = d;
}); //try to load 3 times, then give up
var attempts = 3;
function retry() {
MistUtil.http.get(url,function(d){
for (var i in cache[url]) {
cache[url][i](d);
}
cache[url] = d;
},function(){
if (attempts > 0) {
attempts--;
setTimeout(retry,2e3);
}
else {
var d = "/*Failed to load*/";
for (var i in cache[url]) {
cache[url][i](d);
}
cache[url] = d;
}
});
}
retry();
} }
return style; //its empty now, but will be filled on load return style; //its empty now, but will be filled on load