-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
387 lines (350 loc) · 12.2 KB
/
index.html
File metadata and controls
387 lines (350 loc) · 12.2 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cookie-Cats</title>
<style>
#Cookie-Cats {
padding: 20px;
height: 10px;
}
.cat {
position: relative;
height: 80px;
width: 80px;
background-color: #ffc400;
border-radius: 10px 10px 50%/ 100% 100% 0px 0px;
.ear {
position: absolute;
top: -10px;
height: 36px;
width: 25px;
border-top-left-radius: 6px;
/* background-color: #5d5d5e; */
}
.left-ear {
left: 5px;
transform: rotate(6deg) skewY(48deg);
background-color: #cf9ec2;
border: #000000;
}
.right-ear {
right: 4px;
transform: rotate(33deg) skewY(48deg);
background-color: #000000;
}
.eye {
position: absolute;
top: 24px;
height: 11px;
width: 13px;
border-radius: 50%;;
background-color: #fff;
}
.left-eye {
left: 22px;
}
.right-eye {
right: 22px;
}
.mouth {
position: absolute;
top: 45px;
left: 50%;
transform: translateX(-50%);
height: 2px;
width: 8px;
background-color: #fff;
}
.tail {
position: absolute;
bottom: -0px;
left: -16px;
width: 60px;
height: 16px;
border: 6px solid #000000;
border-radius: 30%;
border-top: none;
}
}
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
height: 100%;
}
.container {
padding: 50px 0px;
height: 100%;
background-image: linear-gradient(to right, #003377, #c3a3b4);
}
.login-wrapper {
background-color: #fff;
width: 558px;
/* height: 588px; */
border-radius: 15px;
padding: 0 50px;
position: relative;
left: 50%;
/* top: 50%; */
/* margin-left: -50%; */
transform: translateX(-50%);
}
.header {
font-size: 38px;
font-weight: bold;
text-align: center;
line-height: 200px;
}
.input-item {
box-sizing: border-box;
display: block;
width: 100%;
margin-bottom: 20px;
border: 0;
padding: 10px;
border-bottom: 1px solid rgb(128, 125, 125);
font-size: 15px;
outline: none;
}
.input-item::placeholder {
text-transform: uppercase;
}
.btn {
box-sizing: border-box;
text-align: center;
padding: 10px;
width: 100%;
margin-top: 40px;
background-image: linear-gradient(to right, #003377, #c3a3b4);
color: #fff;
}
.msg {
text-align: center;
line-height: 88px;
}
a {
text-decoration-line: none;
color: #ABB1C7;
}
.custom-select {
padding-left: 5px;
box-sizing: border-box;
width: 100%;
/* padding: 10px; */
background: #fff;
height: 38px;
border: 0;
margin-bottom: 20px;
font-size: 15px;
border-bottom: 1px solid rgb(128, 125, 125);
}
.input-item-box {
display: flex;
}
.input-item-box .custom-select-ip {
background: #fff;
height: 38px;
border: 0;
width: 100%;
margin-bottom: 20px;
font-size: 15px;
border-bottom: 1px solid rgb(128, 125, 125);
}
.input-item-box .input-item-ip {
box-sizing: border-box;
display: block;
width: 100%;
margin-bottom: 20px;
border: 0;
padding: 10px;
border-bottom: 1px solid rgb(128, 125, 125);
font-size: 15px;
outline: none;
margin-left: 10px;
}
.input-item-box .input-item-label {
box-sizing: border-box;
display: block;
width: 83px;
min-width: 83px;
margin-bottom: 20px;
border: 0;
font-size: 12px;
border-bottom: 1px solid rgb(128, 125, 125);
outline: none;
display: flex;
padding-left: 10px;
align-items: center;
}
.form-container {
display: flex;
}
.form-item-box {
flex: 1;
/* width: 50%; */
}
</style>
</head>
<body>
<div class="container">
<div id="Cookie-Cats">
<div class="cat">
<div class="ear left-ear"></div>
<div class="ear right-ear"></div>
<div class="eye left-eye"></div>
<div class="eye right-eye"></div>
<div class="mouth"></div>
<div class="tail"></div>
</div>
</div>
<div class="login-wrapper">
<div class="header">欢迎领养饼干喵~</div>
<div class="form-container">
<form action="" method="post" onsubmit="submitForm()">
<div class="form-item-box" style="margin-right: 10px;">
<div class="form-wrapper">
<select class="custom-select" name="school" id="school">
<option value="" selected>选择学校</option>
<option value="CPU">中国药科大学</option>
</select>
<select class="custom-select" name="carrier" id="carrier">
<option value="" selected>选择供应商</option>
<option value="ChinaMobile">中国移动</option>
<option value="ChinaUnicom">中国联通</option>
<option value="ChinaTelecom">中国电信</option>
<option value="SchoolNetwork">校园网</option>
</select>
</div>
<div class="form-wrapper">
<input type="text" name="username" id="username" placeholder="用户名" class="input-item"/>
<input type="password" name="password" id="password" placeholder="密码" class="input-item"/>
</div>
<div class="input-item-box">
<div class="input-item-label">IP获取方式:</div>
<select class="custom-select-ip" name="IP_Obtain_Method" onchange="handleChangeIpType()"
id="selectIpType">
<option value="unnecessary" selected>无需获取</option>
<option value="manual">手动输入</option>
<option value="meow">meow</option>
</select>
</div>
</div>
</form>
<div class="form-item-box">
<input type="text" name="WiFi_SSID" id="WiFi_SSID" placeholder="认证路由SSID" class="input-item"/>
<input type="password" name="WiFi_PASSWORD" id="WiFi_PASSWORD" placeholder="认证路由密码"
class="input-item"/>
<input type="text" name="Cookie_Cat_SSID" id="Cookie_Cat_SSID" placeholder="Cookie-Cats无线名"
class="input-item"/>
<input type="password" name="Cookie_Cat_PASSWORD" id="Cookie_Cat_PASSWORD"
placeholder="Cookie-Cats无线密码" class="input-item"/>
<input type="hidden" name="IP_Obtain_Method" id="hiddenIpMethod">
<div id="selectIpByInput"></div>
</div>
</div>
<div class="btn" onclick="handleSubmit()">
<input type="submit" value="我输入好啦~" style="background-color: transparent;color: white;border: none;"/>
</div>
<div class="msg">
平台使用有疑问?<a href="https://github.com/Cookie-Cats/Cookie-Cats/issues">联系我们</a>
</div>
</div>
</div>
<script>
function handleChangeIpType() {
const el = document.querySelector('#selectIpType')
const input = document.querySelector('#selectIpByInput')
const hidden = document.querySelector('#hiddenIpMethod')
if (el.value === 'unnecessary') {
input.innerHTML = ''
hidden.value = 'unnecessary' // 提交内容为空
}
if (el.value === 'manual') {
input.innerHTML = '<input type="text" name="IP_Obtain_Method_Content" id="IP_Obtain_Method_Content" placeholder="请输入ip" class="input-item" />' // 在div中添加文本框
hidden.value = 'manual' // 设置隐藏input的值为manual
}
if (el.value === 'meow') {
input.innerHTML = '<input type="text" name="IP_Obtain_Method_Content" id="IP_Obtain_Method_Content" placeholder="请输入url" class="input-item" />' // 在div中添加文本框
hidden.value = 'meow' // 设置隐藏input的值为meow
}
}
async function resetConfig() {
try {
// 填完整的url
const response = await window.fetch('device/restart', {
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
});
if (response.status === 200) {
alert('重启成功');
} else {
throw new Error(`网络异常, statusCode(${response.status})`);
}
} catch (e) {
alert('服务器异常')
console.log(e)
}
}
async function postConfig(body) {
try {
// 填完整的url
const response = await window.fetch('config/save', {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
});
if (response.status < 200 || response.status >= 300) {
throw new Error(`网络异常, statusCode(${response.status})`);
}
const json = await response.json();
if (json.success) {
alert('饼干猫记住啦,我将会在3秒后重启以载入配置!')
setTimeout(() => {
resetConfig()
}, 3000)
} else {
alert(json.error)
}
} catch (e) {
alert('服务器异常')
console.log(e)
}
}
function handleSubmit() { // 提交按钮事件
const obj = {
allowOTA: "true",
}
;["Cookie_Cat_SSID", "Cookie_Cat_PASSWORD", "WiFi_SSID", "WiFi_PASSWORD", "username", "password", "carrier", "school"].forEach(item => {
const element = document.getElementById(item)
obj[item] = element.value
});
const el = document.querySelector('#selectIpType')
if (el.value === 'manual') {
obj.IP_Obtain_Method = {
manual: document.querySelector('#IP_Obtain_Method_Content').value
}
}
if (el.value === 'meow') {
obj.IP_Obtain_Method = {
meow: document.querySelector('#IP_Obtain_Method_Content').value
}
}
if (el.value === 'unnecessary') {
obj.IP_Obtain_Method = {
unnecessary: '0.0.0.0'
}
}
postConfig(obj)
}
</script>
</body>
</html>