Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. var serverTimeOffset = <?php echo microtime(true); ?> - new Date().getTime()/1000;
  2.  
  3. function getServerTime() {
  4. return new Date().getTime()/1000 + serverTimeOffset;
  5. }
  6.  
  7. function updateCountdown() {
  8. var time = Math.max(30 - (getServerTime() % 40), 0);
  9. document.getElementById('time').innerHTML = time.toFixed(2);
  10.  
  11. window.requestAnimationFrame(updateCountdown);
  12. }
  13.  
  14. window.addEventListener('DOMContentLoaded', function() {
  15. updateCountdown();
  16. });
  17.  
  18. $(function () {
  19.  
  20. $.ajax({
  21. url: 'api.php',
  22. data: "",
  23.  
  24. dataType: 'json',
  25. success: function(data)
  26. {
  27. var id = data[0];
  28.  
  29. $('#output').html("<b>id: </b>"+id);
  30. }
  31. });
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement