Changes in weather-settings auto-complete

yahoo_weather
Neroth 13 years ago
parent de2f990537
commit e522c715fa
  1. 12
      src/weather-settings.js.in

@ -103,17 +103,12 @@ WeatherSetting.prototype =
var testLocation = function(location) var testLocation = function(location)
{ {
that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid from geo.places where text = '"+location+"' limit 2"),function() that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid from geo.places where text = '"+location+"' limit 1"),function()
{ {
d.sensitive = 0; d.sensitive = 0;
var city = arguments[0].query; var city = arguments[0].query;
if(typeof city == "object" && typeof city.results == "object") if(typeof city == "object" && city.results == null)
city = city.results.place;
else
return 0; return 0;
if(typeof city.woeid == "undefined")
return 0;
else
d.sensitive = 1; d.sensitive = 1;
}); });
}; };
@ -121,7 +116,6 @@ WeatherSetting.prototype =
entry.signal.changed.connect(function() entry.signal.changed.connect(function()
{ {
var location = entry.get_text(); var location = entry.get_text();
print(location);
testLocation(location); testLocation(location);
that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?q=select woeid,name,admin1,country from geo.places where text = '*"+location+"*' or text = '"+location+"' limit 10&format=json"),function() that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?q=select woeid,name,admin1,country from geo.places where text = '*"+location+"*' or text = '"+location+"' limit 10&format=json"),function()
@ -166,7 +160,7 @@ print(location);
dialog.signal.response.connect(function(w, response_id) { dialog.signal.response.connect(function(w, response_id) {
if(response_id) if(response_id)
{ {
that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid,name,admin1,country from geo.places where text = '"+entry.get_text()+"'"),function() that.loadJsonAsync(encodeURI("http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid,name,admin1,country from geo.places where text = '"+entry.get_text()+"' limit 1"),function()
{ {
var city = arguments[0].query; var city = arguments[0].query;
if(typeof city == "object" && typeof city.results == "object") if(typeof city == "object" && typeof city.results == "object")

Loading…
Cancel
Save