diff --git a/js/app.js b/js/app.js index 508ac195..600b379a 100644 --- a/js/app.js +++ b/js/app.js @@ -51,7 +51,7 @@ var App = function () { * * argument callback function - The callback function. */ - var loadConfig = function(callback) { + var loadConfig = function (callback) { Log.log("Loading config ..."); var defaults = require(__dirname + "/defaults.js"); @@ -92,11 +92,7 @@ var App = function () { } }); if (usedDeprecated.length > 0) { - Log.warn(Utils.colors.warn( - "WARNING! Your config is using deprecated options: " + - usedDeprecated.join(", ") + - ". Check README and CHANGELOG for more up-to-date ways of getting the same functionality.") - ); + Log.warn(Utils.colors.warn("WARNING! Your config is using deprecated options: " + usedDeprecated.join(", ") + ". Check README and CHANGELOG for more up-to-date ways of getting the same functionality.")); } }; @@ -153,7 +149,7 @@ var App = function () { * * argument module string - The name of the module (including subpath). */ - var loadModules = function(modules, callback) { + var loadModules = function (modules, callback) { Log.log("Loading module helpers ..."); var loadNextModule = function () { @@ -215,8 +211,8 @@ var App = function () { } } - loadModules(modules, function() { - var server = new Server(config, function(app, io) { + loadModules(modules, function () { + var server = new Server(config, function (app, io) { Log.log("Server started ..."); for (var h in nodeHelpers) { @@ -258,7 +254,9 @@ var App = function () { */ process.on("SIGINT", () => { Log.log("[SIGINT] Received. Shutting down server..."); - setTimeout(() => { process.exit(0); }, 3000); // Force quit after 3 seconds + setTimeout(() => { + process.exit(0); + }, 3000); // Force quit after 3 seconds this.stop(); process.exit(0); }); @@ -267,7 +265,9 @@ var App = function () { */ process.on("SIGTERM", () => { Log.log("[SIGTERM] Received. Shutting down server..."); - setTimeout(() => { process.exit(0); }, 3000); // Force quit after 3 seconds + setTimeout(() => { + process.exit(0); + }, 3000); // Force quit after 3 seconds this.stop(); process.exit(0); }); diff --git a/js/check_config.js b/js/check_config.js index ccd786ef..da2a4aa5 100644 --- a/js/check_config.js +++ b/js/check_config.js @@ -62,7 +62,7 @@ function checkConfigFile() { return true; } else { // In case the there errors show messages and return - messages.forEach(error => { + messages.forEach((error) => { Logger.log("Line", error.line, "col", error.column, error.message); }); } diff --git a/js/electron.js b/js/electron.js index 14e1bf51..0978cd0d 100644 --- a/js/electron.js +++ b/js/electron.js @@ -86,7 +86,7 @@ function createWindow() { // This method will be called when Electron has finished // initialization and is ready to create browser windows. -app.on("ready", function() { +app.on("ready", function () { Log.log("Launching application."); createWindow(); }); diff --git a/js/loader.js b/js/loader.js index 6e20e73d..bc376bd9 100644 --- a/js/loader.js +++ b/js/loader.js @@ -171,34 +171,42 @@ 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() { - Log.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() { - Log.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; diff --git a/js/logger.js b/js/logger.js index a0f8a038..523b9ce5 100644 --- a/js/logger.js +++ b/js/logger.js @@ -7,7 +7,7 @@ * MIT Licensed. */ (function (root, factory) { - if (typeof exports === 'object') { + if (typeof exports === "object") { // add timestamps in front of log messages require("console-stamp")(console, "yyyy-mm-dd HH:MM:ss.l"); @@ -17,8 +17,7 @@ // Browser globals (root is window) root.Log = factory(root.config); } -}(this, function (config) { - +})(this, function (config) { let logLevel = { info: Function.prototype.bind.call(console.info, console), log: Function.prototype.bind.call(console.log, console), @@ -30,15 +29,15 @@ time: Function.prototype.bind.call(console.time, console), timeEnd: Function.prototype.bind.call(console.timeEnd, console), timeStamp: Function.prototype.bind.call(console.timeStamp, console) - } + }; if (config && config.logLevel) { - Object.keys(logLevel).forEach(function(key,index) { + Object.keys(logLevel).forEach(function (key, index) { if (!config.logLevel.includes(key.toLocaleUpperCase())) { - logLevel[key] = function() {}; + logLevel[key] = function () {}; } }); } return logLevel; -})); +}); diff --git a/js/node_helper.js b/js/node_helper.js index c2e49a78..4a31fdee 100644 --- a/js/node_helper.js +++ b/js/node_helper.js @@ -9,16 +9,16 @@ const Log = require("./logger.js"); const express = require("express"); var NodeHelper = Class.extend({ - init: function() { + init: function () { Log.log("Initializing new module helper ..."); }, - loaded: function(callback) { + loaded: function (callback) { Log.log("Module helper loaded: " + this.name); callback(); }, - start: function() { + start: function () { Log.log("Starting module helper: " + this.name); }, @@ -28,7 +28,7 @@ var NodeHelper = Class.extend({ * gracefully exit the module. * */ - stop: function() { + stop: function () { Log.log("Stopping module helper: " + this.name); }, @@ -38,7 +38,7 @@ var NodeHelper = Class.extend({ * argument notification string - The identifier of the notification. * argument payload mixed - The payload of the notification. */ - socketNotificationReceived: function(notification, payload) { + socketNotificationReceived: function (notification, payload) { Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload); }, diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 71284bff..d4cc4f4a 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -337,7 +337,7 @@ var CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntr /* scheduleTimer() * Schedule the timer for the next update. */ - var scheduleTimer = function() { + var scheduleTimer = function () { clearTimeout(reloadTimer); reloadTimer = setTimeout(function () { fetchCalendar(); @@ -435,8 +435,8 @@ var CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntr /* broadcastItems() * Broadcast the existing events. */ - this.broadcastEvents = function() { - console.info('Broadcasting ' + events.length + ' events.'); + this.broadcastEvents = function () { + console.info("Broadcasting " + events.length + " events."); eventsReceivedCallback(self); }; diff --git a/serveronly/index.js b/serveronly/index.js index b02f5c0c..9cc7d942 100644 --- a/serveronly/index.js +++ b/serveronly/index.js @@ -1,7 +1,7 @@ const app = require("../js/app.js"); const Log = require("../js/logger.js"); -app.start(function(config) { +app.start(function (config) { var bindAddress = config.address ? config.address : "localhost"; var httpType = config.useHttps ? "https" : "http"; Log.log("\nReady to go! Please point your browser to: " + httpType + "://" + bindAddress + ":" + config.port);