-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
148 lines (131 loc) · 5.28 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
<!DOCTYPE html>
<link rel="icon" href="https://cdn.jsdelivr.net/gh/xxlgenius/blog_img/logos/favicon32.ico" type="image/x-icon">
<html xmlns="index pages">
<head>
<title>xxlgenius' slides</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex, nofollow">
<style>
*,
*:after,
*:before {
box-sizing: border-box;
}
body,
html {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-weight: 300;
font-size: 16px;
background: #f2f2f2;
color: #2D3737;
display: flex;
align-items: center;
justify-content: center;
min-height: 100%;
}
.protected {
background: #fff;
-webkit-box-shadow: 0 2px 3px 0 rgba(0,0,0,0.1);
box-shadow: 0 2px 3px 0 rgba(0,0,0,0.1);
border-radius: 3px;
min-width: 500px;
}
.protected__content {
padding: 24px 28px;
}
.protected__content__heading {
font-size: 16px;
font-weight: 500;
margin: 0 0 12px;
line-height: 1;
}
.protected__alert {
display: none;
border-bottom: 1px solid transparent;
border-radius: 3px 3px 0 0;
padding: 12px 14px;
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.protected__content__input {
display: block;
border: solid 1px #ccc;
padding: 12px 14px;
-webkit-box-shadow: 0 2px 3px 0 rgba(0,0,0,0.1);
box-shadow: 0 2px 3px 0 rgba(0,0,0,0.1);
font-size: 16px;
width: 100%;
border-radius: 3px;
margin-bottom: 12px;
}
.protected__content__input:focus {
outline: none;
border-color: #228843;
}
.protected__content__btn {
background-color: #228843;
border-radius: 3px;
cursor: pointer;
border: none;
color: #fff;
padding: 12px 14px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-weight: 500;
font-size: 16px;
}
.protected__content__btn:hover {
background-color: #1C6D36;
}
</style>
</head>
<body>
<div class="protected">
<div class="protected__alert" data-id="alert">未找到与输入名称相符的幻灯片</div>
<div class="protected__content">
<h1 class="protected__content__heading">你想要打开哪个幻灯片?</h1>
<input class="protected__content__input" data-id="password" type="password" placeholder="输入幻灯片名称"/>
<button data-id="button" type="button" class="protected__content__btn">继续</button>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-sha1/0.6.0/sha1.min.js"></script>
<script type="text/javascript">
"use strict"
var button = document.querySelectorAll('[data-id="button"]')
var password = document.querySelectorAll('[data-id="password"]')
function login(secret) {
var hash = sha1(secret)
var url = hash + "/index.html"
var alert = document.querySelectorAll('[data-id="alert"]')
var request = new XMLHttpRequest()
request.open('GET', url, true)
request.onload = function () {
if (request.status >= 200 && request.status < 400) {
window.location = url
} else {
parent.location.hash = hash
alert[0].style.display = 'block'
password[0].setAttribute('placeholder', 'Incorrect password')
password[0].value = ''
}
}
request.onerror = function () {
parent.location.hash = hash
alert[0].style.display = 'block'
password[0].setAttribute('placeholder', 'Incorrect password')
password[0].value = ''
}
request.send()
}
button[0].addEventListener("click", function () {
login(password[0].value)
})
document.onkeydown = function (e) {
e = e || window.event
if (e.keyCode == 13) {
login(password[0].value)
}
}
</script>
</body>
</html>