diff --git a/src/extension.js b/src/extension.js index 52b84d8..a09daff 100644 --- a/src/extension.js +++ b/src/extension.js @@ -368,7 +368,7 @@ const WeatherMenuButton = new Lang.Class({ }, locationChanged: function() { - let location = this.extractCity(this._city); + let location = this.extractId(this._city); if (this.oldLocation != location) { return true; } @@ -724,7 +724,6 @@ const WeatherMenuButton = new Lang.Class({ } for (let a in cities) { - if (!this.extractCity(cities[a])) { let params = { q: cities[a], @@ -1406,10 +1405,10 @@ weather-storm.png = weather-storm-symbolic.svg this.updateCities(); return; } - this.oldLocation = this.extractCity(this._city); + this.oldLocation = this.extractId(this._city); let params = { - q: this.oldLocation, + id: this.oldLocation, units: 'metric' }; if (this._appid) @@ -1540,10 +1539,10 @@ weather-storm.png = weather-storm-symbolic.svg return; } - this.oldLocation = this.extractCity(this._city); + this.oldLocation = this.extractId(this._city); let params = { - q: this.oldLocation, + id: this.oldLocation, units: 'metric', cnt: '13' }; diff --git a/src/prefs.js b/src/prefs.js index 2fbc563..0d51665 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -375,8 +375,8 @@ const WeatherPrefsWidget = new GObject.Class({ units: 'metric', q: location }; - if (this._appid) - params['APPID'] = this._appid; + if (this.appid) + params['APPID'] = this.appid; if (testLocation(location) == 0) this.loadJsonAsync(WEATHER_URL_FIND, params, function() { if (!arguments[0]) @@ -433,16 +433,16 @@ const WeatherPrefsWidget = new GObject.Class({ if (entry.get_text().search(/\[/) == -1 || entry.get_text().search(/\]/) == -1) return 0; - let name = entry.get_text().split(/,/)[0]; - if (!name) + let id = entry.get_text().split(/\[/)[1].split(/\]/)[0]; + if (!id) return 0; let params = { - q: name, + id: id, type: 'accurate' }; - if (this._appid) - params['APPID'] = this._appid; + if (this.appid) + params['APPID'] = this.appid; this.loadJsonAsync(WEATHER_URL_CURRENT, params, Lang.bind(this, function() { if (!arguments[0]) return 0; @@ -451,14 +451,13 @@ const WeatherPrefsWidget = new GObject.Class({ if (Number(city.cod) != 200) return 0; - let id = entry.get_text().split(/\[/)[1].split(/\]/)[0]; if (!id) return 0; if (id != city.id) return 0; - let cityText = city.name; + let cityText = entry.get_text().split(/,/)[0]; if (city.sys) cityText += " (" + city.sys.country + ")";