Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created August 25, 2011 14:36
Show Gist options
  • Save austinbv/1170807 to your computer and use it in GitHub Desktop.
Save austinbv/1170807 to your computer and use it in GitHub Desktop.
get_total = (trend, duration) ->
total = 0
for keyword in trend.search_terms
url = "http://otter.topsy.com/search.json?q=#{keyword}&window=#{duration}"
$.when( $.getJSON(url) ).then((data) ->
total += data.response.total
)
console.log total
total
get_total = function(trend, duration) {
var keyword, total, url, _i, _len, _ref;
total = 0;
_ref = trend.search_terms;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
keyword = _ref[_i];
url = "http://otter.topsy.com/search.json?q=" + keyword + "&window=" + duration;
$.when($.getJSON(url)).then(function(data) {
return total += data.response.total;
});
}
console.log(total);
return total;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment