@ -322,6 +322,20 @@ WeatherMenuButton.prototype = {
}
} ,
parse _day : function ( abr ) {
let yahoo _days = [ 'monday' , 'tuesday' , 'wednesday' , 'thursday' , 'friday' , 'saturday' , 'sunday' ] ;
for ( var i = 0 ; i < yahoo _days . length ; i ++ ) {
if ( yahoo _days [ i ] . substr ( 0 , abr . length ) == abr . toLowerCase ( ) ) {
return i ;
}
}
return 0 ;
} ,
get _locale _day : function ( abr ) {
let days = [ _ ( 'Monday' ) , _ ( 'Tuesday' ) , _ ( 'Wednesday' ) , _ ( 'Thursday' ) , _ ( 'Friday' ) , _ ( 'Saturday' ) , _ ( 'Sunday' ) ] ;
return days [ this . parse _day ( abr ) ] . substr ( 0 , abr . length ) ;
} ,
load _json : function ( url ) {
var session = new Soup . SessionSync ( ) ;
@ -349,7 +363,7 @@ WeatherMenuButton.prototype = {
this . load _json _async ( WEATHER _URL , function ( weather ) {
let location = CITY _DISPLAYED ;
let comment = this . get _weather _condition ( weather . get _object _member ( 'condition' ) . get _string _member ( 'code' ) ) ; //weather.get_object_member('condition').get_string_member('text');
let comment = this . get _weather _condition ( weather . get _object _member ( 'condition' ) . get _string _member ( 'code' ) ) ;
let temperature = weather . get _object _member ( 'condition' ) . get _double _member ( 'temperature' ) ;
let temperature _unit = '\u00b0' + weather . get _object _member ( 'units' ) . get _string _member ( 'temperature' ) ;
let humidity = weather . get _object _member ( 'atmosphere' ) . get _string _member ( 'humidity' ) + ' %' ;
@ -382,11 +396,11 @@ WeatherMenuButton.prototype = {
let forecastData = forecast2 [ i ] . get _object ( ) . get _object _member ( 'item' ) . get _object _member ( 'forecast' ) ;
let code = forecastData . get _string _member ( 'code' ) ;
let comment = this . get _weather _condition ( code ) ; //forecastData.get_string_member('text');
let comment = this . get _weather _condition ( code ) ;
let t _low = forecastData . get _string _member ( 'low' ) ;
let t _high = forecastData . get _string _member ( 'high' ) ;
forecastUi . Day . text = date _string [ i ] + ' (' + forecastData . get _string _member ( 'day' ) + ')' ;
forecastUi . Day . text = date _string [ i ] + ' (' + this . get _locale _day ( forecastData . get _string _member ( 'day' ) ) + ')' ;
forecastUi . Temperature . text = t _low + '\u2013' + t _high + ' \u00b0' + UNITS . toUpperCase ( ) ;
forecastUi . Summary . text = comment ;
forecastUi . Icon . icon _name = this . get _weather _icon ( code ) ;