Embed: show an error when CSS failed to load

This commit is contained in:
Cat 2020-03-03 11:54:43 +01:00 committed by Thulinma
parent b9eb03a599
commit c17cfe9595
3 changed files with 23 additions and 12 deletions

14
embed/controls.js vendored
View file

@ -93,14 +93,20 @@ function MistUI(MistVideo,structure) {
//apply skin CSS
var uid = MistUtil.createUnique();
var toload = MistVideo.skin.css.length;
if (toload) { container.style.opacity = "0"; }
var loaded = 0;
if (MistVideo.skin.css.length) { container.style.opacity = 0; }
for (var i in MistVideo.skin.css) {
var style = MistVideo.skin.css[i];
style.callback = function(css) {
if (css == "/*Failed to load*/") {
this.textContent = css;
MistVideo.showError("Failed to load CSS from "+this.getAttribute("data-source"));
}
else {
this.textContent = MistUtil.css.prependClass(css,uid,true);
toload--;
if (toload <= 0) {
}
loaded++;
if (MistVideo.skin.css.length <= loaded) {
container.style.opacity = "";
}
};

View file

@ -418,7 +418,9 @@ MistSkins["default"] = {
//remove all the things when unmuted
var fu = function(){
if (!MistVideo.video.muted) {
if (largeMutedButton.parentNode) {
MistVideo.container.removeChild(largeMutedButton);
}
MistVideo.video.removeEventListener("volumechange",fu);
document.body.removeEventListener("click",i);
MistVideo.video.removeEventListener("mouseenter",f);
@ -2621,10 +2623,10 @@ function MistSkin(MistVideo) {
//load css
var styles = [];
var toload = 0;
for (var i in this.css) {
if (typeof this.css[i] == "string") {
styles.push(MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors));
var a = MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors);
styles.push(a);
}
}
this.css = styles; //overwrite

View file

@ -363,10 +363,8 @@ var MistUtil = {
callback(xhr.response);
}
else if (errorCallback) {
xhr.onerror = function() {
errorCallback(xhr);
}
}
};
if (errorCallback) {
xhr.onerror = function() {
@ -461,7 +459,12 @@ var MistUtil = {
}
cache[url] = d;
},function(){
throw "Failed to load CSS from "+url;
var d = "/*Failed to load*/";
for (var i in cache[url]) {
cache[url][i](d);
}
cache[url] = d;
});
}