diff --git a/js/weather/weather.js b/js/weather/weather.js index 6db8ea96..8147be6f 100644 --- a/js/weather/weather.js +++ b/js/weather/weather.js @@ -31,7 +31,8 @@ var weather = { forecastEndpoint: 'forecast/daily', updateInterval: config.weather.interval || 6000, 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'), _sunset = moment(data.sys.sunset*1000).format('HH:mm'); - var _newWindHtml = ' ' + this.ms2Beaufort(_wind), - _newSunHtml = ' ' + _sunrise; + var _newWindHtml = ' ' + this.ms2Beaufort(_wind) + '', + _newSunHtml = ' ' + _sunrise + ''; if (_sunrise < _now && _sunset > _now) { - _newSunHtml = ' ' + _sunset; + _newSunHtml = ' ' + _sunset + ''; } - $(this.windSunLocation).updateWithText(_newWindHtml + ' ' + _newSunHtml, this.fadeInterval); + $(this.windSunLocation).updateWithText(_newWindHtml + ' ' + _newSunHtml,this.fadeInterval); }.bind(this), error: function () { @@ -118,28 +119,44 @@ weather.updateWeatherForecast = function () { success: function (data) { var _opacity = 1, - _forecastHtml = ''; + _forecastHtml = '', + _forecastHtml2 = '', + _forecastHtml3 = '', + _forecastHtml4 = ''; - _forecastHtml += ''; + _forecastHtml = '
'; for (var i = 0, count = data.list.length; i < count; i++) { var _forecast = data.list[i]; + + if (this.orientation == 'vertical') { + _forecastHtml2 = ''; + _forecastHtml3 = ''; + _forecastHtml4 = ''; + } - _forecastHtml += ''; - - _forecastHtml += ''; - _forecastHtml += ''; - _forecastHtml += ''; - _forecastHtml += ''; - - _forecastHtml += ''; + _forecastHtml += ''; + _forecastHtml2 += ''; + _forecastHtml3 += ''; + _forecastHtml4 += ''; _opacity -= 0.155; + if (this.orientation == 'vertical') { + _forecastHtml += _forecastHtml2 + _forecastHtml3 + _forecastHtml4 + ''; + } + } + _forecastHtml += '', + _forecastHtml2 += '', + _forecastHtml3 += '', + _forecastHtml4 += ''; + + if (this.orientation == 'vertical') { + _forecastHtml += '
' + moment(_forecast.dt, 'X').format('ddd') + '' + this.roundValue(_forecast.temp.max) + '' + this.roundValue(_forecast.temp.min) + '
' + moment(_forecast.dt, 'X').format('ddd') + '' + this.roundValue(_forecast.temp.max) + '' + this.roundValue(_forecast.temp.min) + '
'; + } else { + _forecastHtml += _forecastHtml2 + _forecastHtml3 + _forecastHtml4 +''; } - - _forecastHtml += ''; $(this.forecastLocation).updateWithText(_forecastHtml, this.fadeInterval); @@ -158,12 +175,13 @@ weather.init = function () { } if (this.params.cnt === undefined) { - this.params.cnt = 5; + this.params.cnt = 6; } this.intervalId = setInterval(function () { this.updateCurrentWeather(); this.updateWeatherForecast(); }.bind(this), this.updateInterval); - + this.updateCurrentWeather(); + this.updateWeatherForecast(); }