From 5e573ca980edffa9e5b380fa9d1a94b60cf7490e Mon Sep 17 00:00:00 2001 From: DanielWeeber Date: Tue, 15 Aug 2017 19:54:35 +0200 Subject: [PATCH 1/4] Show Scale of Temperature if config flag is set --- .../default/weatherforecast/weatherforecast.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index aab3aa15..44f420b1 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -24,6 +24,7 @@ Module.register("weatherforecast",{ fade: true, fadePoint: 0.25, // Start on 1/4th of the list. colored: false, + scale: false, // "C" or "F" initialLoadDelay: 2500, // 2.5 seconds delay. This delay is used to keep the OpenWeather API happy. retryDelay: 2500, @@ -141,11 +142,25 @@ Module.register("weatherforecast",{ var maxTempCell = document.createElement("td"); maxTempCell.innerHTML = forecast.maxTemp; + if (this.config.scale == "C" || this.config.scale == "c") { + maxTempCell.innerHTML += " °C"; + } else { + if (this.config.scale == "F" || this.config.scale == "f") { + maxTempCell.innerHTML += " °F"; + } + } maxTempCell.className = "align-right bright max-temp"; row.appendChild(maxTempCell); var minTempCell = document.createElement("td"); minTempCell.innerHTML = forecast.minTemp; + if (scale == "C" || scale == "c") { + minTempCell.innerHTML += " °C"; + } else { + if (scale == "F" || scale == "f") { + minTempCell.innerHTML += " °F"; + } + } minTempCell.className = "align-right min-temp"; row.appendChild(minTempCell); From cb2cc0cb9e6f5170762f3d957b2918b8c20ae18a Mon Sep 17 00:00:00 2001 From: DanielWeeber Date: Tue, 15 Aug 2017 20:57:18 +0200 Subject: [PATCH 2/4] Fix linting? --- modules/default/weatherforecast/weatherforecast.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 44f420b1..fa78b3ef 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -142,10 +142,10 @@ Module.register("weatherforecast",{ var maxTempCell = document.createElement("td"); maxTempCell.innerHTML = forecast.maxTemp; - if (this.config.scale == "C" || this.config.scale == "c") { + if(this.config.scale == "C" || this.config.scale == "c") { maxTempCell.innerHTML += " °C"; } else { - if (this.config.scale == "F" || this.config.scale == "f") { + if(this.config.scale == "F" || this.config.scale == "f") { maxTempCell.innerHTML += " °F"; } } @@ -154,10 +154,10 @@ Module.register("weatherforecast",{ var minTempCell = document.createElement("td"); minTempCell.innerHTML = forecast.minTemp; - if (scale == "C" || scale == "c") { + if(this.config.scale == "C" || this.config.scale == "c") { minTempCell.innerHTML += " °C"; } else { - if (scale == "F" || scale == "f") { + if(this.config.scale == "F" || this.config.scale == "f") { minTempCell.innerHTML += " °F"; } } From 5568e0c2adc73aa20bebb5bfc47df65fea273b05 Mon Sep 17 00:00:00 2001 From: DanielWeeber Date: Wed, 16 Aug 2017 10:00:38 +0200 Subject: [PATCH 3/4] Change Two Conditionals to UpperCase-If --- modules/default/weatherforecast/weatherforecast.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index fa78b3ef..7e33b4e1 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -142,10 +142,10 @@ Module.register("weatherforecast",{ var maxTempCell = document.createElement("td"); maxTempCell.innerHTML = forecast.maxTemp; - if(this.config.scale == "C" || this.config.scale == "c") { + if(this.config.scale.toUpperCase() == "C") { maxTempCell.innerHTML += " °C"; } else { - if(this.config.scale == "F" || this.config.scale == "f") { + if(this.config.scale.toUpperCase() == "F") { maxTempCell.innerHTML += " °F"; } } @@ -154,10 +154,10 @@ Module.register("weatherforecast",{ var minTempCell = document.createElement("td"); minTempCell.innerHTML = forecast.minTemp; - if(this.config.scale == "C" || this.config.scale == "c") { + if(this.config.scale.toUpperCase() == "C") { minTempCell.innerHTML += " °C"; } else { - if(this.config.scale == "F" || this.config.scale == "f") { + if(this.config.scale.toUpperCase() == "F") { minTempCell.innerHTML += " °F"; } } From 2d2f159e04d9287a59bc059b570696f75fdf295b Mon Sep 17 00:00:00 2001 From: DanielWeeber Date: Wed, 16 Aug 2017 12:11:57 +0200 Subject: [PATCH 4/4] Small change for re-running Travis CI --- 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 7e33b4e1..479122d0 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -24,7 +24,7 @@ Module.register("weatherforecast",{ fade: true, fadePoint: 0.25, // Start on 1/4th of the list. colored: false, - scale: false, // "C" or "F" + scale: false, initialLoadDelay: 2500, // 2.5 seconds delay. This delay is used to keep the OpenWeather API happy. retryDelay: 2500,