From a4d73e2a67a8f6b507a76a878221682c7666a89b Mon Sep 17 00:00:00 2001 From: Bryan Zhu Date: Sat, 1 Aug 2020 17:39:58 -0400 Subject: [PATCH] amended code according to pull request reviews --- modules/default/weather/weather.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 83db10d2..6fbbc418 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -11,7 +11,7 @@ Module.register("weather", { defaults: { weatherProvider: "openweathermap", roundTemp: false, - type: "current", + type: "current", // current, forecast, daily (equivalent to forecast), hourly (only with OpenWeatherMap /onecall endpoint) lat: 0, lon: 0, @@ -127,10 +127,17 @@ Module.register("weather", { // Select the template depending on the display type. getTemplate: function () { - if (this.config.type === "daily") { - return `forecast.njk`; + switch (this.config.type.toLowerCase()) { + case "current": + return `current.njk`; + case "hourly": + return `hourly.njk`; + case "daily": + case "forecast": + return `forecast.njk`; + default: + return `${this.config.type.toLowerCase()}.njk`; } - return `${this.config.type.toLowerCase()}.njk`; }, // Add all the data to the template.