From a7db8cf7cdb818516b6e3a97f044ce65a44ce302 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Wed, 17 Aug 2016 21:51:48 -0500 Subject: [PATCH 1/5] Humidity data to the current weather module --- modules/default/currentweather/README.md | 11 ++- .../default/currentweather/currentweather.css | 4 + .../default/currentweather/currentweather.js | 85 +++++++++++-------- 3 files changed, 64 insertions(+), 36 deletions(-) diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 2a6f7844..1cafd11a 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -14,7 +14,7 @@ modules: [ config: { // See 'Configuration options' for more information. location: 'Amsterdam,Netherlands', - locationID: '', //Location ID from http://bulk.openweather.org/sample/ + locationID: '', //Location ID from http://bulk.openweather.org/sample/ appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key. } } @@ -35,7 +35,7 @@ The following properties can be configured: - + location The location used for weather information.
@@ -106,6 +106,13 @@ The following properties can be configured: + showHumidity + Show the current humidity
+
Possible values: true or false +
Default value: false + + + useBeaufort Pick between using the Beaufort scale for wind speed or using the default units.

Possible values: true or false diff --git a/modules/default/currentweather/currentweather.css b/modules/default/currentweather/currentweather.css index 9e9d9ed3..08c040d6 100644 --- a/modules/default/currentweather/currentweather.css +++ b/modules/default/currentweather/currentweather.css @@ -6,3 +6,7 @@ -webkit-transform: translate(0, -3px); /* Safari */ transform: translate(0, -3px); } + +.currentweather .humidity-padding { + padding-bottom: 6px; +} diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index db3d5de2..5875c121 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -23,6 +23,7 @@ Module.register("currentweather",{ showWindDirection: true, useBeaufort: true, lang: config.language, + showHumidity: false, initialLoadDelay: 0, // 0 seconds delay retryDelay: 2500, @@ -142,6 +143,21 @@ Module.register("currentweather",{ sunriseSunsetTime.innerHTML = " " + this.sunriseSunsetTime; small.appendChild(sunriseSunsetTime); + wrapper.appendChild(small); + + if (this.config.showHumidity) { + var middle = document.createElement("div"); + middle.className = "normal small humidity-padding"; + + var humidity = document.createElement("span"); + humidity.innerHTML = "Humidity: " + this.humidity + "%"; // TODO: Localization + var br = document.createElement("br"); + + middle.appendChild(humidity); + middle.appendChild(br); + wrapper.appendChild(middle); + } + var large = document.createElement("div"); large.className = "large light"; @@ -154,8 +170,8 @@ Module.register("currentweather",{ temperature.innerHTML = " " + this.temperature + "°"; large.appendChild(temperature); - wrapper.appendChild(small); wrapper.appendChild(large); + return wrapper; }, @@ -224,6 +240,7 @@ Module.register("currentweather",{ return; } + this.humidity = parseFloat(data.main.humidity); this.temperature = this.roundValue(data.main.temp); if (this.config.useBeaufort){ @@ -315,39 +332,39 @@ Module.register("currentweather",{ */ deg2Cardinal: function(deg) { - if (deg>11.25 && deg<=33.75){ - return "NNE"; - } else if (deg > 33.75 && deg <= 56.25) { - return "NE"; - } else if (deg > 56.25 && deg <= 78.75) { - return "ENE"; - } else if (deg > 78.75 && deg <= 101.25) { - return "E"; - } else if (deg > 101.25 && deg <= 123.75) { - return "ESE"; - } else if (deg > 123.75 && deg <= 146.25) { - return "SE"; - } else if (deg > 146.25 && deg <= 168.75) { - return "SSE"; - } else if (deg > 168.75 && deg <= 191.25) { - return "S"; - } else if (deg > 191.25 && deg <= 213.75) { - return "SSW"; - } else if (deg > 213.75 && deg <= 236.25) { - return "SW"; - } else if (deg > 236.25 && deg <= 258.75) { - return "WSW"; - } else if (deg > 258.75 && deg <= 281.25) { - return "W"; - } else if (deg > 281.25 && deg <= 303.75) { - return "WNW"; - } else if (deg > 303.75 && deg <= 326.25) { - return "NW"; - } else if (deg > 326.25 && deg <= 348.75) { - return "NNW"; - } else { - return "N"; - } + if (deg>11.25 && deg<=33.75){ + return "NNE"; + } else if (deg > 33.75 && deg <= 56.25) { + return "NE"; + } else if (deg > 56.25 && deg <= 78.75) { + return "ENE"; + } else if (deg > 78.75 && deg <= 101.25) { + return "E"; + } else if (deg > 101.25 && deg <= 123.75) { + return "ESE"; + } else if (deg > 123.75 && deg <= 146.25) { + return "SE"; + } else if (deg > 146.25 && deg <= 168.75) { + return "SSE"; + } else if (deg > 168.75 && deg <= 191.25) { + return "S"; + } else if (deg > 191.25 && deg <= 213.75) { + return "SSW"; + } else if (deg > 213.75 && deg <= 236.25) { + return "SW"; + } else if (deg > 236.25 && deg <= 258.75) { + return "WSW"; + } else if (deg > 258.75 && deg <= 281.25) { + return "W"; + } else if (deg > 281.25 && deg <= 303.75) { + return "WNW"; + } else if (deg > 303.75 && deg <= 326.25) { + return "NW"; + } else if (deg > 326.25 && deg <= 348.75) { + return "NNW"; + } else { + return "N"; + } }, From c6f424201b7b3fe9d8d444250937074d1179eee7 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Thu, 18 Aug 2016 09:32:19 -0500 Subject: [PATCH 2/5] Fix indentation and spacing --- modules/default/currentweather/README.md | 6 +- .../default/currentweather/currentweather.js | 67 +++++++++---------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 1cafd11a..3df88173 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -14,7 +14,7 @@ modules: [ config: { // See 'Configuration options' for more information. location: 'Amsterdam,Netherlands', - locationID: '', //Location ID from http://bulk.openweather.org/sample/ + locationID: '', //Location ID from http://bulk.openweather.org/sample/ appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key. } } @@ -35,7 +35,7 @@ The following properties can be configured: - + location The location used for weather information.
@@ -112,7 +112,7 @@ 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 diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 5875c121..57884ad7 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -171,7 +171,6 @@ Module.register("currentweather",{ large.appendChild(temperature); wrapper.appendChild(large); - return wrapper; }, @@ -332,39 +331,39 @@ Module.register("currentweather",{ */ deg2Cardinal: function(deg) { - if (deg>11.25 && deg<=33.75){ - return "NNE"; - } else if (deg > 33.75 && deg <= 56.25) { - return "NE"; - } else if (deg > 56.25 && deg <= 78.75) { - return "ENE"; - } else if (deg > 78.75 && deg <= 101.25) { - return "E"; - } else if (deg > 101.25 && deg <= 123.75) { - return "ESE"; - } else if (deg > 123.75 && deg <= 146.25) { - return "SE"; - } else if (deg > 146.25 && deg <= 168.75) { - return "SSE"; - } else if (deg > 168.75 && deg <= 191.25) { - return "S"; - } else if (deg > 191.25 && deg <= 213.75) { - return "SSW"; - } else if (deg > 213.75 && deg <= 236.25) { - return "SW"; - } else if (deg > 236.25 && deg <= 258.75) { - return "WSW"; - } else if (deg > 258.75 && deg <= 281.25) { - return "W"; - } else if (deg > 281.25 && deg <= 303.75) { - return "WNW"; - } else if (deg > 303.75 && deg <= 326.25) { - return "NW"; - } else if (deg > 326.25 && deg <= 348.75) { - return "NNW"; - } else { - return "N"; - } + if (deg>11.25 && deg<=33.75){ + return "NNE"; + } else if (deg > 33.75 && deg <= 56.25) { + return "NE"; + } else if (deg > 56.25 && deg <= 78.75) { + return "ENE"; + } else if (deg > 78.75 && deg <= 101.25) { + return "E"; + } else if (deg > 101.25 && deg <= 123.75) { + return "ESE"; + } else if (deg > 123.75 && deg <= 146.25) { + return "SE"; + } else if (deg > 146.25 && deg <= 168.75) { + return "SSE"; + } else if (deg > 168.75 && deg <= 191.25) { + return "S"; + } else if (deg > 191.25 && deg <= 213.75) { + return "SSW"; + } else if (deg > 213.75 && deg <= 236.25) { + return "SW"; + } else if (deg > 236.25 && deg <= 258.75) { + return "WSW"; + } else if (deg > 258.75 && deg <= 281.25) { + return "W"; + } else if (deg > 281.25 && deg <= 303.75) { + return "WNW"; + } else if (deg > 303.75 && deg <= 326.25) { + return "NW"; + } else if (deg > 326.25 && deg <= 348.75) { + return "NNW"; + } else { + return "N"; + } }, From a592ca25ffb7a578f36981e77ce27b16a47048d1 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Sun, 28 Aug 2016 01:52:08 -0500 Subject: [PATCH 3/5] Add in icon for the current humidity --- modules/default/currentweather/currentweather.css | 4 ++++ modules/default/currentweather/currentweather.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/default/currentweather/currentweather.css b/modules/default/currentweather/currentweather.css index 08c040d6..768b0f8d 100644 --- a/modules/default/currentweather/currentweather.css +++ b/modules/default/currentweather/currentweather.css @@ -7,6 +7,10 @@ transform: translate(0, -3px); } +.currentweather .humidityIcon { + padding-right: 8px; +} + .currentweather .humidity-padding { padding-bottom: 6px; } diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 57884ad7..87e4d04a 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -149,10 +149,15 @@ Module.register("currentweather",{ var middle = document.createElement("div"); middle.className = "normal small humidity-padding"; + var humidityIcon = document.createElement("span"); + humidityIcon.className = "wi wi-humidity humidityIcon"; + small.appendChild(sunriseSunsetIcon); + var humidity = document.createElement("span"); - humidity.innerHTML = "Humidity: " + this.humidity + "%"; // TODO: Localization + humidity.innerHTML = this.humidity + "%"; var br = document.createElement("br"); + middle.appendChild(humidityIcon); middle.appendChild(humidity); middle.appendChild(br); wrapper.appendChild(middle); From 853fa870121f89905ab8e8bebb676cceb3e876bb Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Sun, 28 Aug 2016 01:58:56 -0500 Subject: [PATCH 4/5] Slight change to padding of humidity icon, just too much before --- modules/default/currentweather/currentweather.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/currentweather/currentweather.css b/modules/default/currentweather/currentweather.css index 768b0f8d..a40be878 100644 --- a/modules/default/currentweather/currentweather.css +++ b/modules/default/currentweather/currentweather.css @@ -8,7 +8,7 @@ } .currentweather .humidityIcon { - padding-right: 8px; + padding-right: 4px; } .currentweather .humidity-padding { From d8d425c963c412740c528a46e5ec4482db603295 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sat, 1 Oct 2016 14:06:10 +0200 Subject: [PATCH 5/5] Visual changes. --- .../default/currentweather/currentweather.js | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 170e9ab6..587080db 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -118,6 +118,7 @@ Module.register("currentweather",{ var small = document.createElement("div"); small.className = "normal medium"; + var windIcon = document.createElement("span"); windIcon.className = "wi wi-strong-wind dimmed"; small.appendChild(windIcon); @@ -135,6 +136,18 @@ Module.register("currentweather",{ spacer.innerHTML = " "; small.appendChild(spacer); + if (this.config.showHumidity) { + var humidity = document.createElement("span"); + humidity.innerHTML = this.humidity; + + var humidityIcon = document.createElement("sup"); + humidityIcon.className = "wi wi-humidity humidityIcon"; + humidityIcon.innerHTML = " "; + + small.appendChild(humidity); + small.appendChild(humidityIcon); + } + var sunriseSunsetIcon = document.createElement("span"); sunriseSunsetIcon.className = "wi dimmed " + this.sunriseSunsetIcon; small.appendChild(sunriseSunsetIcon); @@ -145,24 +158,6 @@ Module.register("currentweather",{ wrapper.appendChild(small); - if (this.config.showHumidity) { - var middle = document.createElement("div"); - middle.className = "normal small humidity-padding"; - - var humidityIcon = document.createElement("span"); - humidityIcon.className = "wi wi-humidity humidityIcon"; - small.appendChild(sunriseSunsetIcon); - - var humidity = document.createElement("span"); - humidity.innerHTML = this.humidity + "%"; - var br = document.createElement("br"); - - middle.appendChild(humidityIcon); - middle.appendChild(humidity); - middle.appendChild(br); - wrapper.appendChild(middle); - } - var large = document.createElement("div"); large.className = "large light";