Automatically fix "wrong" WOEID (i.e., numeric instead of alphanumeric WOEID).

yahoo_weather
simon04 14 years ago
parent c710bea1be
commit 8666143616
  1. 21
      src/extension.js

@ -399,6 +399,27 @@ WeatherMenuButton.prototype = {
// Refresh current weather // Refresh current weather
this.load_json_async(this.get_weather_url(), function(weather) { this.load_json_async(this.get_weather_url(), function(weather) {
// Fixes wrong woeid if necessary
try {
// Wrong woeid specified
if (weather.get_int_member('code') == 500) {
// Fetch correct woeid
this.load_json_async(this.get_weather_url().replace('p=', 'w='), function(weather) {
try {
// Take correct woeid, update gsettings
this._woeid = weather.get_object_member('location').get_string_member('location_id');
this._settings.set_string(WEATHER_WOEID_KEY, this._woeid);
// Loads weather with correct woeid
this.refreshWeather();
} catch(e) {
}
});
return;
}
} catch(e) {
global.log('A ' + e.name + ' has occured: ' + e.message);
}
let location = weather.get_object_member('location').get_string_member('city'); let location = weather.get_object_member('location').get_string_member('city');
if (this._city != null && this._city.length > 0) if (this._city != null && this._city.length > 0)
location = this._city; location = this._city;

Loading…
Cancel
Save