diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 35c03404..d7116930 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -64,6 +64,13 @@ The following properties can be configured:
Default value: config.units + + roundTemperature + Round temperature value to nearest integer.
+
Possible values: true (round to integer) or false (display exact value with decimal point) +
Default value: false + + updateInterval How often does the content needs to be fetched? (Milliseconds)
diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index a379332d..43b57f4f 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -15,6 +15,7 @@ Module.register("currentweather",{ locationID: false, appid: "", units: config.units, + roundTemperature: false, updateInterval: 10 * 60 * 1000, // every 10 minutes animationSpeed: 1000, timeFormat: config.timeFormat, @@ -181,9 +182,13 @@ Module.register("currentweather",{ weatherIcon.className = "wi weathericon " + this.weatherType; large.appendChild(weatherIcon); + var temp = this.temperature; + if (this.config.roundTemperature) { + temp = Math.round(temp); + } var temperature = document.createElement("span"); temperature.className = "bright"; - temperature.innerHTML = " " + this.temperature + "°"; + temperature.innerHTML = " " + temp + "°"; large.appendChild(temperature); wrapper.appendChild(large); diff --git a/modules/default/weatherforecast/README.md b/modules/default/weatherforecast/README.md index 6b88d21e..8b80e982 100644 --- a/modules/default/weatherforecast/README.md +++ b/modules/default/weatherforecast/README.md @@ -64,6 +64,13 @@ The following properties can be configured:
Default value: config.units + + roundTemperature + Round temperature values to nearest integer.
+
Possible values: true (round to integer) or false (display exact value with decimal point) +
Default value: false + + maxNumberOfDays How many days of forecast to return. Specified by config.js
diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 51c3f56e..014e00cd 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -15,6 +15,7 @@ Module.register("weatherforecast",{ locationID: false, appid: "", units: config.units, + roundTemperature: false, maxNumberOfDays: 7, showRainAmount: false, updateInterval: 10 * 60 * 1000, // every 10 minutes @@ -133,13 +134,20 @@ Module.register("weatherforecast",{ icon.className = "wi weathericon " + forecast.icon; iconCell.appendChild(icon); + var maxTemp = forecast.maxTemp; + var minTemp = forecast.minTemp; + if (this.config.roundTemperature) { + maxTemp = Math.round(maxTemp); + minTemp = Math.round(minTemp); + } + var maxTempCell = document.createElement("td"); - maxTempCell.innerHTML = forecast.maxTemp; + maxTempCell.innerHTML = maxTemp; maxTempCell.className = "align-right bright max-temp"; row.appendChild(maxTempCell); var minTempCell = document.createElement("td"); - minTempCell.innerHTML = forecast.minTemp; + minTempCell.innerHTML = minTemp; minTempCell.className = "align-right min-temp"; row.appendChild(minTempCell); @@ -352,3 +360,4 @@ Module.register("weatherforecast",{ return parseFloat(temperature).toFixed(1); } }); +