-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkaraoke_score.html
95 lines (85 loc) · 2.92 KB
/
karaoke_score.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Div</title>
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
#centered-div {
display: flex;
justify-content: center;
align-items: center;
font-size: 250px;
font-weight: bold;
width: 400px;
height: 400px;
border-radius: 50%;
background-color: yellow;
color: red;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
font-size: 70px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="centered-div">
99
</div>
<button id="calculateButton">Calcular</button>
<audio id="clappingSound1" preload="auto">
<source src="clapping1.mp3" type="audio/mp3">
</audio>
<audio id="clappingSound2" preload="auto">
<source src="clapping2.wav" type="audio/wav">
</audio>
<audio id="clappingSound3" preload="auto">
<source src="clapping3.wav" type="audio/wav">
</audio>
<script>
const centeredDiv = document.getElementById("centered-div");
const calculateButton = document.getElementById("calculateButton");
const clappingSound1 = document.getElementById("clappingSound1");
const clappingSound2 = document.getElementById("clappingSound2");
const clappingSound3 = document.getElementById("clappingSound3");
calculateButton.addEventListener("click", function() {
let dots = ".";
centeredDiv.textContent = dots;
let timer = setInterval(function() { // Use setInterval
dots += ".";
centeredDiv.textContent = dots;
if (dots.length === 5) {
clearInterval(timer); // Stop the interval
setTimeout(function() {
const randomNumber = Math.floor(Math.random() * (99 - 70 + 1)) + 70;
centeredDiv.textContent = randomNumber;
if (randomNumber >= 95) {
clappingSound1.play();
} else if (randomNumber >= 80) {
clappingSound2.play();
} else {
clappingSound3.play();
}
clappingSound.play()
}, 1000); // Final timeout for the number
}
}, 500); // 2 seconds interval
});
</script>
</body>
</html>