Weather forecast settings match current weather

This change makes the config of weather forecast more in line with
current weather. It uses the configured units (metric, imperial,
default) to determine the sign.
This commit is contained in:
Chris van Marle 2017-08-31 18:18:19 +02:00
parent afa0fb8da1
commit 62ce7a0e37

View File

@ -140,27 +140,28 @@ Module.register("weatherforecast",{
icon.className = "wi weathericon " + forecast.icon; icon.className = "wi weathericon " + forecast.icon;
iconCell.appendChild(icon); iconCell.appendChild(icon);
var maxTempCell = document.createElement("td"); var degreeLabel = "";
maxTempCell.innerHTML = forecast.maxTemp; if(this.config.scale) {
if(typeof(this.config.scale) == "string" && this.config.scale.toUpperCase() == "C") { switch(this.config.units) {
maxTempCell.innerHTML += " °C"; case "metric":
} else { degreeLabel = " °C";
if(typeof(this.config.scale) == "string" && this.config.scale.toUpperCase() == "F") { break;
maxTempCell.innerHTML += " °F"; case "imperial":
degreeLabel = " °F";
break;
case "default":
degreeLabel = "K";
break;
} }
} }
var maxTempCell = document.createElement("td");
maxTempCell.innerHTML = forecast.maxTemp + degreeLabel;
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 = forecast.minTemp + degreeLabel;
if(typeof(this.config.scale) == "string" && this.config.scale.toUpperCase() == "C") {
minTempCell.innerHTML += " °C";
} else {
if(typeof(this.config.scale) == "string" && this.config.scale.toUpperCase() == "F") {
minTempCell.innerHTML += " °F";
}
}
minTempCell.className = "align-right min-temp"; minTempCell.className = "align-right min-temp";
row.appendChild(minTempCell); row.appendChild(minTempCell);