Skip to content

Instantly share code, notes, and snippets.

@rtanglao
Created August 26, 2010 03:49
Show Gist options
  • Select an option

  • Save rtanglao/550760 to your computer and use it in GitHub Desktop.

Select an option

Save rtanglao/550760 to your computer and use it in GitHub Desktop.
DOES NOT WORK!
<!DOCTYPE html>
<html lang="en">
<body>
<ol>
<div class="d1"></div>
<div class="d2"></div>
<div class="d3"></div>
<div class="d4"></div>
<div class="d5"></div>
</ol>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script>
if (typeof console === 'undefined' || !console.log) {
var console = { log: function () {}};
};
(function($){
$.ajaxSetup({
cache: false // turn off AJAX caching so you actually get the top 5!
});
var today = new Date(); // today in local timezone
var month = today.getMonth();
var day_of_month = today.getDate();
var topics; // all today's topics
var replies; // all replies to today's topics
function doIt(){
var topic_page = 1;
var topics_updated_today = true;
while (topics_updated_today) {
topic_url =
"http://api.getsatisfaction.com/products/mozilla_thunderbird/topics.json?sort=recently_active&page="
+ topic_page + "&limit=30&callback=?";
console.log(topic_url);
$.getJSON(topic_url,
function(gsjs){ //gsjs is the JSON object from getsatisfaction
console.log("page:",topic_page,"topics:",gsjs);
$.each(gsjs.data, function(i,topic) {
topic_change_date = new Date(topic.last_active_at);
topic_change_day_of_month = topic_change_date.getDate();
console.log("topic date:", topic_change_day_of_month, "day of month:", day_of_month);
if (topic_change_day_of_month != day_of_month) {
//alert("setting topics_updated_today to false!!!!");
topics_updated_today = false;
return false; // this is a break!!!!!!
}
});
});
topic_page++;
}
//setTimeout(doIt, 32000);
};
setTimeout(doIt, 1000);
})(jQuery);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment