Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jonadan0 authored Jun 27, 2024
1 parent 881aa5d commit 0ce07fb
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>로또 추천기</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>로또 추천기</h1>
<div id="roulette" class="roulette"></div>
<div id="numbers"></div>
<button id="generate-btn">번호 추천 받기</button>
</div>

<script src="script.js"></script>
</body>
</html>
51 changes: 51 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

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();
});
63 changes: 63 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
max-width: 400px;
width: 90%;
}

h1 {
color: #333;
}

#roulette {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: 20px 0;
}

.ball {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #007bff;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
margin: 5px;
font-size: 16px;
}

#numbers {
margin: 20px 0;
font-size: 24px;
}

button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.3s ease;
}

button:hover {
background-color: #0056b3;
}

0 comments on commit 0ce07fb

Please sign in to comment.