mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Merge pull request #720 from roramirez/prevent_error_load
Prevent crash system if cannot load a js script or style sheet.
This commit is contained in:
commit
11c0221f81
10
js/loader.js
10
js/loader.js
@ -186,6 +186,11 @@ var Loader = (function() {
|
|||||||
script.onload = function() {
|
script.onload = function() {
|
||||||
if (typeof callback === "function") {callback();}
|
if (typeof callback === "function") {callback();}
|
||||||
};
|
};
|
||||||
|
script.onerror = function() {
|
||||||
|
console.error("Error on loading script:", fileName);
|
||||||
|
if (typeof callback === "function") {callback();}
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementsByTagName("body")[0].appendChild(script);
|
document.getElementsByTagName("body")[0].appendChild(script);
|
||||||
break;
|
break;
|
||||||
case "css":
|
case "css":
|
||||||
@ -197,6 +202,11 @@ var Loader = (function() {
|
|||||||
stylesheet.onload = function() {
|
stylesheet.onload = function() {
|
||||||
if (typeof callback === "function") {callback();}
|
if (typeof callback === "function") {callback();}
|
||||||
};
|
};
|
||||||
|
stylesheet.onerror = function() {
|
||||||
|
console.error("Error on loading stylesheet:", fileName);
|
||||||
|
if (typeof callback === "function") {callback();}
|
||||||
|
};
|
||||||
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(stylesheet);
|
document.getElementsByTagName("head")[0].appendChild(stylesheet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user