Skip to content

Instantly share code, notes, and snippets.

@andresilva
Created January 6, 2014 23:26
Show Gist options
  • Save andresilva/8291852 to your computer and use it in GitHub Desktop.
Save andresilva/8291852 to your computer and use it in GitHub Desktop.
mucuchies
var weatherSource = Dashboard.PeriodicSource.create({
period: 300000,
dataUpdate: function(callback) {
var query = "select * from weather.forecast WHERE woeid=746203 and u='c'&format=json"
var req = {
url: "http://query.yahooapis.com/v1/public/yql?q=" + encodeURI(query)
};
$.get("/get", req, function(data) {
var results = data.query.results;
var condition = results.channel.item.condition;
callback({
temperature: condition.temp,
code: condition.code,
city: results.channel.location.city
})
});
}
});
Dashboard.WeatherWidget.create({
row: 1, col: 1, sizex: 1, sizey: 1,
showLastUpdated: true,
source: weatherSource
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment