Skip to content

Commit

Permalink
Create Generator.html
Browse files Browse the repository at this point in the history
  • Loading branch information
TurboHK authored Mar 2, 2022
1 parent 245742e commit 19c56c3
Showing 1 changed file with 171 additions and 0 deletions.
171 changes: 171 additions & 0 deletions Generator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=big5"/>
<title>抽籤系統</title>
<style>
.container {
background-color: #ffff99;
margin-top: 10px;
margin-left: 300px;
margin-right: 300px;
width: auto;
height: auto;
}
</style>
</head>

<body>
<div class="container">
<input
type="text"
style="border:0px;text-align:center;font-size:60px;background-color:#ffff99;"
id="txt">
<br>
<br>
<font size="20">
目前已经抽出<span id="count"> 0 </span>个!
</font>
<br>
<input
type="button"
style="font-size:30px"
value="開始/加速"
onClick="solve1();">
<input
type="button"
style='font-size:30px'
value="停止/減速"
onClick="solve2()">
<input
type="button"
style='font-size:30px'
value="清空數據"
onClick="Clear();">
<br>
<br>
<span id="display"></span>
<br>
</div>
<script>
var num = 0;
var arr = [];
var vis = [];
var mark = [];
var stringpro = "CONTENT A,CONTENT B,CONTENT C,CONTENT D,CONTENT E,CONTENT F"
var pro = stringpro.split(',');
var c = 0;
var k = 0;
var t;
var tt;
var flag = true;
//for(var i = 0; i < 19; i++)
// vis[i] = i+1;

var cont = 0;

while(true) {
var tt = parseInt(Math.random() * 6 + 1);

if(!mark[tt]) {
mark[tt] = 1;
vis[cont++] = tt;
}

if(cont === 6) {
break;
}
}

function timedCount() {
document.getElementById('txt').value = c;
k = k + 1;
k = k % (vis.length);
c = vis[k];
t = setTimeout("timedCount()",50)
}

function solve1() {
if(flag) {
timedCount();
flag = false;
}
}

function stopCount() {
clearTimeout(t);
tt = document.getElementById('txt').value;
}

function Random() {
var draw = document.getElementById('display');

num += 1;
arr.push(tt);
var tmp = tt;

tmp -= 1;
draw.innerHTML = draw.innerHTML + '<h1>第' + num + '组抽中:' + pro[tmp] + '<br/></h1>';
var tmp = [];

tmp.length = 0;
var cnt = 0;

for(var i = 0, len = vis.length; i < len; i += 1) {
if(vis[i] != tt) {
tmp[cnt] = vis[i];
cnt = cnt+1;
}
}

vis.length = 0;
for(var i = 0, len = tmp.length; i < len; i += 1) {
vis[i] = tmp[i];
}

document.getElementById("count").innerHTML = arr.length;
if(arr.length === 6){
alert('已经抽完!');
}
}

function solve2() {
if(!flag) {
stopCount();
Random();
flag = true;
}
}

function Clear() {
arr = null;
arr = [];

mark = [];
var cont = 0;

while(true) {
var tt = parseInt(Math.random() * 6 + 1);

if(!mark[tt]) {
mark[tt] = 1;
vis[cont++] = tt;
}

if(cont === 6) {
break;
}
}

k = 0;
num = 0;
c = 0;
clearTimeout(t);
document.getElementById('txt').value = '0';
document.getElementById('count').innerHTML = '0';
document.getElementById('display').innerHTML = '';
}
</script>
</body>
</html>

0 comments on commit 19c56c3

Please sign in to comment.