Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created August 28, 2011 23:59
Show Gist options
  • Save austinbv/1177424 to your computer and use it in GitHub Desktop.
Save austinbv/1177424 to your computer and use it in GitHub Desktop.
$ ->
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)
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