From 6b5270c64f8beffbdec99f0af6579afcf4fbbabb Mon Sep 17 00:00:00 2001 From: zyqunix Date: Sat, 7 Dec 2024 17:27:05 +0100 Subject: [PATCH] his audio request --- autist/index.html | 13 ++++++++++++- autist/index.js | 30 ++++++++++-------------------- autist/style.css | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/autist/index.html b/autist/index.html index dd20365..73d9dbe 100644 --- a/autist/index.html +++ b/autist/index.html @@ -15,7 +15,18 @@

No sound played. Press the button!

- + + + +
diff --git a/autist/index.js b/autist/index.js index ca1ed69..eb6a1a6 100644 --- a/autist/index.js +++ b/autist/index.js @@ -1,29 +1,19 @@ -const sounds = { - autist: 'wav/sound1.wav', - downie: 'wav/sound2.wav', - retard: 'wav/sound3.wav', - 'retarded autistic downie': 'wav/sound4.wav' -}; +const buttons = document.querySelectorAll('button'); + +buttons.forEach(button => { + const audio = button.querySelector('audio'); + button.addEventListener('click', function() { + if (audio) { + audio.play(); + } + }); +}); -const button = document.getElementById('playButton'); -const header = document.getElementById('played'); const toggle = document.getElementById('toggle'); const ad = document.getElementById('ad'); let isHidden = false; -button.addEventListener('click', function() { - const audio = document.getElementById('audio'); - const keys = Object.keys(sounds); - let randKey = keys[Math.floor(Math.random() * keys.length)]; - let randSound = sounds[randKey]; - - audio.src = randSound; - audio.play(); - - header.innerHTML = randKey; -}); - toggle.addEventListener('click', function() { if (!isHidden) { ad.style.display = 'none'; diff --git a/autist/style.css b/autist/style.css index fc3e987..9daa8d8 100644 --- a/autist/style.css +++ b/autist/style.css @@ -55,8 +55,8 @@ button:not(#toggle) { cursor: pointer; transition: 0.1s ease-in-out; padding: 10px 20px; - font-weight: bold; margin: 10px; + } #toggle {