Created
April 13, 2011 08:42
-
-
Save mconnell/917205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Weather(locationName){ | |
var locationURL = "http://www.google.com/ig/api?weather="+locationName; | |
var forcast = {}; | |
$.get(locationURL, function(data){ | |
var current = $(data).find('current_conditions'); | |
['condition', 'temp_f', 'temp_c', 'humidity', 'wind_condition'].forEach(function(attribute){ | |
forcast[attribute] = $(current).find(attribute).attr('data'); | |
}); | |
}); | |
return forcast; | |
}; | |
// Weather('Edinburgh'); | |
// Object | |
// condition: "Partly Cloudy" | |
// humidity: "Humidity: 76%" | |
// temp_c: "8" | |
// temp_f: "46" | |
// wind_condition: "Wind: SW at 14 mph" | |
// __proto__: Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment