Support showing wind direction with an arrow

As described in https://github.com/MichMich/MagicMirror/issues/871 this feature lets user use arrow instead of an abbreviation for wind directions. This can be especially helpful on languages like Finnish that do not have all the compass directions English has.
This commit is contained in:
Mikko Tapionlinna 2017-04-24 23:54:32 +03:00 committed by GitHub
parent a6485b61a4
commit 0e486b45e1

View File

@ -94,6 +94,7 @@ Module.register("currentweather",{
this.windSpeed = null; this.windSpeed = null;
this.windDirection = null; this.windDirection = null;
this.windDeg = null;
this.sunriseSunsetTime = null; this.sunriseSunsetTime = null;
this.sunriseSunsetIcon = null; this.sunriseSunsetIcon = null;
this.temperature = null; this.temperature = null;
@ -122,7 +123,13 @@ Module.register("currentweather",{
if (this.config.showWindDirection) { if (this.config.showWindDirection) {
var windDirection = document.createElement("sup"); var windDirection = document.createElement("sup");
if (this.config.showWindDirectionAsArrow) {
if(this.windDeg !== null) {
windDirection.innerHTML = " &nbsp;<i class=\"fa fa-long-arrow-down\" style=\"transform:rotate("+this.windDeg+"deg);\"></i>&nbsp;";
}
} else {
windDirection.innerHTML = " " + this.translate(this.windDirection); windDirection.innerHTML = " " + this.translate(this.windDirection);
}
small.appendChild(windDirection); small.appendChild(windDirection);
} }
var spacer = document.createElement("span"); var spacer = document.createElement("span");
@ -329,6 +336,7 @@ Module.register("currentweather",{
this.windDirection = this.deg2Cardinal(data.wind.deg); this.windDirection = this.deg2Cardinal(data.wind.deg);
this.windDeg = data.wind.deg;
this.weatherType = this.config.iconTable[data.weather[0].icon]; this.weatherType = this.config.iconTable[data.weather[0].icon];
var now = new Date(); var now = new Date();