Created
August 28, 2011 23:59
-
-
Save austinbv/1177424 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
$ -> | |
get_each(trends.islam, 1, (trend) -> | |
console.log trend | |
) | |
get_each = (trend, duration, callback) -> | |
requests = [] | |
for term in trend.search_terms | |
url = "http://otter.topsy.com/search.js?callback=?&apikey=X&q=#{term.term}&window=#{duration}" | |
console.log url | |
requests.push($.getJSON(url, (data) -> | |
term.total = data.response.total | |
)) | |
$.when.apply($, requests).then -> | |
callback(trend) | |
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
get_each(trends.islam, 1, function(trend) { | |
return console.log(trend); | |
}); | |
get_each = function(trend, duration, callback) { | |
var requests, term, url, _i, _len, _ref; | |
requests = []; | |
_ref = trend.search_terms; | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
term = _ref[_i]; | |
url = "http://otter.topsy.com/search.js?callback=?&apikey=38A260E9D12A4908B1AF9184B691131&q=" + term.term + "&window=" + duration; | |
requests.push($.getJSON(url, function(data) { | |
return term.total = data.response.total; | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment