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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LOTTY WINNER~</title>
<style type="text/css">
html {
font-size: 12px;
font-family: "sans serif", tahoma, verdana, helvetica;
}

body {
text-align: center;
padding-top: 20%;
}

#pool {
padding: 10px;
border: dashed 1px orangered;
width: 40%;
min-height: 200px;
margin-left: auto;
margin-right: auto;
max-height: 200px;
overflow: auto;
overflow-y: yes;
}

#pool span {
font-size: 24px;
line-height: 36px;
}

#pool .red {
color: indianred;
}

#pool .blue {
color: dodgerblue;
}

.title {
}

.red {
color: indianred
}

.blue {
color: dodgerblue
}

.green {
color: forestgreen
}

.purple {
color: mediumpurple
}

.pink {
color: deeppink
}

.dark {
color: black
}

.yellow {
color: yellowgreen
}
</style>
<script type="text/javascript">

//红色选择六个数 1-33里选
//蓝色选择一个数 1-16里选

var ticket = {};
window.onload = function () {
var btn = document.getElementById('lotty');

//摇奖按钮事件
btn.addEventListener('click', function () {

reset_ticket();
for (var i = 0; i < 6; i++) {
ticket['red'].push(Math.floor(Math.random() * 33 + 1));
}

ticket['blue'] = Math.floor(Math.random() * 16 + 1);

append_pull(ticket);
});

//自动滚动生成
var scroll = document.getElementById("scroll");
var interval;
scroll.addEventListener('click', function () {
if (scroll.innerHTML == 'SCROLL@') {
scroll.innerHTML = "PAUSE-";
//开始滚动
interval = setInterval(function () {
btn.click();
}, 1000);
}
else {
scroll.innerHTML = "SCROLL@";
clearInterval(interval);
}
});

var clear = document.getElementById('clear');
clear.addEventListener('click', function () {
var pool = document.getElementById('pool');
pool.innerHTML = '';
});

blink();
};

//title变换颜色class组
var colors = ['red', 'blue', 'green', 'purple', 'pink', 'dark', 'yellow'];

//闪烁标题
var blink = function () {
var title = document.getElementById('title');
var titles = title.innerHTML.split('');

setInterval(function () {
var html = '';
for (var i = 0; i < titles.length; i++) {
html += '<span class=' + colors[Math.floor(Math.random() * 7)] + '>' + titles[i] + '</span>';
}
title.innerHTML = html;
}, 1000);
};

//生成结果滚动展示
function append_pull(ticket) {
var pool = document.getElementById('pool');
pool.innerHTML = pool.innerHTML + "<span class=\'red\'>" + ticket['red'].join(" ") + "</span><span class=\'blue\'> (" + ticket['blue'] + ")</span><br />";

setInterval(scroll_end(pool), 100);
reset_ticket();
}

//重置ticket
function reset_ticket() {
ticket = {};
ticket['red'] = [];
ticket['blue'] = null;
}

//滚动到对象底部
function scroll_end(e) {
e.scrollTop = e.scrollHeight;
}
</script>
</head>
<body>
<div><h1 class="title" id="title">LOTTY WINNER~!</h1></div>
<br/>
<div id="pool">

</div>
<br/>
<button id="lotty">LOTTY ME~!</button>
<button id="scroll">SCROLL@</button>
<button id="clear">CLEAR^</button>
</body>
</html>