Skip to content

Commit

Permalink
Merge pull request #10 from codingkatty/wonkysound
Browse files Browse the repository at this point in the history
Wonky Sound
  • Loading branch information
vansh-codes authored Oct 7, 2024
2 parents 004cbed + efa40ff commit 10031fc
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 8 deletions.
15 changes: 7 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ <h1 id="chaos-header">ChaosWeb - The Disorderly UI Experiment</h1>
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function() {
const header = document.getElementById('chaos-header');
const words = header.textContent.split(' ');
header.innerHTML = words.map(word => `<span>${word}</span>`).join(' ');
});
</script>
<a href="#">Tester link</a>
<button>Tester button</button>
<input placeholder="test">

<script src="js/script.js"></script>
<script src="js/sound.js"></script>
</body>
</html>
</html>
5 changes: 5 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document.addEventListener('DOMContentLoaded', function() {
const header = document.getElementById('chaos-header');
const words = header.textContent.split(' ');
header.innerHTML = words.map(word => `<span>${word}</span>`).join(' ');
});
21 changes: 21 additions & 0 deletions js/sound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const sound = document.createElement('audio');
sound.style.display = 'none';
document.body.appendChild(sound);

let arrayofnoises = ["sfx/bird.mp3", "sfx/buffalo.mp3", "sfx/cat1.mp3", "sfx/cat2.mp3", "sfx/elephant1.mp3", "sfx/elephant2.mp3", "sfx/penguin.mp3", "sfx/rooster.mp3", "sfx/tiger.mp3"];

function wonkySound() {
let random = Math.floor(Math.random() * arrayofnoises.length);
sound.src = arrayofnoises[random];

sound.currentTime = 0;
sound.play();
}

const links = document.querySelectorAll('a');
links.forEach(a => a.addEventListener('click', wonkySound));

const buttons = document.querySelectorAll('button');
buttons.forEach(button => button.addEventListener('click', wonkySound));

document.addEventListener('keyup', wonkySound);
Binary file added sfx/bird.mp3
Binary file not shown.
Binary file added sfx/buffalo.mp3
Binary file not shown.
Binary file added sfx/cat1.mp3
Binary file not shown.
Binary file added sfx/cat2.mp3
Binary file not shown.
Binary file added sfx/elephant1.mp3
Binary file not shown.
Binary file added sfx/elephant2.mp3
Binary file not shown.
Binary file added sfx/penguin.mp3
Binary file not shown.
Binary file added sfx/rooster.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions sfx/source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[website I got audio from](https://pixabay.com/sound-effects/search/animals/?duration=0-30)
Binary file added sfx/tiger.mp3
Binary file not shown.

0 comments on commit 10031fc

Please sign in to comment.