buzzkillb

price.js

Mar 6th, 2019
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var listen = setInterval(function() {
  2.  
  3. fetch('https://api.egem.io/api/v1/egem_prices')
  4. .then(function(response) {
  5. return response.json();
  6. })
  7. .then(function(data) {
  8. if (data.BLOCK_HEIGHT)
  9. console.log(data.BLOCK_HEIGHT);
  10. $('#blockheight').html("");
  11. $("#blockheight").append(data.BLOCK_HEIGHT).addClass('animated pulse');
  12. if (data.TOTAL_EGEM_SUPPLY)
  13. console.log(data.TOTAL_EGEM_SUPPLY);
  14. $('#currentsupply').html("");
  15. $("#currentsupply").append(data.TOTAL_EGEM_SUPPLY);
  16. var targetblock = 2500000;
  17. var blocktime = 0.273;
  18. var blocksleft = targetblock - (data.BLOCK_HEIGHT);
  19. $('#blocks_left').html("");
  20. $("#blocks_left").append(blocksleft).hide().fadeIn('slow');
  21. var minutesleft = blocksleft * blocktime;
  22. var mleft = minutesleft.toFixed(0);
  23. $('#minutesLeft').html("");
  24. $("#minutesLeft").append(mleft).hide().fadeIn('slow');
  25. var hoursleft = minutesleft / 60;
  26. var hleft = hoursleft.toFixed(0);
  27. $('#hoursLeft').html("");
  28. $("#hoursLeft").append(hleft).hide().fadeIn('slow');
  29. var daysleft = hoursleft / 24;
  30. var dleft = daysleft.toFixed(0);
  31. $('#daysLeft').html("");
  32. $("#daysLeft").append(dleft).fadeIn('slow');
  33. var someDate = new Date();
  34. var numberOfDaysToAdd = daysleft;
  35. someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
  36.  
  37. var dd = someDate.getDate();
  38. var mm = someDate.getMonth() + 1;
  39. var y = someDate.getFullYear();
  40.  
  41. var someFormattedDate = mm + '/'+ dd + '/'+ y;
  42. $('#blockparty').html("");
  43. $("#blockparty").append(someFormattedDate).hide().fadeIn('slow');
  44.  
  45. if (data.GRAVIEX_BTC)
  46. console.log(data.GRAVIEX_BTC);
  47. $('#graviexbtc').html("");
  48. $("#graviexbtc").append(data.GRAVIEX_BTC).addClass('animated pulse');
  49.  
  50.  
  51. })
  52. .catch(function(err) {
  53. console.log(err);
  54. });
  55.  
  56.  
  57. }, 13000);//13 second
RAW Paste Data