From 0cae954f8018f09043550fab498ae1f57397c3d3 Mon Sep 17 00:00:00 2001 From: rejas Date: Mon, 11 May 2020 23:13:53 +0200 Subject: [PATCH] Use Log in loader too --- js/loader.js | 62 +++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/js/loader.js b/js/loader.js index 50e7176d..6e20e73d 100644 --- a/js/loader.js +++ b/js/loader.js @@ -171,42 +171,34 @@ var Loader = (function () { var extension = fileName.slice((Math.max(0, fileName.lastIndexOf(".")) || Infinity) + 1); switch (extension.toLowerCase()) { - case "js": - Log.log("Load script: " + fileName); - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = fileName; - script.onload = function () { - if (typeof callback === "function") { - callback(); - } - }; - script.onerror = function () { - console.error("Error on loading script:", fileName); - if (typeof callback === "function") { - callback(); - } - }; + case "js": + Log.log("Load script: " + fileName); + var script = document.createElement("script"); + script.type = "text/javascript"; + script.src = fileName; + script.onload = function() { + if (typeof callback === "function") {callback();} + }; + script.onerror = function() { + Log.error("Error on loading script:", fileName); + if (typeof callback === "function") {callback();} + }; - document.getElementsByTagName("body")[0].appendChild(script); - break; - case "css": - Log.log("Load stylesheet: " + fileName); - var stylesheet = document.createElement("link"); - stylesheet.rel = "stylesheet"; - stylesheet.type = "text/css"; - stylesheet.href = fileName; - stylesheet.onload = function () { - if (typeof callback === "function") { - callback(); - } - }; - stylesheet.onerror = function () { - console.error("Error on loading stylesheet:", fileName); - if (typeof callback === "function") { - callback(); - } - }; + document.getElementsByTagName("body")[0].appendChild(script); + break; + case "css": + Log.log("Load stylesheet: " + fileName); + var stylesheet = document.createElement("link"); + stylesheet.rel = "stylesheet"; + stylesheet.type = "text/css"; + stylesheet.href = fileName; + stylesheet.onload = function() { + if (typeof callback === "function") {callback();} + }; + stylesheet.onerror = function() { + Log.error("Error on loading stylesheet:", fileName); + if (typeof callback === "function") {callback();} + }; document.getElementsByTagName("head")[0].appendChild(stylesheet); break;