Guest User

Untitled

a guest
Jun 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. //Presentations
  2. function presentations()
  3. {
  4. $.ajax({
  5. url: '/jsonapi/presentations/',
  6. type: 'POST',
  7. dataType: 'json',
  8. complete: function(xhr, textStatus) {
  9. setTimeout("presentations()", 5000);
  10. },
  11. success: function(data, textStatus, xhr) {
  12.  
  13. $(".presentation").html(data.length);
  14.  
  15. console.log('Checking presentations');
  16. var item_list = '';
  17. for (var i=0; i < data.length; i++) {
  18.  
  19. var thumbnail = '<div class="thumbnail"><img src="/static/img/default_avatar.png" /></div>';
  20. var title = '<span class="title">' + data[i].name + '</span>';
  21. var author = '<span class="author">' + data[i].user + '</span>';
  22. var twitter_name = '<span class="twitter_username">@' + data[i].twitter_name + '</span>';
  23. var content = '<div class="content">'+ title + author + twitter_name + '</div>';
  24.  
  25. var countdown = (data[i].status == 'ongoing' ? '<div class="countdown">9:38</div>' : '');
  26.  
  27. var item = '<li class="'+ data[i].status +'">'+ thumbnail + content + countdown + '</li>';
  28.  
  29. item_list += item;
  30.  
  31. var now = new Date();
  32. var endingSoon = new Date(now);
  33. endingSoon.setMinutes(now.getMinutes() + 1);
  34. // $(".ongoing .countdown").countdown(endingSoon,
  35. // {
  36. // precision: "simple"
  37. // }
  38. // );
  39.  
  40. };
  41.  
  42. console.log(item_list);
  43. console.log($("#presentations ul").html());
  44. if($("#presentations ul").html() == item_list)
  45. {
  46. console.log('No change in presentation');
  47. }
  48. else
  49. {
  50. console.log('Presentations changed');
  51. $("#presentations ul").html(item_list);
  52. }
  53.  
  54.  
  55. },
  56. error: function(xhr, textStatus, errorThrown) {
  57. //called when there is an error
  58. }
  59. });
  60. }
  61.  
  62. presentations();
Add Comment
Please, Sign In to add comment