implemented roundTemperature in weather modules

This commit is contained in:
Olexandr Savchuk 2016-12-02 17:17:58 +01:00
parent c949548150
commit 3c33969d23
4 changed files with 31 additions and 3 deletions

View File

@ -64,6 +64,13 @@ The following properties can be configured:
<br><b>Default value:</b> <code>config.units</code> <br><b>Default value:</b> <code>config.units</code>
</td> </td>
</tr> </tr>
<tr>
<td><code>roundTemperature</code></td>
<td>Round temperature value to nearest integer.<br>
<br><b>Possible values:</b> <code>true</code> (round to integer) or <code>false</code> (display exact value with decimal point)
<br><b>Default value:</b> <code>false</code>
</td>
</tr>
<tr> <tr>
<td><code>updateInterval</code></td> <td><code>updateInterval</code></td>
<td>How often does the content needs to be fetched? (Milliseconds)<br> <td>How often does the content needs to be fetched? (Milliseconds)<br>

View File

@ -15,6 +15,7 @@ Module.register("currentweather",{
locationID: false, locationID: false,
appid: "", appid: "",
units: config.units, units: config.units,
roundTemperature: false,
updateInterval: 10 * 60 * 1000, // every 10 minutes updateInterval: 10 * 60 * 1000, // every 10 minutes
animationSpeed: 1000, animationSpeed: 1000,
timeFormat: config.timeFormat, timeFormat: config.timeFormat,
@ -181,9 +182,13 @@ Module.register("currentweather",{
weatherIcon.className = "wi weathericon " + this.weatherType; weatherIcon.className = "wi weathericon " + this.weatherType;
large.appendChild(weatherIcon); large.appendChild(weatherIcon);
var temp = this.temperature;
if (this.config.roundTemperature) {
temp = Math.round(temp);
}
var temperature = document.createElement("span"); var temperature = document.createElement("span");
temperature.className = "bright"; temperature.className = "bright";
temperature.innerHTML = " " + this.temperature + "&deg;"; temperature.innerHTML = " " + temp + "&deg;";
large.appendChild(temperature); large.appendChild(temperature);
wrapper.appendChild(large); wrapper.appendChild(large);

View File

@ -64,6 +64,13 @@ The following properties can be configured:
<br><b>Default value:</b> <code>config.units</code> <br><b>Default value:</b> <code>config.units</code>
</td> </td>
</tr> </tr>
<tr>
<td><code>roundTemperature</code></td>
<td>Round temperature values to nearest integer.<br>
<br><b>Possible values:</b> <code>true</code> (round to integer) or <code>false</code> (display exact value with decimal point)
<br><b>Default value:</b> <code>false</code>
</td>
</tr>
<tr> <tr>
<td><code>maxNumberOfDays</code></td> <td><code>maxNumberOfDays</code></td>
<td>How many days of forecast to return. Specified by config.js<br> <td>How many days of forecast to return. Specified by config.js<br>

View File

@ -15,6 +15,7 @@ Module.register("weatherforecast",{
locationID: false, locationID: false,
appid: "", appid: "",
units: config.units, units: config.units,
roundTemperature: false,
maxNumberOfDays: 7, maxNumberOfDays: 7,
showRainAmount: false, showRainAmount: false,
updateInterval: 10 * 60 * 1000, // every 10 minutes updateInterval: 10 * 60 * 1000, // every 10 minutes
@ -133,13 +134,20 @@ Module.register("weatherforecast",{
icon.className = "wi weathericon " + forecast.icon; icon.className = "wi weathericon " + forecast.icon;
iconCell.appendChild(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"); var maxTempCell = document.createElement("td");
maxTempCell.innerHTML = forecast.maxTemp; maxTempCell.innerHTML = maxTemp;
maxTempCell.className = "align-right bright max-temp"; maxTempCell.className = "align-right bright max-temp";
row.appendChild(maxTempCell); row.appendChild(maxTempCell);
var minTempCell = document.createElement("td"); var minTempCell = document.createElement("td");
minTempCell.innerHTML = forecast.minTemp; minTempCell.innerHTML = minTemp;
minTempCell.className = "align-right min-temp"; minTempCell.className = "align-right min-temp";
row.appendChild(minTempCell); row.appendChild(minTempCell);
@ -352,3 +360,4 @@ Module.register("weatherforecast",{
return parseFloat(temperature).toFixed(1); return parseFloat(temperature).toFixed(1);
} }
}); });