@ -205,11 +205,7 @@ WeatherMenuButton.prototype = {
} ,
get _weather _url : function ( ) {
return 'http://weather.yahooapis.com/forecastjson?u=' + this . unit _to _url ( ) + '&p=' + this . _woeid ;
} ,
get _forecast _url : function ( ) {
return 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20item.forecast%20from%20weather.forecast%20where%20location%3D%22' + this . _woeid + '%22%20%20and%20u="' + this . unit _to _url ( ) + '"' ;
return 'http://query.yahooapis.com/v1/public/yql?format=json&q=select location,wind,atmosphere,units,item.condition,item.forecast from weather.forecast where location="' + this . _woeid + '" and u="' + this . unit _to _url ( ) + '"' ;
} ,
get _weather _icon : function ( code ) {
@ -462,9 +458,13 @@ WeatherMenuButton.prototype = {
} ,
refreshWeather : function ( recurse ) {
// Refresh current weather
this . load _json _async ( this . get _weather _url ( ) , function ( weather ) {
this . load _json _async ( this . get _weather _url ( ) , function ( json ) {
let weather = json . get _object _member ( 'query' ) . get _object _member ( 'results' ) . get _object _member ( 'channel' ) ;
let weather _c = weather . get _object _member ( 'item' ) . get _object _member ( 'condition' ) ;
let forecast = weather . get _object _member ( 'item' ) . get _array _member ( 'forecast' ) . get _elements ( ) ;
/ * T O D O w o n ' t w o r k w i t h t h e n e w U R L
// Fixes wrong woeid if necessary
try {
// Wrong woeid specified
@ -485,33 +485,33 @@ WeatherMenuButton.prototype = {
} catch ( e ) {
global . log ( 'A ' + e . name + ' has occured: ' + e . message ) ;
}
* /
let location = weather . get _object _member ( 'location' ) . get _string _member ( 'city' ) ;
if ( this . _city != null && this . _city . length > 0 )
location = this . _city ;
let comment = weather . get _object _member ( 'condition' ) . get _string _member ( 'text' ) ;
// Refresh current weather
let comment = weather _c . get _string _member ( 'text' ) ;
if ( this . _translate _condition )
comment = this . get _weather _condition ( weather . get _obje ct _member ( 'condition' ) . get _string _member ( 'code' ) ) ;
comment = this . get _weather _condition ( weather _c . get _string _member ( 'code' ) ) ;
let temperature = weather . get _obje ct _member ( 'condition' ) . get _double _member ( 'temperature ' ) ;
let temperature = weather _c . get _string _member ( 'temp' ) ;
let humidity = weather . get _object _member ( 'atmosphere' ) . get _string _member ( 'humidity' ) + ' %' ;
let pressure = weather . get _object _member ( 'atmosphere' ) . get _double _member ( 'pressure' ) ;
let pressure = weather . get _object _member ( 'atmosphere' ) . get _string _member ( 'pressure' ) ;
let pressure _unit = weather . get _object _member ( 'units' ) . get _string _member ( 'pressure' ) ;
let wind _direction = weather . get _object _member ( 'wind' ) . get _string _member ( 'direction' ) ;
let wind = weather . get _object _member ( 'wind' ) . get _double _member ( 'speed' ) ;
let wind = weather . get _object _member ( 'wind' ) . get _string _member ( 'speed' ) ;
let wind _unit = weather . get _object _member ( 'units' ) . get _string _member ( 'speed' ) ;
let iconname = this . get _weather _icon _safely ( weather . get _obje ct _member ( 'condition' ) . get _string _member ( 'code' ) ) ;
let iconname = this . get _weather _icon _safely ( weather _c . get _string _member ( 'code' ) ) ;
this . _currentWeatherIcon . icon _name = this . _weatherIcon . icon _name = iconname ;
if ( this . _comment _in _panel )
if ( this . _comment _in _panel )
this . _weatherInfo . text = ( comment + ' ' + temperature + ' ' + this . unit _to _unicode ( ) ) ;
else
this . _weatherInfo . text = ( temperature + ' ' + this . unit _to _unicode ( ) ) ;
this . _currentWeatherSummary . text = comment ;
this . _currentWeatherLocation . text = location ;
this . _currentWeatherTemperature . text = temperature + ' ' + this . unit _to _unicode ( ) ;
@ -519,16 +519,11 @@ WeatherMenuButton.prototype = {
this . _currentWeatherPressure . text = pressure + ' ' + pressure _unit ;
this . _currentWeatherWind . text = ( wind _direction ? wind _direction + ' ' : '' ) + wind + ' ' + wind _unit ;
} ) ;
// Refresh forecast
this . load _json _async ( this . get _forecast _url ( ) , function ( forecast ) {
// Refresh forecast
let date _string = [ _ ( 'Today' ) , _ ( 'Tomorrow' ) ] ;
forecast = forecast . get _object _member ( 'query' ) . get _object _member ( 'results' ) . get _array _member ( 'channel' ) . get _elements ( ) ;
for ( let i = 0 ; i <= 1 ; i ++ ) {
let forecastUi = this . _forecast [ i ] ;
let forecastData = forecast [ i ] . get _object ( ) . get _object _member ( 'item' ) . get _object _member ( 'forecast' ) ;
let forecastData = forecast [ i ] . get _object ( ) ;
let code = forecastData . get _string _member ( 'code' ) ;
let t _low = forecastData . get _string _member ( 'low' ) ;