mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-03 06:15:59 +00:00
Use Log in loader too
This commit is contained in:
parent
c60446a015
commit
0cae954f80
62
js/loader.js
62
js/loader.js
@ -171,42 +171,34 @@ var Loader = (function () {
|
|||||||
var extension = fileName.slice((Math.max(0, fileName.lastIndexOf(".")) || Infinity) + 1);
|
var extension = fileName.slice((Math.max(0, fileName.lastIndexOf(".")) || Infinity) + 1);
|
||||||
|
|
||||||
switch (extension.toLowerCase()) {
|
switch (extension.toLowerCase()) {
|
||||||
case "js":
|
case "js":
|
||||||
Log.log("Load script: " + fileName);
|
Log.log("Load script: " + fileName);
|
||||||
var script = document.createElement("script");
|
var script = document.createElement("script");
|
||||||
script.type = "text/javascript";
|
script.type = "text/javascript";
|
||||||
script.src = fileName;
|
script.src = fileName;
|
||||||
script.onload = function () {
|
script.onload = function() {
|
||||||
if (typeof callback === "function") {
|
if (typeof callback === "function") {callback();}
|
||||||
callback();
|
};
|
||||||
}
|
script.onerror = function() {
|
||||||
};
|
Log.error("Error on loading script:", fileName);
|
||||||
script.onerror = function () {
|
if (typeof callback === "function") {callback();}
|
||||||
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":
|
||||||
Log.log("Load stylesheet: " + fileName);
|
Log.log("Load stylesheet: " + fileName);
|
||||||
var stylesheet = document.createElement("link");
|
var stylesheet = document.createElement("link");
|
||||||
stylesheet.rel = "stylesheet";
|
stylesheet.rel = "stylesheet";
|
||||||
stylesheet.type = "text/css";
|
stylesheet.type = "text/css";
|
||||||
stylesheet.href = fileName;
|
stylesheet.href = fileName;
|
||||||
stylesheet.onload = function () {
|
stylesheet.onload = function() {
|
||||||
if (typeof callback === "function") {
|
if (typeof callback === "function") {callback();}
|
||||||
callback();
|
};
|
||||||
}
|
stylesheet.onerror = function() {
|
||||||
};
|
Log.error("Error on loading stylesheet:", fileName);
|
||||||
stylesheet.onerror = function () {
|
if (typeof callback === "function") {callback();}
|
||||||
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