sign_up.js 897 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import './public-path';
  2. import axios from 'axios';
  3. import ready from '../mastodon/ready';
  4. ready(() => {
  5. setInterval(() => {
  6. axios.get('/api/v1/emails/check_confirmation').then((response) => {
  7. if (response.data) {
  8. window.location = '/start';
  9. }
  10. }).catch(error => {
  11. console.error(error);
  12. });
  13. }, 5000);
  14. document.querySelectorAll('.timer-button').forEach(button => {
  15. let counter = 30;
  16. const container = document.createElement('span');
  17. const updateCounter = () => {
  18. container.innerText = ` (${counter})`;
  19. };
  20. updateCounter();
  21. const countdown = setInterval(() => {
  22. counter--;
  23. if (counter === 0) {
  24. button.disabled = false;
  25. button.removeChild(container);
  26. clearInterval(countdown);
  27. } else {
  28. updateCounter();
  29. }
  30. }, 1000);
  31. button.appendChild(container);
  32. });
  33. });