You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

10 years ago
  1. $(function () {
  2. $('[data-toggle="tooltip"]').tooltip();
  3. var url = $("#pitch-url").text();
  4. var lastPing = null;
  5. var lastPingHuman = null;
  6. $("#run-it").click(function() {
  7. $.get(url);
  8. });
  9. function checkLastPing() {
  10. $.getJSON("/welcome/timer/", function(data) {
  11. if (data.last_ping != lastPing) {
  12. lastPing = data.last_ping;
  13. $("#timer").data("timer", data.timer);
  14. }
  15. var lph = data.last_ping_human;
  16. if (lph && lph.indexOf("seconds ago") > 0)
  17. data.last_ping_human = "seconds ago";
  18. if (data.last_ping_human != lastPingHuman) {
  19. lastPingHuman = data.last_ping_human;
  20. $("#last-ping").text(lastPingHuman);
  21. }
  22. });
  23. }
  24. function updateTimer() {
  25. var timer = parseInt($("#timer").data("timer"));
  26. if (timer == 0)
  27. return;
  28. var s = timer % 60;
  29. var m = parseInt(timer / 60) % 60;
  30. var h = parseInt(timer / 3600);
  31. $("#timer").text(h + "h " + m + "m " + s + "s");
  32. $("#timer").data("timer", timer - 1);
  33. }
  34. setInterval(checkLastPing, 3000);
  35. setInterval(updateTimer, 1000);
  36. });