Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. var bidResponse;
  2. var lotId = document.getElementById('lotId');
  3. if (lotId) {
  4. clearInterval(inAuction);
  5. var inAuction = setInterval(() => {
  6. var inCountdown = document.querySelector('.timer-countdown-label');
  7. return fetch('/api.json?1570646780373&m=getLotDetails&v=1570646777453&js=1', {
  8. 'credentials': 'include',
  9. 'headers': {
  10. 'accept': '*/*',
  11. 'cache-control': 'no-cache',
  12. 'content-type': 'application/json',
  13. 'pragma': 'no-cache',
  14. 'sec-fetch-mode': 'cors',
  15. 'sec-fetch-site': 'same-origin'
  16. },
  17. 'referrerPolicy': 'no-referrer-when-downgrade',
  18. 'body': '{\"api\":\"catalog\",\"method\":\"getLotDetails\",\"lotId\":' + lotId.innerHTML + '}',
  19. 'method': 'POST',
  20. 'mode': 'cors'
  21. })
  22. .then(response => {
  23. return response.json();
  24. })
  25. .then(data => {
  26. let { data: { hasWinner, bidHistory } } = data;
  27. let timeLeft = inCountdown ? parseFloat(inCountdown.innerHTML) : null;
  28. if (!hasWinner) {
  29. if (!inCountdown) {
  30. bidResponse = 'waiting for countdown'
  31. console.log('waiting for countdown');
  32. completion(bidReponse);
  33. return;
  34. }
  35. if (timeLeft < 20) {
  36. let bidInput = document.getElementById('jsActiveBidInput');
  37. if (bidHistory[0]) {
  38. bidResponse = `Plaats bod, ${bidHistory[0].customer.firstName}`;
  39. console.log(`Plaats bod, ${bidHistory[0].customer.firstName}`);
  40. completion(bidReponse);
  41. if( bidInput ) {
  42. bidInput.value = bidHistory[0].customer.price + 1;
  43. }
  44. } else {
  45. bidResponse = 'Er is nog niet geboden, bied 1';
  46. console.log('Er is nog niet geboden, bied 1');
  47. completion(bidReponse);
  48. if( bidInput ) {
  49. bidInput.value = 1;
  50. }
  51. }
  52. } else if (timeLeft != NaN) {
  53. bidResponse = 'Nog niet binnen de tijd';
  54. console.log(`Nog niet binnen de tijd`);
  55. completion(bidReponse);
  56. }
  57. } else {
  58. clearInterval(inAuction);
  59. bidResponse = 'Bieden afgelopen';
  60. console.log('Bieden afgelopen');
  61. completion(bidReponse);
  62. }
  63. });
  64. }, 50);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement