-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
51 lines (47 loc) · 1.77 KB
/
script.js
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
document.addEventListener("DOMContentLoaded", function() {
function generateLottoNumbers() {
let numbers = [];
while (numbers.length < 6) {
let randomNumber = Math.floor(Math.random() * 45) + 1;
if (!numbers.includes(randomNumber)) {
numbers.push(randomNumber);
}
}
return numbers;
}
function createRouletteBalls() {
let roulette = document.getElementById('roulette');
roulette.innerHTML = '';
for (let i = 1; i <= 45; i++) {
let ball = document.createElement('div');
ball.className = 'ball';
ball.textContent = i;
roulette.appendChild(ball);
}
}
function animateRoulette() {
let balls = document.querySelectorAll('.ball');
let interval = setInterval(() => {
balls.forEach(ball => {
ball.style.order = Math.floor(Math.random() * 45);
});
}, 100);
setTimeout(() => {
clearInterval(interval);
let numbers = generateLottoNumbers();
let numbersDiv = document.getElementById('numbers');
numbersDiv.textContent = '추천 번호: ' + numbers.join(', ');
balls.forEach(ball => {
if (numbers.includes(parseInt(ball.textContent))) {
ball.style.backgroundColor = '#ff0000';
} else {
ball.style.backgroundColor = '#007bff';
}
});
}, 5000); // Adjust the duration of the roulette animation here
}
document.getElementById('generate-btn').addEventListener('click', () => {
createRouletteBalls();
animateRoulette();
});
});