Naive exception handling.

yahoo_weather
simon04 14 years ago
parent 93c3ea4606
commit b792b84a2d
  1. 31
      weather@venemo.net/extension.js

@ -132,25 +132,22 @@ WeatherMenuButton.prototype = {
}
},
load_json: function(url) {
var session = new Soup.SessionSync();
var message = Soup.Message.new('GET', url);
stat = session.send_message(message);
jp = new Json.Parser();
jp.load_from_data(message.response_body.data, -1);
return jp.get_root();
},
refreshWeather: function() {
// Fetching current weather
let weather;
{
var session = new Soup.SessionSync();
var message = Soup.Message.new('GET', WEATHER_URL);
stat = session.send_message(message);
jp = new Json.Parser();
jp.load_from_data(message.response_body.data, -1);
weather = jp.get_root().get_object();
}
try {
/*
weather.constructor.prototype.get_data = function(a, b) {
return weather.get_object_member(a).get_strig_member(b);
};
*/
// Fetching current weather
let weather = this.load_json(WEATHER_URL).get_object();
// Refreshing current weather
let location = weather.get_object_member('location').get_string_member('city');
@ -175,6 +172,10 @@ WeatherMenuButton.prototype = {
this._currentWeatherPressure.text = pressure + ' ' + pressure_unit;
this._currentWeatherWind.text = wind_direction + ' ' + wind + ' ' + wind_unit;
} catch (e) {
//TODO
}
// Repeatedly refresh weather
here = this;
Mainloop.timeout_add(1000*60*4, function() {

Loading…
Cancel
Save