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.

couloir_ami.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //------------------ Variables ------------------//
  2. let p_counter = 0;
  3. let texts = document.getElementsByClassName("textWillAppear");
  4. let buttonBox = document.getElementById("buttons");
  5. let arrow = document.getElementById("arrow");
  6. let space = document.getElementById("space");
  7. let nomAmi = document.getElementsByClassName("nomAmi");
  8. console.log(nomAmi[0])
  9. let NB_TEXTS = texts.length;
  10. let NB_BUTTONS = 1;
  11. let NB_ELEMENTS_TO_APPEAR = NB_TEXTS + NB_BUTTONS;
  12. //------------------ Fonctions ------------------//
  13. for (let i = 0 ; i<nomAmi.length ; i++) {
  14. nomAmi[i].innerHTML = localStorage.getItem('friendPseudo');
  15. }
  16. //gère les apparitions et disparitions des textes
  17. function makeNextTextAppear(event) {
  18. if (p_counter < NB_ELEMENTS_TO_APPEAR) {
  19. if (event.keyCode == 13 || event.keyCode == 32) {
  20. if(p_counter < NB_TEXTS) {
  21. texts[p_counter].style.cssText = "animation: fade 2s forwards;";
  22. }
  23. else {
  24. buttonBox.style.cssText = "animation: fade 2s forwards;";
  25. arrow.style.cssText = "animation: fade-reverse 2s forwards;";
  26. space.style.cssText = "animation: fade-reverse 2s forwards;";
  27. }
  28. p_counter += 1;
  29. }
  30. }
  31. }
  32. //------------------ Gestion events ------------------//
  33. document.addEventListener("keypress", makeNextTextAppear);