loadImg.js 585 B

12345678910111213141516171819
  1. const delay = ms => new Promise(res => setTimeout(res, ms))
  2. window.addEventListener('DOMContentLoaded', async () => {
  3. console.log('End expe ' + END_EXPE)
  4. // only if not end of expe
  5. if (!END_EXPE) {
  6. await delay(500)
  7. document.getElementById('expeImg').style.display = 'inline'
  8. }
  9. // redirect after 5s if end of expe
  10. else if (END_EXPE) {
  11. for (let i = 0; i <= 5; i++) {
  12. document.getElementById('refreshTime').textContent = 5 - i
  13. if (i <= 4) await delay(1000)
  14. }
  15. window.location = baseUrl
  16. }
  17. })