mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-30 13:09:34 +00:00
Merge pull request #58 from bitte-ein-bit/Weather-improvment
Improve Weather
This commit is contained in:
commit
7a50d6fb7c
@ -31,7 +31,8 @@ var weather = {
|
|||||||
forecastEndpoint: 'forecast/daily',
|
forecastEndpoint: 'forecast/daily',
|
||||||
updateInterval: config.weather.interval || 6000,
|
updateInterval: config.weather.interval || 6000,
|
||||||
fadeInterval: config.weather.fadeInterval || 1000,
|
fadeInterval: config.weather.fadeInterval || 1000,
|
||||||
intervalId: null
|
intervalId: null,
|
||||||
|
orientation: config.weather.orientation || 'vertical',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,14 +90,14 @@ weather.updateCurrentWeather = function () {
|
|||||||
_sunrise = moment(data.sys.sunrise*1000).format('HH:mm'),
|
_sunrise = moment(data.sys.sunrise*1000).format('HH:mm'),
|
||||||
_sunset = moment(data.sys.sunset*1000).format('HH:mm');
|
_sunset = moment(data.sys.sunset*1000).format('HH:mm');
|
||||||
|
|
||||||
var _newWindHtml = '<span class="wi wi-strong-wind xdimmed"></span> ' + this.ms2Beaufort(_wind),
|
var _newWindHtml = '<span class="wind"><span class="wi wi-strong-wind xdimmed"></span> ' + this.ms2Beaufort(_wind) + '</span>',
|
||||||
_newSunHtml = '<span class="wi wi-sunrise xdimmed"></span> ' + _sunrise;
|
_newSunHtml = '<span class="sun"><span class="wi wi-sunrise xdimmed"></span> ' + _sunrise + '</span>';
|
||||||
|
|
||||||
if (_sunrise < _now && _sunset > _now) {
|
if (_sunrise < _now && _sunset > _now) {
|
||||||
_newSunHtml = '<span class="wi wi-sunset xdimmed"></span> ' + _sunset;
|
_newSunHtml = '<span class="sun"><span class="wi wi-sunset xdimmed"></span> ' + _sunset + '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this.windSunLocation).updateWithText(_newWindHtml + ' ' + _newSunHtml, this.fadeInterval);
|
$(this.windSunLocation).updateWithText(_newWindHtml + ' ' + _newSunHtml,this.fadeInterval);
|
||||||
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
error: function () {
|
error: function () {
|
||||||
@ -118,28 +119,44 @@ weather.updateWeatherForecast = function () {
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
|
||||||
var _opacity = 1,
|
var _opacity = 1,
|
||||||
_forecastHtml = '';
|
_forecastHtml = '<tr>',
|
||||||
|
_forecastHtml2 = '<tr>',
|
||||||
|
_forecastHtml3 = '<tr>',
|
||||||
|
_forecastHtml4 = '<tr>';
|
||||||
|
|
||||||
_forecastHtml += '<table class="forecast-table">';
|
_forecastHtml = '<table class="forecast-table"><tr>';
|
||||||
|
|
||||||
for (var i = 0, count = data.list.length; i < count; i++) {
|
for (var i = 0, count = data.list.length; i < count; i++) {
|
||||||
|
|
||||||
var _forecast = data.list[i];
|
var _forecast = data.list[i];
|
||||||
|
|
||||||
_forecastHtml += '<tr style="opacity:' + _opacity + '">';
|
if (this.orientation == 'vertical') {
|
||||||
|
_forecastHtml2 = '';
|
||||||
|
_forecastHtml3 = '';
|
||||||
|
_forecastHtml4 = '';
|
||||||
|
}
|
||||||
|
|
||||||
_forecastHtml += '<td class="day">' + moment(_forecast.dt, 'X').format('ddd') + '</td>';
|
_forecastHtml += '<td style="opacity:' + _opacity + '" class="day">' + moment(_forecast.dt, 'X').format('ddd') + '</td>';
|
||||||
_forecastHtml += '<td class="icon-small ' + this.iconTable[_forecast.weather[0].icon] + '"></td>';
|
_forecastHtml2 += '<td style="opacity:' + _opacity + '" class="icon-small ' + this.iconTable[_forecast.weather[0].icon] + '"></td>';
|
||||||
_forecastHtml += '<td class="temp-max">' + this.roundValue(_forecast.temp.max) + '</td>';
|
_forecastHtml3 += '<td style="opacity:' + _opacity + '" class="temp-max">' + this.roundValue(_forecast.temp.max) + '</td>';
|
||||||
_forecastHtml += '<td class="temp-min">' + this.roundValue(_forecast.temp.min) + '</td>';
|
_forecastHtml4 += '<td style="opacity:' + _opacity + '" class="temp-min">' + this.roundValue(_forecast.temp.min) + '</td>';
|
||||||
|
|
||||||
_forecastHtml += '</tr>';
|
|
||||||
|
|
||||||
_opacity -= 0.155;
|
_opacity -= 0.155;
|
||||||
|
|
||||||
|
if (this.orientation == 'vertical') {
|
||||||
|
_forecastHtml += _forecastHtml2 + _forecastHtml3 + _forecastHtml4 + '</tr>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_forecastHtml += '</tr>',
|
||||||
|
_forecastHtml2 += '</tr>',
|
||||||
|
_forecastHtml3 += '</tr>',
|
||||||
|
_forecastHtml4 += '</tr>';
|
||||||
|
|
||||||
|
if (this.orientation == 'vertical') {
|
||||||
_forecastHtml += '</table>';
|
_forecastHtml += '</table>';
|
||||||
|
} else {
|
||||||
|
_forecastHtml += _forecastHtml2 + _forecastHtml3 + _forecastHtml4 +'</table>';
|
||||||
|
}
|
||||||
|
|
||||||
$(this.forecastLocation).updateWithText(_forecastHtml, this.fadeInterval);
|
$(this.forecastLocation).updateWithText(_forecastHtml, this.fadeInterval);
|
||||||
|
|
||||||
@ -158,12 +175,13 @@ weather.init = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.params.cnt === undefined) {
|
if (this.params.cnt === undefined) {
|
||||||
this.params.cnt = 5;
|
this.params.cnt = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.intervalId = setInterval(function () {
|
this.intervalId = setInterval(function () {
|
||||||
this.updateCurrentWeather();
|
this.updateCurrentWeather();
|
||||||
this.updateWeatherForecast();
|
this.updateWeatherForecast();
|
||||||
}.bind(this), this.updateInterval);
|
}.bind(this), this.updateInterval);
|
||||||
|
this.updateCurrentWeather();
|
||||||
|
this.updateWeatherForecast();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user