Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Created November 4, 2010 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpadilla/662442 to your computer and use it in GitHub Desktop.
Save jpadilla/662442 to your computer and use it in GitHub Desktop.
//Presentations
function presentations()
{
$.ajax({
url: '/jsonapi/presentations/',
type: 'POST',
dataType: 'json',
complete: function(xhr, textStatus) {
setTimeout("presentations()", 5000);
},
success: function(data, textStatus, xhr) {
$(".presentation").html(data.length);
console.log('Checking presentations');
var item_list = '';
for (var i=0; i < 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