Guest User

Untitled

a guest
Jul 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. var interval;
  2. var loopcounter = 1;
  3.  
  4. // startTxPendingCheck is a global window variable set by another script
  5.  
  6. if (startTxPendingCheck) {
  7. var div = document.getElementById('spinnerwait');
  8. div.style.display = 'block';
  9. interval = setTimeout(checkForConfirmedTx, 2000);
  10. function checkForConfirmedTx() {
  11. if (loopcounter < 45) {
  12. $.ajax({
  13. url: "/api?module=localchk&action=txexist&txhash=" + txHash,
  14. type: "GET",
  15. success: function(data) {
  16. if (data.result == "True") {
  17. window.location.href = "/tx/" + txHash;
  18. }
  19. },
  20. dataType: "json"
  21. })
  22. loopcounter = loopcounter + 1;
  23. interval = setTimeout(checkForConfirmedTx, 20000);
  24. } else {
  25. stopInterval();
  26. }
  27. }
  28. function stopInterval() {
  29. console.log("stopInterval called");
  30. var div = document.getElementById('spinnerwait');
  31. div.style.display = 'none';
  32. clearTimeout(interval);
  33. }
  34. function startInterval() {
  35. console.log("startInterval called");
  36. clearTimeout(interval);
  37. var div = document.getElementById('spinnerwait');
  38. div.style.display = 'block';
  39. interval = setTimeout(checkForConfirmedTx, 5000);
  40. }
  41. }
Add Comment
Please, Sign In to add comment