Advertisement
Guest User

Untitled

a guest
Apr 30th, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. const audio = new Audio();
  2.  
  3. [...document.querySelectorAll(".file")].forEach((element) => {
  4. const onFileClick = () => {
  5.  
  6. const title = element.querySelector(".fileText a").title;
  7. if (title.indexOf("sound") !== -1) {
  8. // i can't into regex
  9. const url = decodeURIComponent(title.split("[")[1].split("sound=")[1].split("]")[0]);
  10. audio.src = url;
  11. console.log("wah !");
  12. }
  13.  
  14. if (element.classList.contains("image-expanded")) {
  15. audio.pause();
  16. } else {
  17. audio.play();
  18. }
  19. }
  20.  
  21. element.addEventListener("click", onFileClick);
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement