Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created May 30, 2010 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkphp/419265 to your computer and use it in GitHub Desktop.
Save thinkphp/419265 to your computer and use it in GitHub Desktop.
Request.Weather = new Class({
Extends: Request.JSONP,
options: {
url: 'http://query.yahooapis.com/v1/public/yql?q=use%20%22http%3A%2F%2Fthinkphp.ro%2Fapps%2FYQL%2Fweather-forecast%2Fweather.woeid.xml%22%20as%20weather%3B%20select%20*%20from%20weather%20where%20location%3D%22{term}%22%20and%20unit%3D%22c%22%3B',
data: {
format: 'json'
}
},
initialize: function(term,options) {
this.parent(options);
this.options.url = this.options.url.substitute({term: term});
}
});
window.addEvent('domready',function(){
new Request.Weather('london',{
onSuccess: function(o){
var title = '<p style="color: blue"><strong>'+o.query.results.weather.rss.channel.item.title+'</strong></p>',
description = o.query.results.weather.rss.channel.item.description;
$('weather').set('html',title+description);
}
}).send();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment