Created
September 17, 2013 19:59
-
-
Save ronnie72/6599746 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var WTH={ | |
setup: function (){ | |
CF.log("Weather Module setup function has been called"); | |
}, | |
getData: function(url, dataReceivedCallback) { | |
// to be able to access our variable, we need to keep a reference to | |
// "this" because by the time the callback is called, the "this" value | |
// won't point to our module anymore. This is common JavaScript practice. | |
// perform the request | |
CF.request("http://api.worldweatheronline.com/free/v1/weather.ashx?q=vleuten&format=json&num_of_days=5&key=mb49v9emnccjk5eadwn6sxzz", function(status, headers, body) { | |
CF.log("Status is: " +status); | |
if (status == 200) { | |
// ... process body here, extract the data we are looking for ... | |
var weather = JSON.parse(body); | |
CF.setJoin("s7001", body); | |
CF.log("weather is: " +weather); | |
// If a callback was provided, call it now, handing over the | |
// last bit of data we processed. | |
if (dataReceivedCallback !== undefined) { | |
dataReceivedCallback.apply(null, [processed]); | |
} | |
} | |
}); | |
}, | |
DisplayData: function() { | |
CF.setjoin("s7002", weather.data.current_condition[0].temp_C); | |
} | |
}; | |
CF.modules.push({name:"Weather", setup:WTH.setup}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment