fork download
  1. const retrieve = (str) => document.getElementById(str);
  2.  
  3. const images = [];
  4. for (let i = 0; i< 5; i++) images.push(retrieve(`image${i}`));
  5. let i = 0;
  6. const changePicture = () =>
  7. {
  8. if (i === 4) {
  9. images[4].style.zIndex = 2
  10. images.forEach(img => img.style.opacity = 1);
  11. }
  12. if (i === 0) {
  13. images[4].style.zIndex = -3;
  14. images[4].style.opacity = 1;
  15. }
  16. images[i].style.opacity = 0;
  17. i++;
  18. if (i >4) i = 0;
  19. }
  20.  
  21. const frame = retrieve('start-frame');
  22. const label = retrieve('start-caption');
  23.  
  24. //todo: remake with async+promise
  25. const loadContent = () => new Promise(resolve => document.addEventListener("DOMContentLoaded", resolve, false));
  26.  
  27.  
  28. async function magic() {
  29. await loadContent();
  30. frame.classList.add('fadeout');
  31. frame.style.opacity = 0;
  32. const animateFrame = () => new Promise(resolve => frame.addEventListener('transitionend', resolve, false));
  33. await animateFrame();
  34. frame.style.zIndex = -10;
  35. retrieve('nav').style.opacity = 1;
  36. label.style.opacity = 1;
  37. setInterval(changePicture, 6000);
  38. const animateLabel = () => new Promise(resolve => label.addEventListener('transitionend', resolve, false));
  39. await animateLabel();
  40. label.classList.remove('fast-fadein');
  41. label.classList.add('fadeout');
  42. label.style.opacity = 0;
  43. }
  44.  
  45. magic();
Runtime error #stdin #stdout #stderr 0.01s 9656KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:4:48 SyntaxError: illegal character:
prog.js:4:48 for (let i = 0; i< 5; i++) images.push(retrieve(`image${i}`));
prog.js:4:48 ................................................^