|
211 | 211 | </body>
|
212 | 212 | <script>
|
213 | 213 |
|
214 |
| - const $ = document.querySelector.bind(document); |
| 214 | + const $$$ = document.querySelector.bind(document); |
215 | 215 | const changeType = (type) => {
|
216 |
| - $('#ring').style.display = 'none'; |
217 |
| - $('#error').style.display = 'none'; |
218 |
| - $('#success').style.display = 'none'; |
| 216 | + $$$('#ring').style.display = 'none'; |
| 217 | + $$$('#error').style.display = 'none'; |
| 218 | + $$$('#success').style.display = 'none'; |
219 | 219 | switch (type) {
|
220 | 220 | case 'ring':
|
221 |
| - $('#ring').style["display"] = 'block'; |
| 221 | + $$$('#ring').style["display"] = 'block'; |
222 | 222 | break;
|
223 | 223 | case 'error':
|
224 |
| - $('#error').style["display"] = 'block'; |
| 224 | + $$$('#error').style["display"] = 'block'; |
225 | 225 | break;
|
226 | 226 | case 'success':
|
227 |
| - $('#success').style["display"] = 'block'; |
| 227 | + $$$('#success').style["display"] = 'block'; |
228 | 228 | break;
|
229 | 229 | }
|
230 | 230 | }
|
231 | 231 | changeType('ring');
|
232 |
| - $('#info').innerHTML = '正在安装ClientWorker...'; |
| 232 | + $$$('#info').innerHTML = '正在安装ClientWorker...'; |
233 | 233 | navigator.serviceWorker.register('/cw.js?t=' + new Date().getTime()).then(async (registration) => {
|
234 | 234 | const conf = () => {
|
235 |
| - $('#info').innerHTML = 'ClientWorker已安装,等待配置中...'; |
| 235 | + $$$('#info').innerHTML = 'ClientWorker已安装,等待配置中...'; |
236 | 236 | fetch('/cw-cgi/api?type=config')
|
237 | 237 | .then(res => res.text())
|
238 | 238 | .then(text => {
|
239 | 239 | if (text === 'ok') {
|
240 | 240 | changeType('success');
|
241 |
| - $('#info').innerHTML = 'ClientWorker已安装并配置完成,正在无刷新启动...'; |
| 241 | + $$$('#info').innerHTML = 'ClientWorker已安装并配置完成,正在无刷新启动...'; |
242 | 242 | fetch(window.location.href).then(res => res.text()).then(text => {
|
243 | 243 | document.open()
|
244 | 244 | document.write(text);
|
245 | 245 | document.close();
|
246 | 246 | });
|
247 | 247 | } else {
|
248 |
| - $('#info').innerHTML = 'ClientWorker配置失败,可能还没有准备好,正在进行第二次...'; |
| 248 | + $$$('#info').innerHTML = 'ClientWorker配置失败,可能还没有准备好,正在进行第二次...'; |
249 | 249 | setTimeout(() => {
|
250 | 250 | conf()
|
251 | 251 | }, 200);
|
252 | 252 | }
|
253 | 253 | }).catch(err => {
|
254 | 254 | changeType('error');
|
255 |
| - $('#info').innerHTML = 'ClientWorker配置失败,请检查您的配置!错误原因:' + err.message; |
| 255 | + $$$('#info').innerHTML = 'ClientWorker配置失败,请检查您的配置!错误原因:' + err.message; |
256 | 256 | });
|
257 | 257 | }
|
258 | 258 | setTimeout(() => {
|
259 | 259 | conf()
|
260 | 260 | }, 50);
|
261 | 261 | }).catch(err => {
|
262 | 262 | changeType('error');
|
263 |
| - $('#info').innerHTML = 'ClientWorker安装失败,错误原因:' + err.message; |
| 263 | + $$$('#info').innerHTML = 'ClientWorker安装失败,错误原因:' + err.message; |
264 | 264 | });
|
265 | 265 | </script>
|
266 | 266 |
|
|
0 commit comments