Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const audio = new Audio();
- [...document.querySelectorAll(".file")].forEach((element) => {
- const onFileClick = () => {
- const title = element.querySelector(".fileText a").title;
- if (title.indexOf("sound") !== -1) {
- // i can't into regex
- const url = decodeURIComponent(title.split("[")[1].split("sound=")[1].split("]")[0]);
- audio.src = url;
- console.log("wah !");
- }
- if (element.classList.contains("image-expanded")) {
- audio.pause();
- } else {
- audio.play();
- }
- }
- element.addEventListener("click", onFileClick);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement