From 4e86de7fc2ff64b9b1cd691dd76ea0899b80ad4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mona=20Sch=C3=BCch?= Date: Tue, 26 Apr 2016 22:34:12 +0200 Subject: [PATCH 01/19] calendar events repeating count title for birthdayd etc --- modules/default/calendar/README.md | 15 +++++ modules/default/calendar/calendar.js | 39 +++++++++++- modules/default/calendar/calendarfetcher.js | 3 +- nohup.out | 68 +++++++++++++++++++++ 4 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 nohup.out diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index cfe4e2b8..00378263 100644 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -112,6 +112,14 @@ The following properties can be configured: + + displayRepeatingCountTitle + Show count title for yearly repeating events (e.g. "X. Birthday", "X. Anniversary")
+ +
Possible values: true or false +
Default value: false + + @@ -154,5 +162,12 @@ config: {
Possible values: See Font Awsome website. + + repeatingCountTitle + The count title for yearly repating events in this calendar.
+
Example:
+ 'Birthday' + + diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 5e315586..8bad8277 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -15,6 +15,8 @@ Module.register("calendar",{ maximumNumberOfDays: 365, displaySymbol: true, defaultSymbol: "calendar", // Fontawsome Symbol see http://fontawesome.io/cheatsheet/ + displayRepeatingCountTitle: false, + defaultRepeatingCountTitle: '', maxTitleLength: 25, fetchInterval: 5 * 60 * 1000, // Update every 5 minutes. animationSpeed: 2000, @@ -113,8 +115,24 @@ Module.register("calendar",{ eventWrapper.appendChild(symbolWrapper); } - var titleWrapper = document.createElement("td"); - titleWrapper.innerHTML = this.titleTransform(event.title); + var titleWrapper = document.createElement("td"), + repeatingCountTitle = ''; + + + if (this.config.displayRepeatingCountTitle) { + + repeatingCountTitle = this.countTitleForUrl(event.url) + + if(repeatingCountTitle != '') { + + var thisYear = new Date().getFullYear(), + yearDiff = thisYear - event.firstYear; + + repeatingCountTitle = ', '+ yearDiff + '. ' + repeatingCountTitle; + } + } + + titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; titleWrapper.className = "title bright"; eventWrapper.appendChild(titleWrapper); @@ -239,6 +257,23 @@ Module.register("calendar",{ return this.config.defaultSymbol; }, + /* countTitleForUrl(url) + * Retrieves the name for a specific url. + * + * argument url sting - Url to look for. + * + * return string - The Symbol + */ + countTitleForUrl: function(url) { + for (var c in this.config.calendars) { + var calendar = this.config.calendars[c]; + if (calendar.url === url && typeof calendar.repeatingCountTitle === "string") { + return calendar.repeatingCountTitle; + } + } + + return this.config.defaultRepeatingCountTitle; + }, /* shorten(string, maxLength) * Shortens a sting if it's longer than maxLenthg. diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index ac558e2f..4675f4c0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -84,7 +84,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary, startDate: startDate.format("x"), endDate: endDate.format("x"), - fullDayEvent: isFullDayEvent(event) + fullDayEvent: isFullDayEvent(event), + firstYear: event.start.getFullYear() }); } } diff --git a/nohup.out b/nohup.out new file mode 100644 index 00000000..6a8c47df --- /dev/null +++ b/nohup.out @@ -0,0 +1,68 @@ + +> magicmirror@2.0.0 start /home/pi/MagicMirror +> electron js/electron.js + +Loading config ... +Loading module helpers ... +No helper found for module: alert. +No helper found for module: clock. +Initializing new module helper ... +No helper found for module: compliments. +No helper found for module: currentweather. +No helper found for module: weatherforecast. +Initializing new module helper ... +All module helpers loaded. +Starting server op port 8080 ... +Server started ... +Connecting socket for: calendar +Starting node helper for: calendar +Connecting socket for: newsfeed +Starting module: newsfeed +Sockets connected & modules started ... +A JavaScript error occurred in the main process +Uncaught Exception: +Error: listen EADDRINUSE :::8080 + at Object.exports._errnoException (util.js:890:11) + at exports._exceptionWithHostPort (util.js:913:20) + at Server._listen2 (net.js:1234:14) + at listen (net.js:1270:10) + at Server.listen (net.js:1366:5) + at new Server (/home/pi/MagicMirror/js/server.js:17:9) + at /home/pi/MagicMirror/js/app.js:112:17 + at loadConfig (/home/pi/MagicMirror/js/app.js:33:4) + at start (/home/pi/MagicMirror/js/app.js:98:3) + at Object. (/home/pi/MagicMirror/js/electron.js:64:6) +Launching application. + +> magicmirror@2.0.0 start /home/pi/MagicMirror +> electron js/electron.js + +Loading config ... +Loading module helpers ... +No helper found for module: clock. +Initializing new module helper ... +No helper found for module: currentweather. +No helper found for module: weatherforecast. +No helper found for module: voice. +Initializing new module helper ... +All module helpers loaded. +Starting server op port 8080 ... +Server started ... +Connecting socket for: custom-calendar +Starting node helper for: custom-calendar +Connecting socket for: MMM-Wunderlist +Sockets connected & modules started ... +A JavaScript error occurred in the main process +Uncaught Exception: +Error: listen EADDRINUSE :::8080 + at Object.exports._errnoException (util.js:890:11) + at exports._exceptionWithHostPort (util.js:913:20) + at Server._listen2 (net.js:1234:14) + at listen (net.js:1270:10) + at Server.listen (net.js:1366:5) + at new Server (/home/pi/MagicMirror/js/server.js:17:9) + at /home/pi/MagicMirror/js/app.js:112:17 + at loadConfig (/home/pi/MagicMirror/js/app.js:33:4) + at start (/home/pi/MagicMirror/js/app.js:98:3) + at Object. (/home/pi/MagicMirror/js/electron.js:64:6) +Launching application. From 2a3a942b8e73965311d1b7366fb8b8f3a7fe5b47 Mon Sep 17 00:00:00 2001 From: momo13292 Date: Mon, 2 May 2016 19:32:18 +0200 Subject: [PATCH 02/19] Delete nohup.out --- nohup.out | 68 ------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 nohup.out diff --git a/nohup.out b/nohup.out deleted file mode 100644 index 6a8c47df..00000000 --- a/nohup.out +++ /dev/null @@ -1,68 +0,0 @@ - -> magicmirror@2.0.0 start /home/pi/MagicMirror -> electron js/electron.js - -Loading config ... -Loading module helpers ... -No helper found for module: alert. -No helper found for module: clock. -Initializing new module helper ... -No helper found for module: compliments. -No helper found for module: currentweather. -No helper found for module: weatherforecast. -Initializing new module helper ... -All module helpers loaded. -Starting server op port 8080 ... -Server started ... -Connecting socket for: calendar -Starting node helper for: calendar -Connecting socket for: newsfeed -Starting module: newsfeed -Sockets connected & modules started ... -A JavaScript error occurred in the main process -Uncaught Exception: -Error: listen EADDRINUSE :::8080 - at Object.exports._errnoException (util.js:890:11) - at exports._exceptionWithHostPort (util.js:913:20) - at Server._listen2 (net.js:1234:14) - at listen (net.js:1270:10) - at Server.listen (net.js:1366:5) - at new Server (/home/pi/MagicMirror/js/server.js:17:9) - at /home/pi/MagicMirror/js/app.js:112:17 - at loadConfig (/home/pi/MagicMirror/js/app.js:33:4) - at start (/home/pi/MagicMirror/js/app.js:98:3) - at Object. (/home/pi/MagicMirror/js/electron.js:64:6) -Launching application. - -> magicmirror@2.0.0 start /home/pi/MagicMirror -> electron js/electron.js - -Loading config ... -Loading module helpers ... -No helper found for module: clock. -Initializing new module helper ... -No helper found for module: currentweather. -No helper found for module: weatherforecast. -No helper found for module: voice. -Initializing new module helper ... -All module helpers loaded. -Starting server op port 8080 ... -Server started ... -Connecting socket for: custom-calendar -Starting node helper for: custom-calendar -Connecting socket for: MMM-Wunderlist -Sockets connected & modules started ... -A JavaScript error occurred in the main process -Uncaught Exception: -Error: listen EADDRINUSE :::8080 - at Object.exports._errnoException (util.js:890:11) - at exports._exceptionWithHostPort (util.js:913:20) - at Server._listen2 (net.js:1234:14) - at listen (net.js:1270:10) - at Server.listen (net.js:1366:5) - at new Server (/home/pi/MagicMirror/js/server.js:17:9) - at /home/pi/MagicMirror/js/app.js:112:17 - at loadConfig (/home/pi/MagicMirror/js/app.js:33:4) - at start (/home/pi/MagicMirror/js/app.js:98:3) - at Object. (/home/pi/MagicMirror/js/electron.js:64:6) -Launching application. From a1b3e0778a9a45b2dfe5d57ecfbd17fc623b6248 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 3 May 2016 11:18:06 +0200 Subject: [PATCH 03/19] Add info about malformed config files. Fix: #249 --- js/defaults.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/defaults.js b/js/defaults.js index 28cc2613..8129bff9 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -38,6 +38,14 @@ var defaults = { text: "See README for more information." } }, + { + module: "helloworld", + position: "middle_center", + classes: "xsmall", + config: { + text: "If you get this message while your config file is already
created, your config file probably contains an error.
Use a javascript linter to validate your file." + } + }, { module: "helloworld", position: "bottom_bar", From 05a946e2bfd3f8427f30754c4d56eedf4bdaa205 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 3 May 2016 11:19:01 +0200 Subject: [PATCH 04/19] Formatting. --- js/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/defaults.js b/js/defaults.js index 8129bff9..1d81252c 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -43,7 +43,7 @@ var defaults = { position: "middle_center", classes: "xsmall", config: { - text: "If you get this message while your config file is already
created, your config file probably contains an error.
Use a javascript linter to validate your file." + text: "If you get this message while your config file is already
created, your config file probably contains an error.
Use a JavaScript linter to validate your file." } }, { From 37f8c0783d56d35ed7bb2d727766645022803f15 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 3 May 2016 11:56:24 +0200 Subject: [PATCH 05/19] Fix facebook dates. #271 --- modules/default/calendar/calendar.js | 5 ++--- modules/default/calendar/calendarfetcher.js | 10 ++++++---- modules/default/calendar/vendor/ical.js/node-ical.js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 8bad8277..ea881007 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -121,10 +121,9 @@ Module.register("calendar",{ if (this.config.displayRepeatingCountTitle) { - repeatingCountTitle = this.countTitleForUrl(event.url) + repeatingCountTitle = this.countTitleForUrl(event.url); - if(repeatingCountTitle != '') { - + if(repeatingCountTitle !== '') { var thisYear = new Date().getFullYear(), yearDiff = thisYear - event.firstYear; diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 4675f4c0..00a17fd9 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -55,14 +55,16 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe if (event.type === "VEVENT") { - //console.log(event); - var startDate = (event.start.length === 8) ? moment(event.start, "YYYYMMDD") : moment(new Date(event.start)); var endDate; if (typeof event.end !== "undefined") { endDate = (event.end.length === 8) ? moment(event.end, "YYYYMMDD") : moment(new Date(event.end)); } else { - endDate = startDate; + if (!isFacebookBirthday) { + endDate = startDate; + } else { + endDate = moment(startDate).add(1, 'days'); + } } // calculate the duration f the event for use with recurring events. @@ -92,7 +94,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe } else { // console.log("Single event ..."); // Single event. - var fullDayEvent = isFullDayEvent(event); + var fullDayEvent = (isFacebookBirthday) ? true : isFullDayEvent(event); var title = (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary; if (!fullDayEvent && endDate < new Date()) { diff --git a/modules/default/calendar/vendor/ical.js/node-ical.js b/modules/default/calendar/vendor/ical.js/node-ical.js index 294908ea..2f6ef3ef 100644 --- a/modules/default/calendar/vendor/ical.js/node-ical.js +++ b/modules/default/calendar/vendor/ical.js/node-ical.js @@ -32,7 +32,7 @@ ical.objectHandlers['END'] = function(val, params, curr, stack){ if (curr.start.length === 8) { var comps = /^(\d{4})(\d{2})(\d{2})$/.exec(curr.start); if (comps) { - curr.start = new Date (comps[1], comps[2], comps[3]); + curr.start = new Date (comps[1], comps[2] - 1, comps[3]); } } From 14d3bb273cbdfff672db48314a8e3c35d00f5acc Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 3 May 2016 16:42:09 +0200 Subject: [PATCH 06/19] Load custom.css after the modules. Fix: #284 --- index.html | 2 +- js/loader.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d08291cc..26972810 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,8 @@ - +
diff --git a/js/loader.js b/js/loader.js index 2dbd40b2..da75908e 100644 --- a/js/loader.js +++ b/js/loader.js @@ -34,7 +34,15 @@ var Loader = (function() { loadNextModule(); }); } else { - startModules(); + // All modules loaded. Load custom.css + // This is done after all the moduels so we can + // overwrite all the defined styls. + + loadFile('css/custom.css', function() { + // custom.css loaded. Start all modules. + startModules(); + }); + } }; From a6da9e8943490dfd25f9a8ec8ef58075da646c1a Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 3 May 2016 16:59:18 +0200 Subject: [PATCH 07/19] Fix #283 --- modules/default/alert/alert.js | 2 +- modules/default/alert/notificationFx.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index bff91504..084161ac 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -18,7 +18,7 @@ Module.register("alert",{ //Position position: "center", //shown at startup - welcome_message: true, + welcome_message: false, }, getScripts: function() { return ["classie.js", "modernizr.custom.js", "notificationFx.js"]; diff --git a/modules/default/alert/notificationFx.js b/modules/default/alert/notificationFx.js index b74c9d14..ca77208d 100644 --- a/modules/default/alert/notificationFx.js +++ b/modules/default/alert/notificationFx.js @@ -144,7 +144,10 @@ if (ev.target !== self.ntf) return false; this.removeEventListener(animEndEventName, onEndAnimationFn); } - self.options.wrapper.removeChild(this); + + if (this.parentNode === self.options.wrapper) { + self.options.wrapper.removeChild(this); + } }; if (support.animations) { From 744f9316a9ce9c5af646a35edf2c316bf32ab641 Mon Sep 17 00:00:00 2001 From: Daniel nix Date: Tue, 3 May 2016 17:01:48 +0200 Subject: [PATCH 08/19] Create fr.json adding fr translation --- modules/default/calendar/translations/fr.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 modules/default/calendar/translations/fr.json diff --git a/modules/default/calendar/translations/fr.json b/modules/default/calendar/translations/fr.json new file mode 100644 index 00000000..45f48b8b --- /dev/null +++ b/modules/default/calendar/translations/fr.json @@ -0,0 +1,7 @@ +{ + "TODAY": "Aujourd'hui" + , "TOMORROW": "Demain" + , "RUNNING": "Se termine dans" + , "LOADING": "Chargement des RDV …" + , "EMPTY": "Aucun RDV." +} From 2e5a5812a9194ddc0e3e68e233e5d9d02f126e03 Mon Sep 17 00:00:00 2001 From: Daniel nix Date: Tue, 3 May 2016 17:04:45 +0200 Subject: [PATCH 09/19] Update calendar.js add fr translation for calendar --- modules/default/calendar/calendar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index ea881007..2d494499 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -48,7 +48,8 @@ Module.register("calendar",{ return { en: "translations/en.json", de: "translations/de.json", - nl: "translations/nl.json" + nl: "translations/nl.json", + fr: "translations/fr.json" }; }, From 15887994fe5a827f857b0f91a35a61d899ed53ce Mon Sep 17 00:00:00 2001 From: Nicholas Hubbard Date: Tue, 3 May 2016 19:09:38 -0400 Subject: [PATCH 10/19] JSCS Says Goodbye --- .eslintignore | 6 ++++++ .eslintrc.json | 14 ++++++++++++++ .jscsrc | 9 --------- js/app.js | 16 ++++++++-------- js/class.js | 5 +++-- js/loader.js | 46 +++++++++++++++++++-------------------------- js/main.js | 27 ++++++++++++++++++++++---- js/module.js | 12 ++++++------ js/translator.js | 2 +- serveronly/index.js | 6 +++--- 10 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json delete mode 100644 .jscsrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..460e735a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +vendor/ +!/vendor/vendor.js +/modules/** +!/modules/default/** +!/modules/node_helper +!/modules/node_helper/** diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..83309505 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "rules": { + "indent": ["error", "tab"], + "quotes": ["error", "double"], + "max-len": ["error", 250], + "curly": "error", + "camelcase": ["error", {"properties": "never"}] + }, + "env": { + "browser": true, + "node": true, + "es6": true + } +} \ No newline at end of file diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 4638b44f..00000000 --- a/.jscsrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "preset": "google", - "validateIndentation": "\t", - "validateQuoteMarks": "\"", - "maximumLineLength": 250, - "requireCurlyBraces": [], - "requireCamelCaseOrUpperCaseIdentifiers": false, - "excludeFiles": [".jscsrc"], -} \ No newline at end of file diff --git a/js/app.js b/js/app.js index 012d33ad..1ffbafb8 100644 --- a/js/app.js +++ b/js/app.js @@ -12,11 +12,11 @@ var path = require("path"); // The next part is here to prevent a major exception when there // is no internet connection. This could probable be solved better. -process.on('uncaughtException', function (err) { - console.log("Whoops! There was an uncaught exception..."); - console.error(err); - console.log("MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?"); - console.log("If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues"); +process.on("uncaughtException", function (err) { + console.log("Whoops! There was an uncaught exception..."); + console.error(err); + console.log("MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?"); + console.log("If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues"); }); /* App - The core app. @@ -41,7 +41,7 @@ var App = function() { var config = Object.assign(defaults, c); callback(config); } catch (e) { - console.error('WARNING! Could not find config. Please create one.'); + console.error("WARNING! Could not find config. Please create one."); callback(defaults); } }; @@ -98,7 +98,7 @@ var App = function() { /* start(callback) * This methods starts the core app. * It loads the config, then it loads all modules. - * When it's done it executs the callback with the config as argument. + * When it"s done it executs the callback with the config as argument. * * argument callback function - The callback function. */ @@ -130,7 +130,7 @@ var App = function() { console.log("Sockets connected & modules started ..."); - if (typeof callback === 'function') { + if (typeof callback === "function") { callback(config); } diff --git a/js/class.js b/js/class.js index 69b0cb09..b1793f16 100644 --- a/js/class.js +++ b/js/class.js @@ -48,8 +48,9 @@ // The dummy class constructor function Class() { // All construction is actually done in the init method - if (!initializing && this.init) - this.init.apply(this, arguments); + if (!initializing && this.init) { + this.init.apply(this, arguments); + } } // Populate our constructed prototype object diff --git a/js/loader.js b/js/loader.js index 2dbd40b2..7ab96812 100644 --- a/js/loader.js +++ b/js/loader.js @@ -1,7 +1,4 @@ /* global config, vendor, MM, Log, Module */ -/* jshint unused:false */ -/* jshint -W061 */ - /* Magic Mirror * Module and File loaders. * @@ -165,31 +162,26 @@ 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();} - }; - - document.getElementsByTagName("body")[0].appendChild(script); + 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();} + }; + 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();} - }; - - document.getElementsByTagName("head")[0].appendChild(stylesheet); + 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();} + }; + document.getElementsByTagName("head")[0].appendChild(stylesheet); break; } diff --git a/js/main.js b/js/main.js index 7a585425..b159687a 100644 --- a/js/main.js +++ b/js/main.js @@ -1,5 +1,4 @@ /* global Log, Loader, Module, config, defaults */ -/* jshint -W020 */ /* Magic Mirror * Main System @@ -165,7 +164,7 @@ var MM = (function() { clearTimeout(module.showHideTimer); module.showHideTimer = setTimeout(function() { // To not take up any space, we just make the position absolute. - // since it's fade out anyway, we can see it lay above or + // since it"s fade out anyway, we can see it lay above or // below other modules. This works way better than adjusting // the .display property. moduleWrapper.style.position = "absolute"; @@ -434,7 +433,27 @@ var MM = (function() { })(); // Add polyfill for Object.assign. -if (typeof Object.assign != 'function') { (function () { Object.assign = function (target) { 'use strict'; if (target === undefined || target === null) { throw new TypeError('Cannot convert undefined or null to object'); } var output = Object(target); for (var index = 1; index < arguments.length; index++) { var source = arguments[index]; if (source !== undefined && source !== null) { for (var nextKey in source) { if (source.hasOwnProperty(nextKey)) { output[nextKey] = source[nextKey]; } } } } return output; }; })(); } - +if (typeof Object.assign != "function") { + (function() { + Object.assign = function(target) { + "use strict"; + if (target === undefined || target === null) { + throw new TypeError("Cannot convert undefined or null to object"); + } + var output = Object(target); + for (var index = 1; index < arguments.length; index++) { + var source = arguments[index]; + if (source !== undefined && source !== null) { + for (var nextKey in source) { + if (source.hasOwnProperty(nextKey)) { + output[nextKey] = source[nextKey]; + } + } + } + } + return output; + }; + })(); +} MM.init(); diff --git a/js/module.js b/js/module.js index f0b0103d..f21fdec6 100644 --- a/js/module.js +++ b/js/module.js @@ -111,7 +111,7 @@ var Module = Class.extend({ }, /********************************************* - * The methods below don't need subclassing. * + * The methods below don"t need subclassing. * *********************************************/ /* setData(data) @@ -138,7 +138,7 @@ var Module = Class.extend({ }, /* socket() - * Returns a socket object. If it doesn't exsist, it's created. + * Returns a socket object. If it doesn"t exsist, it"s created. * It also registers the notification callback. */ socket: function() { @@ -223,9 +223,9 @@ var Module = Class.extend({ var translations = this.getTranslations(); var translationFile = translations && (translations[config.language.toLowerCase()] || translations.en) || undefined; if(translationFile) { - Translator.load(this, translationFile, callback); + Translator.load(this, translationFile, callback); } else { - callback(); + callback(); } }, @@ -236,7 +236,7 @@ var Module = Class.extend({ * argument defaultValue string - The default value if no translation was found. (Optional) */ translate: function(key, defaultValue) { - return Translator.translate(this, key) || defaultValue || ''; + return Translator.translate(this, key) || defaultValue || ""; }, /* updateDom(speed) @@ -299,7 +299,7 @@ Module.create = function(name) { return obj; } - var temp = obj.constructor(); // give temp the original obj's constructor + var temp = obj.constructor(); // give temp the original obj"s constructor for (var key in obj) { temp[key] = cloneObject(obj[key]); } diff --git a/js/translator.js b/js/translator.js index 87612ed9..b4c2ab53 100644 --- a/js/translator.js +++ b/js/translator.js @@ -47,7 +47,7 @@ var Translator = (function() { _loadJSON: function(file, callback) { var xhr = new XMLHttpRequest(); xhr.overrideMimeType("application/json"); - xhr.open('GET', file, true); + xhr.open("GET", file, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == "200") { callback(JSON.parse(xhr.responseText)); diff --git a/serveronly/index.js b/serveronly/index.js index 3b8e0f16..ea435a8e 100644 --- a/serveronly/index.js +++ b/serveronly/index.js @@ -1,5 +1,5 @@ -var app = require('../js/app.js'); +var app = require("../js/app.js"); app.start(function(config) { - console.log(''); - console.log('Ready to go! Please point your browser to: http://localhost:' + config.port); + console.log(""); + console.log("Ready to go! Please point your browser to: http://localhost:" + config.port); }); From 9d0bf6d4090f367b693ed6b61c58a297f8d096a3 Mon Sep 17 00:00:00 2001 From: Nicholas Hubbard Date: Tue, 3 May 2016 19:51:07 -0400 Subject: [PATCH 11/19] Grunt and Travis, you\'re late --- .eslintignore | 1 + .travis.yml | 10 ++++++++++ Gruntfile.js | 28 ++++++++++++++++++++++++++++ package.json | 9 +++++++-- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 Gruntfile.js diff --git a/.eslintignore b/.eslintignore index 460e735a..25422889 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ vendor/ !/modules/default/** !/modules/node_helper !/modules/node_helper/** +!/modules/default/defaultmodules.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..f2852c10 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: node_js +node_js: + - "6" + - "5.1" + - "4" + - "0.12" + - "0.10" +before_script: + - npm install grunt-cli -g +script: grunt \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..ac499fe3 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,28 @@ +module.exports = function(grunt) { + require("time-grunt")(grunt); + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + eslint: { + options: { + configFile: ".eslintrc.json" + }, + target: ["js/*.js", "modules/default/*.js", "serveronly/*.js", "*.js"] + }, + postcss: { + lint: { + options: { + processors: [ + require("stylelint")({"extends": "stylelint-config-standard", "font-family-name-quotes": "double-where-recommended"}), + require("postcss-reporter")({ clearMessages: true }) + ] + }, + dist: { + src: "**/**/**/**/**/**/**/**.css" + } + } + } + }); + grunt.loadNpmTasks("grunt-eslint"); + grunt.loadNpmTasks("grunt-postcss"); + grunt.registerTask("default", ["eslint", "postcss:lint"]); +}; \ No newline at end of file diff --git a/package.json b/package.json index e815b2f1..d202526a 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,13 @@ "homepage": "https://github.com/MichMich/MagicMirror#readme", "devDependencies": { "electron-prebuilt": "latest", + "grunt": "latest", + "grunt-eslint": "latest", + "grunt-postcss": "latest", + "postcss-reporter": "latest", "stylelint": "latest", - "stylelint-config-standard": "latest" + "stylelint-config-standard": "latest", + "time-grunt": "latest" }, "dependencies": { "express": "latest", @@ -38,7 +43,7 @@ "iconv-lite": "latest", "moment": "latest", "request": "latest", - "snyk": "^1.13.2", + "snyk": "latest", "socket.io": "latest", "valid-url": "latest", "walk": "latest", From ed95cb791cf2efb13c22a61762a03d7290863a83 Mon Sep 17 00:00:00 2001 From: Nicholas Hubbard Date: Tue, 3 May 2016 19:52:49 -0400 Subject: [PATCH 12/19] Force Travis --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4c935d31..1352e51a 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,4 @@ Please keep the following in mind: - **New Features**: please please discuss in a GitHub issue before you start to alter a big part of the code. Without discussion upfront, the pull request will not be accepted / merged. Thanks for your help in making MagicMirror² better! + From f50c206d4ff39829e0515116e86a434d959d43fb Mon Sep 17 00:00:00 2001 From: Nicholas Hubbard Date: Tue, 3 May 2016 19:56:14 -0400 Subject: [PATCH 13/19] Travis fixer. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2852c10..c47850e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: node_js node_js: - - "6" - - "5.1" - - "4" - - "0.12" - - "0.10" + - "6" + - "5.1" + - "4" + - "0.12" + - "0.10" before_script: - - npm install grunt-cli -g + - npm install grunt-cli -g script: grunt \ No newline at end of file From d0f75ffda9de05fb949815124addba3306f860fd Mon Sep 17 00:00:00 2001 From: Nicholas Hubbard Date: Tue, 3 May 2016 20:00:32 -0400 Subject: [PATCH 14/19] TravisFix2 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c47850e9..c78f0847 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ node_js: - "5.1" - "4" - "0.12" - - "0.10" before_script: - npm install grunt-cli -g script: grunt \ No newline at end of file From 5725af55a83d7fa5284143bd080f7c301ab2003a Mon Sep 17 00:00:00 2001 From: "Warwolf8.9" Date: Tue, 3 May 2016 19:14:27 -0500 Subject: [PATCH 15/19] Make Beaufort wind speed optional --- modules/default/currentweather/currentweather.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 4ab04c4f..fb557935 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -20,6 +20,7 @@ Module.register("currentweather",{ showPeriod: true, showPeriodUpper: false, showWindDirection: false, + useBeaufort: true, lang: config.language, initialLoadDelay: 0, // 0 seconds delay @@ -204,7 +205,14 @@ Module.register("currentweather",{ */ processWeather: function(data) { this.temperature = this.roundValue(data.main.temp); - this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed)); + + if (this.config.useBeaufort){ + this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed)); + }else { + this.windSpeed = parseFloat(data.wind.speed).toFixed(0); + } + + this.windDirection = this.deg2Cardinal(data.wind.deg); this.weatherType = this.config.iconTable[data.weather[0].icon]; From 07ad1b1de42cab28efb9dda05fc2af9a0d92bd1f Mon Sep 17 00:00:00 2001 From: roxasvalor Date: Tue, 3 May 2016 19:21:58 -0500 Subject: [PATCH 16/19] Update Readme for useBeaufort option --- modules/default/currentweather/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 2ce54aac..3be92edb 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -97,6 +97,13 @@ The following properties can be configured:
Default value: false + + useBeaufort + Pick between using the Beaufort scale for wind speed or using the default units.
+
Possible values: true or false +
Default value: true + + lang The language of the days.
From 4f01c574d22bad4eb8acd1b088c324a73adc8ad2 Mon Sep 17 00:00:00 2001 From: Paul-Vincent Roll Date: Wed, 4 May 2016 15:25:23 +0200 Subject: [PATCH 17/19] Added module showcase link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc99caf1..1c7c1263 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ The following modules are installed by default. - [**Hello World**](modules/default/helloworld) - [**Alert**](modules/default/alert) -For more available modules, check out out the wiki page: [MagicMirror² Modules](https://github.com/MichMich/MagicMirror/wiki/MagicMirror²-Modules). If you want to build your own modules, check out the [MagicMirror² Module Development Documentation](modules). +For more available modules, check out out the wiki page: [MagicMirror² Modules](https://github.com/MichMich/MagicMirror/wiki/MagicMirror²-Modules). If you want to build your own modules, check out the [MagicMirror² Module Development Documentation](modules) and don't forget to add it to the wiki and the [forum](https://forum.magicmirror.builders/category/7/showcase)! ## Known issues From 2874ee860924529b97889f19b6614c52ea629233 Mon Sep 17 00:00:00 2001 From: Jordi De Poortere Date: Thu, 5 May 2016 19:12:35 +0200 Subject: [PATCH 18/19] Fixing the hardcoded Node.js version number --- installers/raspberry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers/raspberry.sh b/installers/raspberry.sh index 3c1687c0..31803864 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -18,7 +18,7 @@ echo "Installing helper tools ..." sudo apt-get install curl wget build-essential unzip || exit ARM=$(uname -m) # Determine which Pi is running. -NODE_LATEST="v6.0.0" # Set the latest version here. +NODE_LATEST=$(curl -l http://api.jordidepoortere.com/nodejs-latest/) # Fetch the latest version of Node.js. DOWNLOAD_URL="https://nodejs.org/dist/latest/node-$NODE_LATEST-linux-$ARM.tar.gz" # Construct the download URL. echo "Installing Latest Node.js ..." From 2a706208445b8689c0ca411769eed68c7b35a839 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Fri, 6 May 2016 11:29:17 +0200 Subject: [PATCH 19/19] Typo. --- modules/default/newsfeed/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index 936e5c2c..47f73b01 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -21,8 +21,7 @@ modules: [ url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml", }, { - title: "BBC - ", + title: "BBC", url: "http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml?edition=uk", }, ]