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 //apply skin CSS
var uid = MistUtil.createUnique(); var uid = MistUtil.createUnique();
var toload = MistVideo.skin.css.length; var loaded = 0;
if (toload) { container.style.opacity = "0"; } if (MistVideo.skin.css.length) { container.style.opacity = 0; }
for (var i in MistVideo.skin.css) { for (var i in MistVideo.skin.css) {
var style = MistVideo.skin.css[i]; var style = MistVideo.skin.css[i];
style.callback = function(css) { 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); this.textContent = MistUtil.css.prependClass(css,uid,true);
toload--; }
if (toload <= 0) { loaded++;
if (MistVideo.skin.css.length <= loaded) {
container.style.opacity = ""; container.style.opacity = "";
} }
}; };

View file

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

View file

@ -363,10 +363,8 @@ var MistUtil = {
callback(xhr.response); callback(xhr.response);
} }
else if (errorCallback) { else if (errorCallback) {
xhr.onerror = function() {
errorCallback(xhr); errorCallback(xhr);
} }
}
}; };
if (errorCallback) { if (errorCallback) {
xhr.onerror = function() { xhr.onerror = function() {
@ -461,7 +459,12 @@ var MistUtil = {
} }
cache[url] = d; cache[url] = d;
},function(){ },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;
}); });
} }