mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Lint stuff
This commit is contained in:
parent
8c319903dd
commit
13073bc98d
22
js/app.js
22
js/app.js
@ -51,7 +51,7 @@ var App = function () {
|
|||||||
*
|
*
|
||||||
* argument callback function - The callback function.
|
* argument callback function - The callback function.
|
||||||
*/
|
*/
|
||||||
var loadConfig = function(callback) {
|
var loadConfig = function (callback) {
|
||||||
Log.log("Loading config ...");
|
Log.log("Loading config ...");
|
||||||
var defaults = require(__dirname + "/defaults.js");
|
var defaults = require(__dirname + "/defaults.js");
|
||||||
|
|
||||||
@ -92,11 +92,7 @@ var App = function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (usedDeprecated.length > 0) {
|
if (usedDeprecated.length > 0) {
|
||||||
Log.warn(Utils.colors.warn(
|
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."));
|
||||||
"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).
|
* 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 ...");
|
Log.log("Loading module helpers ...");
|
||||||
|
|
||||||
var loadNextModule = function () {
|
var loadNextModule = function () {
|
||||||
@ -215,8 +211,8 @@ var App = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadModules(modules, function() {
|
loadModules(modules, function () {
|
||||||
var server = new Server(config, function(app, io) {
|
var server = new Server(config, function (app, io) {
|
||||||
Log.log("Server started ...");
|
Log.log("Server started ...");
|
||||||
|
|
||||||
for (var h in nodeHelpers) {
|
for (var h in nodeHelpers) {
|
||||||
@ -258,7 +254,9 @@ var App = function () {
|
|||||||
*/
|
*/
|
||||||
process.on("SIGINT", () => {
|
process.on("SIGINT", () => {
|
||||||
Log.log("[SIGINT] Received. Shutting down server...");
|
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();
|
this.stop();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
@ -267,7 +265,9 @@ var App = function () {
|
|||||||
*/
|
*/
|
||||||
process.on("SIGTERM", () => {
|
process.on("SIGTERM", () => {
|
||||||
Log.log("[SIGTERM] Received. Shutting down server...");
|
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();
|
this.stop();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,7 @@ function checkConfigFile() {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// In case the there errors show messages and return
|
// 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);
|
Logger.log("Line", error.line, "col", error.column, error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ function createWindow() {
|
|||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
app.on("ready", function() {
|
app.on("ready", function () {
|
||||||
Log.log("Launching application.");
|
Log.log("Launching application.");
|
||||||
createWindow();
|
createWindow();
|
||||||
});
|
});
|
||||||
|
62
js/loader.js
62
js/loader.js
@ -171,34 +171,42 @@ 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") {callback();}
|
if (typeof callback === "function") {
|
||||||
};
|
callback();
|
||||||
script.onerror = function() {
|
}
|
||||||
Log.error("Error on loading script:", fileName);
|
};
|
||||||
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);
|
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") {callback();}
|
if (typeof callback === "function") {
|
||||||
};
|
callback();
|
||||||
stylesheet.onerror = function() {
|
}
|
||||||
Log.error("Error on loading stylesheet:", fileName);
|
};
|
||||||
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);
|
document.getElementsByTagName("head")[0].appendChild(stylesheet);
|
||||||
break;
|
break;
|
||||||
|
13
js/logger.js
13
js/logger.js
@ -7,7 +7,7 @@
|
|||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof exports === 'object') {
|
if (typeof exports === "object") {
|
||||||
// add timestamps in front of log messages
|
// add timestamps in front of log messages
|
||||||
require("console-stamp")(console, "yyyy-mm-dd HH:MM:ss.l");
|
require("console-stamp")(console, "yyyy-mm-dd HH:MM:ss.l");
|
||||||
|
|
||||||
@ -17,8 +17,7 @@
|
|||||||
// Browser globals (root is window)
|
// Browser globals (root is window)
|
||||||
root.Log = factory(root.config);
|
root.Log = factory(root.config);
|
||||||
}
|
}
|
||||||
}(this, function (config) {
|
})(this, function (config) {
|
||||||
|
|
||||||
let logLevel = {
|
let logLevel = {
|
||||||
info: Function.prototype.bind.call(console.info, console),
|
info: Function.prototype.bind.call(console.info, console),
|
||||||
log: Function.prototype.bind.call(console.log, console),
|
log: Function.prototype.bind.call(console.log, console),
|
||||||
@ -30,15 +29,15 @@
|
|||||||
time: Function.prototype.bind.call(console.time, console),
|
time: Function.prototype.bind.call(console.time, console),
|
||||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||||
}
|
};
|
||||||
|
|
||||||
if (config && config.logLevel) {
|
if (config && config.logLevel) {
|
||||||
Object.keys(logLevel).forEach(function(key,index) {
|
Object.keys(logLevel).forEach(function (key, index) {
|
||||||
if (!config.logLevel.includes(key.toLocaleUpperCase())) {
|
if (!config.logLevel.includes(key.toLocaleUpperCase())) {
|
||||||
logLevel[key] = function() {};
|
logLevel[key] = function () {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return logLevel;
|
return logLevel;
|
||||||
}));
|
});
|
||||||
|
@ -9,16 +9,16 @@ const Log = require("./logger.js");
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
|
|
||||||
var NodeHelper = Class.extend({
|
var NodeHelper = Class.extend({
|
||||||
init: function() {
|
init: function () {
|
||||||
Log.log("Initializing new module helper ...");
|
Log.log("Initializing new module helper ...");
|
||||||
},
|
},
|
||||||
|
|
||||||
loaded: function(callback) {
|
loaded: function (callback) {
|
||||||
Log.log("Module helper loaded: " + this.name);
|
Log.log("Module helper loaded: " + this.name);
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function () {
|
||||||
Log.log("Starting module helper: " + this.name);
|
Log.log("Starting module helper: " + this.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ var NodeHelper = Class.extend({
|
|||||||
* gracefully exit the module.
|
* gracefully exit the module.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
stop: function() {
|
stop: function () {
|
||||||
Log.log("Stopping module helper: " + this.name);
|
Log.log("Stopping module helper: " + this.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ var NodeHelper = Class.extend({
|
|||||||
* argument notification string - The identifier of the notification.
|
* argument notification string - The identifier of the notification.
|
||||||
* argument payload mixed - The payload 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);
|
Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ var CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntr
|
|||||||
/* scheduleTimer()
|
/* scheduleTimer()
|
||||||
* Schedule the timer for the next update.
|
* Schedule the timer for the next update.
|
||||||
*/
|
*/
|
||||||
var scheduleTimer = function() {
|
var scheduleTimer = function () {
|
||||||
clearTimeout(reloadTimer);
|
clearTimeout(reloadTimer);
|
||||||
reloadTimer = setTimeout(function () {
|
reloadTimer = setTimeout(function () {
|
||||||
fetchCalendar();
|
fetchCalendar();
|
||||||
@ -435,8 +435,8 @@ var CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntr
|
|||||||
/* broadcastItems()
|
/* broadcastItems()
|
||||||
* Broadcast the existing events.
|
* Broadcast the existing events.
|
||||||
*/
|
*/
|
||||||
this.broadcastEvents = function() {
|
this.broadcastEvents = function () {
|
||||||
console.info('Broadcasting ' + events.length + ' events.');
|
console.info("Broadcasting " + events.length + " events.");
|
||||||
eventsReceivedCallback(self);
|
eventsReceivedCallback(self);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const app = require("../js/app.js");
|
const app = require("../js/app.js");
|
||||||
const Log = require("../js/logger.js");
|
const Log = require("../js/logger.js");
|
||||||
|
|
||||||
app.start(function(config) {
|
app.start(function (config) {
|
||||||
var bindAddress = config.address ? config.address : "localhost";
|
var bindAddress = config.address ? config.address : "localhost";
|
||||||
var httpType = config.useHttps ? "https" : "http";
|
var httpType = config.useHttps ? "https" : "http";
|
||||||
Log.log("\nReady to go! Please point your browser to: " + httpType + "://" + bindAddress + ":" + config.port);
|
Log.log("\nReady to go! Please point your browser to: " + httpType + "://" + bindAddress + ":" + config.port);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user