No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

etrange_decouverte.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // select elements
  2. let buttons = document.getElementById("buttons")
  3. let safeButton = document.getElementById("safeButton");
  4. let boisson = document.getElementById("boisson");
  5. let selectedDrink = document.getElementById("selectedDrink");
  6. let text = document.getElementById("text")
  7. let eyeBlock = document.getElementById("eyeBlock")
  8. let counter_p = 1
  9. let childs = []
  10. console.log(text.childNodes);
  11. selectedDrink.innerText = boisson.value;
  12. //functions
  13. function handleSelectChange(event){
  14. selectedDrink.innerText = event.target.value;
  15. boisson.blur()
  16. }
  17. function handleDisplayText(event){
  18. if (event.keyCode == 32 || event.keyCode == 13){
  19. if (counter_p < text.childElementCount-1){
  20. text.children[counter_p].style.cssText = "animation : fade 2s forwards"
  21. counter_p += 1
  22. } else {
  23. text.children[counter_p].children[0].style.cssText = "animation : fade-reverse 2s forwards"
  24. text.children[counter_p].children[1].style.cssText = "animation : none"
  25. buttons.style.cssText = "animation : fade 2s forwards"
  26. }
  27. }
  28. }
  29. function handleDisplayEye(){
  30. console.log(eyeBlock.children[0].children[0]);
  31. eyeBlock.style.cssText = "z-index:1;animation:fade 2s forwards"
  32. eyeBlock.children[1].style.cssText = "animation: blinking1 1s forwards 1s,blinking2 1s forwards 2s,blinking3 1s forwards 3s"
  33. eyeBlock.children[0].children[0].style.cssText = "animation:fade 1s forwards 4s"
  34. eyeBlock.children[2].children[0].style.cssText = "animation:fade 1s forwards 4.5s"
  35. }
  36. //listeners
  37. boisson.addEventListener("change",handleSelectChange)
  38. setInterval(() => {
  39. document.addEventListener("keypress",handleDisplayText)
  40. }, 1000);
  41. safeButton.addEventListener("click",handleDisplayEye)