-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
208 lines (185 loc) · 5.34 KB
/
index.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>智学网排名计算器</title>
<link rel="icon" href="https://wmimg.com/i/1169/2024/10/67137de25d188.png" type="image/png">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
}
h1 {
color: #0dc2b3; /* 主色调 */
margin-bottom: 30px;
}
.container {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
select,
input,
button {
display: block;
width: 100%;
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
select {
appearance: none;
background-color: #f8f8f8;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="%230dc2b3"><path d="M7 10l5 5 5-5z"/></svg>');
background-repeat: no-repeat;
background-position: right 10px center;
padding-right: 30px;
}
select:focus {
border-color: #0dc2b3;
box-shadow: 0 0 5px rgba(13, 194, 179, 0.5);
outline: none;
}
input {
background-color: #f8f8f8;
}
input:focus {
border-color: #0dc2b3;
box-shadow: 0 0 5px rgba(13, 194, 179, 0.5);
outline: none;
}
button {
background-color: #0dc2b3; /* 主色调 */
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0a9e91; /* 主色调的深色变体 */
}
#result {
color: #333;
font-size: 18px;
margin-top: 20px;
}
label {
display: block;
margin-bottom: 10px;
font-size: 16px;
color: #333;
}
.footer {
margin-top: 20px;
font-size: 14px;
color: #666;
}
.footer a {
color: #0dc2b3; /* 主色调 */
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
.error {
color: red;
font-size: 14px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>智 学 网 排 名 计 算 器</h1>
<label for="gradeSelect">选择等级</label>
<select id="gradeSelect">
<option value="A5">A5</option>
<option value="A4">A4</option>
<option value="A3">A3</option>
<option value="A2">A2</option>
<option value="A1">A1</option>
<option value="B5">B5</option>
<option value="B4">B4</option>
<option value="B3">B3</option>
<option value="B2">B2</option>
<option value="B1">B1</option>
<option value="C5">C5</option>
<option value="C4">C4</option>
<option value="C3">C3</option>
<option value="C2">C2</option>
<option value="C1">C1</option>
<option value="D5">D5</option>
<option value="D4">D4</option>
<option value="D3">D3</option>
<option value="D2">D2</option>
<option value="D1">D1</option>
<option value="E">E</option>
</select>
<!-- 添加“输入考试总人数”标题 -->
<label for="totalStudents">输入考试总人数</label>
<input type="number" id="totalStudents" placeholder="输入考试总人数">
<button onclick="calculateRank()">计算排名</button>
<p id="result"></p>
<p id="error" class="error"></p>
</div>
<!-- 添加版权标识 -->
<div class="footer">
© 2024 <a href="https://peter267.zeabur.app" target="_blank">Wu Jingbo</a>
</div>
<script>
function calculateRank() {
var gradeSelect = document.getElementById("gradeSelect");
var totalStudentsInput = document.getElementById("totalStudents");
var totalStudents = totalStudentsInput.value;
var grade = gradeSelect.value;
var errorElement = document.getElementById("error");
var resultElement = document.getElementById("result");
// 清除之前的错误信息和结果
errorElement.textContent = "";
resultElement.textContent = "";
// 验证输入是否为正整数
if (!Number.isInteger(Number(totalStudents)) || totalStudents <= 0) {
errorElement.textContent = "请输入一个正确的数字。";
return;
}
var rankRanges = {
"A5": [0, 2],
"A4": [2, 5],
"A3": [5, 9],
"A2": [9, 14],
"A1": [14, 20],
"B5": [20, 27],
"B4": [27, 34],
"B3": [34, 41],
"B2": [41, 48],
"B1": [48, 55],
"C5": [55, 61],
"C4": [61, 67],
"C3": [67, 73],
"C2": [73, 79],
"C1": [79, 85],
"D5": [85, 90],
"D4": [90, 94],
"D3": [94, 97],
"D2": [97, 98],
"D1": [98, 99],
"E": [99, 100]
};
var range = rankRanges[grade];
var minRank = Math.ceil(totalStudents * (range[0] / 100));
var maxRank = Math.ceil(totalStudents * (range[1] / 100));
resultElement.innerHTML = "你的排名在 " + minRank + " 到 " + maxRank + " 之间";
}
</script>
</body>
</html>