From 52aa8b868a205af3c0737c59c8474041b736804c Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Thu, 28 May 2020 10:09:34 +0200 Subject: [PATCH 01/13] Truncate event title --- modules/default/calendar/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d93f570c..3a23978f 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -396,7 +396,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = event.location; + descCell.innerHTML = this.titleTransform(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); From 766140f483be96a95ac11c03e04b8bbd6f67a103 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Thu, 28 May 2020 10:10:00 +0200 Subject: [PATCH 02/13] Ability to hide sun details --- modules/default/weather/current.njk | 18 ++++++++++-------- modules/default/weather/weather.js | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/default/weather/current.njk b/modules/default/weather/current.njk index 33dac07a..d89c5f53 100755 --- a/modules/default/weather/current.njk +++ b/modules/default/weather/current.njk @@ -22,14 +22,16 @@ {% if config.showHumidity and current.humidity %} {{ current.humidity | decimalSymbol }}  {% endif %} - - - {% if current.nextSunAction() === "sunset" %} - {{ current.sunset | formatTime }} - {% else %} - {{ current.sunrise | formatTime }} - {% endif %} - + {% if config.showSun %} + + + {% if current.nextSunAction() === "sunset" %} + {{ current.sunset | formatTime }} + {% else %} + {{ current.sunrise | formatTime }} + {% endif %} + + {% endif %} {% endif %}
diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 868316d9..46485c7b 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -33,6 +33,7 @@ Module.register("weather",{ useBeaufort: true, lang: config.language, showHumidity: false, + showSun: true, degreeLabel: false, decimalSymbol: ".", showIndoorTemperature: false, From 6aa0a4a47fbd1a52a12ed30b4417b9a43f26cce9 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Fri, 29 May 2020 23:50:01 +0200 Subject: [PATCH 03/13] Renamed function --- modules/default/calendar/calendar.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 3a23978f..07fd40ab 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -244,7 +244,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.truncateTitle(event.title) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -396,7 +396,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.titleTransform(event.location); + descCell.innerHTML = this.truncateTitle(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -719,8 +719,8 @@ Module.register("calendar", { return string.charAt(0).toUpperCase() + string.slice(1); }, - /* titleTransform(title) - * Transforms the title of an event for usage. + /* truncateTitle(title) + * Transforms the title of an event and the location for usage. * Replaces parts of the text as defined in config.titleReplace. * Shortens title based on config.maxTitleLength and config.wrapEvents * @@ -728,7 +728,7 @@ Module.register("calendar", { * * return string - The transformed title. */ - titleTransform: function (title) { + truncateTitle: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; From f449feb3f822d9a191151ceb9c4b925c36ccbd36 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Fri, 29 May 2020 23:53:07 +0200 Subject: [PATCH 04/13] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a594e6..af9a97af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ _This release is scheduled to be released on 2020-07-01._ - Switch to most of the eslint:recommended rules and fix warnings - Replaced insecure links with https ones - Cleaned up all "no-undef" warnings from eslint +- Added location title wrapping for calendar module ### Deleted From e6ef64968bc99b6f8ed30fb0f1a581bc78763a97 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Sat, 30 May 2020 00:06:20 +0200 Subject: [PATCH 05/13] Disable Sunrise/Sunset in Config option --- tests/configs/modules/weather/currentweather_options.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/configs/modules/weather/currentweather_options.js b/tests/configs/modules/weather/currentweather_options.js index 2b5f9774..3c9021f5 100644 --- a/tests/configs/modules/weather/currentweather_options.js +++ b/tests/configs/modules/weather/currentweather_options.js @@ -28,6 +28,7 @@ let config = { initialLoadDelay: 3000, useBeaufort: false, showWindDirectionAsArrow: true, + showSun: false, showHumidity: true, roundTemp: true, degreeLabel: true From bb972f84495c74247584681a66ffe60be4237dcb Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Sat, 30 May 2020 00:11:14 +0200 Subject: [PATCH 06/13] Updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a594e6..8fbc2928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ _This release is scheduled to be released on 2020-07-01._ - Added prettier for an even cleaner codebase +- Hide Sunrise/Sunset in Weather module + ### Updated - Cleaned up alert module code From 457c80fe769e9bb785315c31b8ce6cb77bc5b867 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 31 May 2020 00:15:54 +0900 Subject: [PATCH 07/13] Correct #2018 Weather forecast need the maxNumberOfDays as argument &cnt=** The minimum is 1 and the maximum is 17. --- modules/default/weatherforecast/weatherforecast.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 8846289e..a04fb40d 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -294,6 +294,8 @@ Module.register("weatherforecast", { return; } + params += "&cnt=" + (((this.config.maxNumberOfDays < 1) || (this.config.maxNumberOfDays > 17)) ? 7 : this.config.maxNumberOfDays); + params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; params += "&APPID=" + this.config.appid; From d306bb25dcbb67375ec485780690613dd210cf51 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 31 May 2020 00:20:42 +0900 Subject: [PATCH 08/13] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a594e6..0f239f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ _This release is scheduled to be released on 2020-07-01._ - The broken modules due to Socket.io change from last release [#1973](https://github.com/MichMich/MagicMirror/issues/1973) - Add backward compatibility for old module code in socketclient.js [#1973](https://github.com/MichMich/MagicMirror/issues/1973) +- Fix the use of "maxNumberOfDays" in the module "weatherforecast" [#2018](https://github.com/MichMich/MagicMirror/issues/2018) ## [2.11.0] - 2020-04-01 From 4a7076e01c900d139eaff1d84562417d1b92b0c1 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 31 May 2020 11:46:50 +0900 Subject: [PATCH 09/13] Prettier correction --- modules/default/weatherforecast/weatherforecast.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index a04fb40d..4be0582a 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -294,7 +294,7 @@ Module.register("weatherforecast", { return; } - params += "&cnt=" + (((this.config.maxNumberOfDays < 1) || (this.config.maxNumberOfDays > 17)) ? 7 : this.config.maxNumberOfDays); + params += "&cnt=" + (this.config.maxNumberOfDays·<·1·||·this.config.maxNumberOfDays·>·17 ? 7 : this.config.maxNumberOfDays); params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; From cc01c1f0dbc1d9cb6322241a585499b8d6e308ce Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 31 May 2020 11:57:53 +0900 Subject: [PATCH 10/13] Update weatherforecast.js --- modules/default/weatherforecast/weatherforecast.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 4be0582a..83389911 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -294,7 +294,7 @@ Module.register("weatherforecast", { return; } - params += "&cnt=" + (this.config.maxNumberOfDays·<·1·||·this.config.maxNumberOfDays·>·17 ? 7 : this.config.maxNumberOfDays); + params += "&cnt=" + (this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays); params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; From 3d73153e5971c7fbe1974387dafe014dab3d6448 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 20:19:03 +0200 Subject: [PATCH 11/13] Revert "Renamed function" This reverts commit 6aa0a4a4 --- modules/default/calendar/calendar.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d8491a76..7d51ed88 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -241,7 +241,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.truncateTitle(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -389,7 +389,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.truncateTitle(event.location); + descCell.innerHTML = this.titleTransform(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -710,8 +710,8 @@ Module.register("calendar", { return string.charAt(0).toUpperCase() + string.slice(1); }, - /* truncateTitle(title) - * Transforms the title of an event and the location for usage. + /* titleTransform(title) + * Transforms the title of an event for usage. * Replaces parts of the text as defined in config.titleReplace. * Shortens title based on config.maxTitleLength and config.wrapEvents * @@ -719,7 +719,7 @@ Module.register("calendar", { * * return string - The transformed title. */ - truncateTitle: function (title) { + titleTransform: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; From efbb9648c4f2a6e738cf432ae9b0b56cce7e0cf3 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 20:23:59 +0200 Subject: [PATCH 12/13] Introduce new function for location title shortening. --- modules/default/calendar/calendar.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 7d51ed88..f5ecab70 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -389,7 +389,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.titleTransform(event.location); + descCell.innerHTML = this.locationTitleShorten(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -736,6 +736,19 @@ Module.register("calendar", { return title; }, + /* + * locationTitleShorten(title) + * Shortens the event location title based on config.maxTitleLength and config.wrapEvents + * + * argument title string - the event location title to shorten + * + * return string - The shortened title. + */ + locationTitleShorten: function (title) { + title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); + return title; + }, + /* broadcastEvents() * Broadcasts the events to all other modules for reuse. * The all events available in one array, sorted on startdate. From a692d6be09e4653e4229939bde3e530ed98c35a4 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 22:25:07 +0200 Subject: [PATCH 13/13] Reworked titleTransform. --- modules/default/calendar/calendar.js | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index f5ecab70..9a1cc350 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -17,8 +17,11 @@ Module.register("calendar", { displayRepeatingCountTitle: false, defaultRepeatingCountTitle: "", maxTitleLength: 25, + maxLocationTitleLength: 25, wrapEvents: false, // wrap events to multiple lines breaking at maxTitleLength + wrapLocationEvents: false, maxTitleLines: 3, + maxEventTitleLines: 3, fetchInterval: 5 * 60 * 1000, // Update every 5 minutes. animationSpeed: 2000, fade: true, @@ -45,6 +48,9 @@ Module.register("calendar", { "De verjaardag van ": "", "'s birthday": "" }, + locationTitleReplace: { + "street ": "" + }, broadcastEvents: true, excludedEvents: [], sliceMultiDayEvents: false, @@ -241,7 +247,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.titleTransform(event.title, this.config.titleReplace, this.config.wrapEvents, this.config.maxTitleLength, this.config.maxTitleLines) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -389,7 +395,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.locationTitleShorten(event.location); + descCell.innerHTML = this.titleTransform(event.location, this.config.locationTitleReplace, this.config.wrapLocationEvents, this.config.maxLocationTitleLength, this.config.maxEventTitleLines); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -719,9 +725,9 @@ Module.register("calendar", { * * return string - The transformed title. */ - titleTransform: function (title) { - for (var needle in this.config.titleReplace) { - var replacement = this.config.titleReplace[needle]; + titleTransform: function (title, titleReplace, wrapEvents, maxTitleLength, maxTitleLines) { + for (var needle in titleReplace) { + var replacement = titleReplace[needle]; var regParts = needle.match(/^\/(.+)\/([gim]*)$/); if (regParts) { @@ -732,20 +738,7 @@ Module.register("calendar", { title = title.replace(needle, replacement); } - title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); - return title; - }, - - /* - * locationTitleShorten(title) - * Shortens the event location title based on config.maxTitleLength and config.wrapEvents - * - * argument title string - the event location title to shorten - * - * return string - The shortened title. - */ - locationTitleShorten: function (title) { - title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); + title = this.shorten(title, maxTitleLength, wrapEvents, maxTitleLines); return title; },