Skip to content

Instantly share code, notes, and snippets.

@gcollazo
Forked from jpadilla/gist:662442
Created November 4, 2010 13:27
Show Gist options
  • Save gcollazo/662455 to your computer and use it in GitHub Desktop.
Save gcollazo/662455 to your computer and use it in GitHub Desktop.
var old_data;
//Presentations
function presentations()
{
$.ajax({
url: '/jsonapi/presentations/',
type: 'POST',
dataType: 'json',
complete: function(xhr, textStatus) {
setTimeout("presentations()", 5000);
},
success: function(data, textStatus, xhr) {
if(data === old_data){
// do nothing
} else {
old_data = data;
console.log('Checking presentations');
var item_list = '';
for (var i=0; i < good_data.length; i++) {
var thumbnail = '<div class="thumbnail"><img src="/static/img/default_avatar.png" /></div>';
var title = '<span class="title">' + data[i].name + '</span>';
var author = '<span class="author">' + data[i].user + '</span>';
var twitter_name = '<span class="twitter_username">@' + data[i].twitter_name + '</span>';
var content = '<div class="content">'+ title + author + twitter_name + '</div>';
var countdown = (data[i].status == 'ongoing' ? '<div class="countdown">9:38</div>' : '');
var item = '<li class="'+ data[i].status +'">'+ thumbnail + content + countdown + '</li>';
item_list += item;
var now = new Date();
var endingSoon = new Date(now);
endingSoon.setMinutes(now.getMinutes() + 1);
// $(".ongoing .countdown").countdown(endingSoon,
// {
// precision: "simple"
// }
// );
};
}
console.log(item_list);
console.log($("#presentations ul").html());
if($("#presentations ul").html() == item_list)
{
console.log('No change in presentation');
}
else
{
console.log('Presentations changed');
$("#presentations ul").html(item_list);
}
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
}
presentations();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment