Add files via upload
This commit is contained in:
parent
c48c5e1008
commit
5fc3bb9801
18
100_projects/47-soundboard-javascript/index.html
Normal file
18
100_projects/47-soundboard-javascript/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Sound Board</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="script.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<audio id="applause" src="sounds/applause.mp3"></audio>
|
||||
<audio id="boo" src="sounds/boo.mp3"></audio>
|
||||
<audio id="gasp" src="sounds/gasp.mp3"></audio>
|
||||
<audio id="tada" src="sounds/tada.mp3"></audio>
|
||||
<audio id="victory" src="sounds/victory.mp3"></audio>
|
||||
<audio id="wrong" src="sounds/wrong.mp3"></audio>
|
||||
</body>
|
||||
</html>
|
21
100_projects/47-soundboard-javascript/script.js
Normal file
21
100_projects/47-soundboard-javascript/script.js
Normal file
@ -0,0 +1,21 @@
|
||||
const sounds = ["applause", "boo", "gasp", "tada", "victory", "wrong"];
|
||||
|
||||
sounds.forEach((sound) => {
|
||||
const btn = document.createElement("button");
|
||||
btn.classList.add("btn");
|
||||
btn.innerText = sound;
|
||||
|
||||
btn.addEventListener("click", () => {
|
||||
stopSongs();
|
||||
|
||||
document.getElementById(sound).play();
|
||||
});
|
||||
document.body.appendChild(btn);
|
||||
});
|
||||
function stopSongs() {
|
||||
sounds.forEach((sound) => {
|
||||
const song = document.getElementById(sound);
|
||||
song.pause();
|
||||
song.currentTime = 0;
|
||||
});
|
||||
}
|
BIN
100_projects/47-soundboard-javascript/sounds/applause.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/applause.mp3
Normal file
Binary file not shown.
BIN
100_projects/47-soundboard-javascript/sounds/boo.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/boo.mp3
Normal file
Binary file not shown.
BIN
100_projects/47-soundboard-javascript/sounds/gasp.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/gasp.mp3
Normal file
Binary file not shown.
BIN
100_projects/47-soundboard-javascript/sounds/tada.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/tada.mp3
Normal file
Binary file not shown.
BIN
100_projects/47-soundboard-javascript/sounds/victory.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/victory.mp3
Normal file
Binary file not shown.
BIN
100_projects/47-soundboard-javascript/sounds/wrong.mp3
Normal file
BIN
100_projects/47-soundboard-javascript/sounds/wrong.mp3
Normal file
Binary file not shown.
28
100_projects/47-soundboard-javascript/style.css
Normal file
28
100_projects/47-soundboard-javascript/style.css
Normal file
@ -0,0 +1,28 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding:0
|
||||
}
|
||||
body {
|
||||
background-color: #E9967A;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
min-height: 50vh;
|
||||
}
|
||||
.btn {
|
||||
background-color:#fff;
|
||||
border-radius: 15px;
|
||||
border: none;
|
||||
margin: 10px;
|
||||
color: black;
|
||||
font-size: 1.2rem;
|
||||
padding: 1.5rem 3rem;
|
||||
transition: .3s;
|
||||
width: 180px;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
.btn:hover{
|
||||
background: #FFFAF0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user