Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 13th, 2013  |  syntax: None  |  size: 1.72 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. var quizIDs = '43',
  3.     numRecords = '10',
  4.     autoUpdate = true,
  5.     reloadInterval = '3000';
  6.  
  7. $(function(){
  8.  
  9.     showLeaderboard();
  10.  
  11.     if (autoUpdate != false) {
  12.         window.setInterval(function(){  
  13.             updateLeaderboard();
  14.          
  15.         }, reloadInterval);
  16.     }
  17.  
  18. });
  19.  
  20. function updateLeaderboard() {
  21.     numRecords;
  22.     quizIDs;
  23.  
  24. $.webMethod({
  25.     url: 'http://staging.cmdapp.com/Services/Poll.asmx/LeaderboardGetTopScores',
  26.     data: '{quizIDs:"'+quizIDs+'",numRecords:"'+numRecords+'"}',
  27.     beforeSend: function () { },
  28.     success: function (ret) {
  29.  
  30.         ret = $.parseJSON(ret.d);
  31.  
  32.         $.each(ret.leaderboard,function(i){
  33.             pos = i + 1;
  34.             str = '<li data-id="'+pos+'">' + ret.leaderboard[i].first_name + '&nbsp;' + ret.leaderboard[i].last_name + '</li>';      
  35.         });
  36.  
  37.         $('.webbies').quicksand( str, { adjustHeight: 'dynamic' } );    
  38.         console.log(str);              
  39.     },
  40.     error: function (response) { console.log(response.responseText); }
  41. });
  42. }
  43.  
  44. function __show() {
  45.  
  46. }
  47.  
  48. function showLeaderboard() {
  49.     updateLeaderboard();
  50. }
  51.  
  52. function convertTime(time) {        
  53.     var millis= time % 1000;
  54.         time = parseInt(time/1000);
  55.     var seconds = time % 60;
  56.         time = parseInt(time/60);
  57.     var minutes = time % 60;
  58.         time = parseInt(time/60);
  59.  
  60.     var hours = time % 24;
  61.     var out = "";
  62.  
  63.     if(hours && hours > 0) out += hours + " " + ((hours == 1)?"Hour":"Hours") + " ";
  64.     if(minutes && minutes > 0) out += minutes + " " + ((minutes == 1)?"minute":"minutes and") + " ";
  65.     if(seconds && seconds > 0) out += seconds + " " + ((seconds == 1)?"second":"seconds") + " ";
  66.     return out.trim();
  67. }