This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 5th, 2012  |  syntax: JavaScript  |  size: 1.04 KB  |  views: 160  |  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. // initial data loading
  2. var lastupdated = 0;
  3.  
  4. function refreshData() {
  5.  
  6.     database.leaderboards.tables.get({filter: { created: {$gte: lastupdated}}}, function(error, tables) {
  7.  
  8.         if(error) {
  9.             console.log("SCORETABLES failed to retrieve results: " + error);
  10.             setTimeout(refreshData, 1000);
  11.             return;
  12.         }
  13.  
  14.         console.log("SCORETABLES loaded " + tables.length + " new tables");
  15.  
  16.         if(tables.length > 0) {
  17.             for(var i=0; i<tables.length; i++) {
  18.                 var table = tables[i];
  19.                 tablelist[table.swfid + table._id] = table;
  20.                 tablelist[table.swfid + table.name] = table;
  21.  
  22.                 if(!table.created) {
  23.                     table.created = datetime.now - 1000;
  24.                     collection.update({_id: table._id}, table, {}, function(error, result) { });
  25.                 }
  26.             }
  27.  
  28.             lastupdated = tables[tables.length-1].created;
  29.         }
  30.  
  31.         setTimeout(refreshData, 30000);
  32.  
  33.     });
  34. }
  35.  
  36. refreshData();
clone this paste RAW Paste Data