Embed: retry failed CSS load (3x)
This commit is contained in:
parent
e96799d5ac
commit
8cd51e5e7d
2 changed files with 25 additions and 14 deletions
File diff suppressed because one or more lines are too long
|
@ -453,19 +453,30 @@ var MistUtil = {
|
|||
else {
|
||||
//retrieve file contents
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue