-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlottery.html
50 lines (43 loc) · 1.02 KB
/
lottery.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
<html>
<head>
<meta name="viewport" content="initial-scale=1" />
<style>
html {
width: 100%;
height: 100%;
}
* {
border: 0px;
font-size: 20px;
line-height: 30px;
}
textarea {
width: 100%;
height: 300px;
background: #222;
color: #eee;
}
button {
width: 100%;
height: 30px;
background: #666;
}
</style>
</head>
<body>
<textarea placeholder="每一行為籤名" id="r"></textarea>
<button onclick="start()">抽籤</button>
<script>
var r = document.getElementById("r");
function start() {
var rs = r.value.split("\n").filter(function (v) {
return !!v;
}),
idx = (Math.random() * rs.length) | 0;
alert(rs[idx]);
rs.splice(idx, 1);
r.value = rs.join("\n");
}
</script>
</body>
</html>