-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.html
92 lines (90 loc) · 2.04 KB
/
random.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
<!DOCTYPE HTML>
<meta charset="utf-8">
<title>随机数生成器</title>
<head>
<link rel="icon" href="./Assets/app.png" type="image/x-icon">
</head>
<body>
<center>
<h1>随机数生成器</h1>
</center>
最小值:<input type="" name="" id="ranmin" value="0">
<br><br>
最大值:<input type="" name="" id="ranmax" value="100">
<br><br>
生成个数:<input type="" name="" id="rangs" value="1">
<br><br>
<button style="font-size: 25px;" id="ranbt" onclick="random()" disabled><b>生成随机数</b></button>
<br><br>
结果:<b id="ranshow" style="font-size: 30px;"></b>
<br><br>
<center><h6><a href="./random.html" target="_blank">在新标签页中打开</a><h6></center>
<!--<center><br><h6>(修改自<a href="https://suntrise.github.io">STR</a> 随机数生成器)</h6></center>-->
</body>
<style type="text/css">
body{
font-size: 20px;
background: #eee;
color: #000;
}
input{
font-size: 25px;
}
button{
padding: 20px;
color: #000;
border: 2px solid #459439;
border-radius: 3px;
background: #A2FF74;
}
button:hover {
border: 2px solid #fff;
}
@media (prefers-color-scheme: dark) {
body {
background-color: rgb(40,40,40);
color: #fff;
}
button{
padding: 20px;
color: #fff;
border: 2px solid #65D954;
border-radius: 3px;
background: #459439;
}
}
</style>
<script type="text/javascript">
var min = 0
var max = 0
var ran = 0
var gs = 0
var ranstr = ""
var ctd = setInterval(ranch,1)
function ranch() {
min = Math.floor(ranmin.value)
max = Math.floor(ranmax.value)
if(min>max){
ranbt.disabled = true;
ranshow.innerHTML = "最小值不能大于最大值!"
}
else{
ranbt.disabled = "";
ranshow.innerHTML = ranstr;
}
}
function random() {
ranstr = "";
while(gs<rangs.value){
min = Math.floor(ranmin.value)
max = Math.floor(ranmax.value)
ran = Math.round(min+Math.random()*(max-min))
gs++
ranstr += ran +" ";
}
if (gs==rangs.value) {
gs=0
ranshow.innerHTML = ranstr;
}
}
</script>