-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlotto.html
124 lines (108 loc) · 3.95 KB
/
lotto.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!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="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<style>
.ball {
float: left;
width: 40px;
height: 40px;
line-height: 40px;
font-size: 20px;
border-radius: 100%;
text-align: center;
vertical-align: middle;
color: #fff;
font-weight: 500;
text-shadow: 0px 0px 3px rgba(73, 57, 0, .8);
margin-right: 6px;
}
.ball1 {
background: #fbc400;
}
.ball2 {
background: #69c8f2;
}
.ball3 {
background: #ff7272;
}
.ball4 {
background: #aaa;
}
.ball5 {
background: #b0d840;
}
.ball6 {
background: #c7c7c7;
}
</style>
</head>
<body>
<script>
$(document).ready(function () {
var getBallClass = function (lotto) {
var result = "ball1";
if (lotto < 10) {
result = "ball1";
} else if (lotto >= 10 && lotto < 20) {
result = "ball2";
} else if (lotto >= 20 && lotto < 30) {
result = "ball3";
} else if (lotto >= 30 && lotto < 40) {
result = "ball4";
} else if (lotto >= 40 && lotto < 46) {
result = "ball5";
}
return result;
}
var lottoCrate = function () {
var i = 0;
$("#content").empty();
while (i < 5) {
var lotto = [];
while (lotto.length < 6) {
var num = parseInt(Math.random() * 45 + 1);
if (lotto.indexOf(num) == -1) {
lotto.push(num);
}
}
lotto.sort((a, b) => a - b);
$("#content").append("<div class='callout callout-danger' style='height: 110px;'><h5>" + (i + 1) + "번! </h5>"
+ "<p>"
+ "<div class='ball " + getBallClass(lotto[0]) + "'>" + lotto[0] + "</div>"
+ "<div class='ball " + getBallClass(lotto[1]) + "'>" + lotto[1] + "</div>"
+ "<div class='ball " + getBallClass(lotto[2]) + "'>" + lotto[2] + "</div>"
+ "<div class='ball " + getBallClass(lotto[3]) + "'>" + lotto[3] + "</div>"
+ "<div class='ball " + getBallClass(lotto[4]) + "'>" + lotto[4] + "</div>"
+ "<div class='ball " + getBallClass(lotto[5]) + "'>" + lotto[5] + "</div>"
+ "</p>"
);
i++;
}
}
$("#btn_lotto").on("click", function () {
lottoCrate();
})
});
</script>
<div class="row">
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">로또 번호 가자!!</h3>
</div>
<div class="card-body" id="content">
생성 눌러라
</div>
<div class="card-footer">
<button type="button" id="btn_lotto" class="btn btn-block btn-success btn-lg">생성</button>
</div>
</div>
</div>
</div>
</body>
</html>