-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.html
225 lines (177 loc) · 5.37 KB
/
search.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>帮你搜索 - 搜索页</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<style type="text/css">
body {
font-family: "Helvetica Neue", Helvetica, Arial, "STHeiti", "Microsoft Yahei", sans-serif;
}
.bg-wz-467b96 {
background: #467b96;
}
.fs-wz-12 {
font-size: 12px;
}
.main {
text-align: center;
padding: 80px 0;
color: white;
min-height: 100vh;
}
.main h1 {
font-size: 36px;
font-weight: bold;
margin-bottom: 30px;
}
.footer {
padding: 50px 0;
background: #333;
}
.footer .github i {
font-size: 28px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">帮你搜索</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="./index.php">首页 <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://blog.wz52.cn">惜梦博客</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/wzblog"><i class="bi-github"></i> Github</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid bg-wz-467b96">
<div class="main col-md-6 offset-md-3">
<h1>帮 你 搜 索</h1>
<form id="search">
<div class="input-group">
<input type="text" class="form-control form-control-lg" placeholder="输入一个问题">
<div class="input-group-append">
<button class="btn btn-warning btn-lg"><i class="bi bi-search"></i></button>
</div>
</div>
</form>
<div class="card" style="margin-top: 80px;">
<div class="card-body text-dark" id="tipsText">
让我来教你正确的打开方式
</div>
</div>
</div>
</div>
<footer class="footer text-center">
<div class="github"><a href="https://github.com/wzblog"><i class="bi-github text-muted"></a></i></div>
<div class="copyright text-muted">© 2021 <a href="https://blog.wz52.cn" class="text-muted">惜梦</a>. All rights reserved.</div>
</footer>
<img src="./images/arrow.cur" width="32" alt="arrow" id="arrow" style="position: absolute; top: 0; left: 0;">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script src="./common.js"></script>
<script>
$('#search').submit(function(){
//+---------------------
// 跳转地址处理
//+---------------------
try {
(function(){
// 获取跳转地址
var goto = getParam('goto');
if (! goto) {
throw new Error('跳转地址为空');
}
// 将 base64 转为 ascii
var url = atob(goto);
// 设置 3 秒后自动跳转
setTimeout(function(){
location.replace(url);
}, 3000);
})();
} catch (e) {
console.error(e);
}
// 取消默认操作
return false;
});
//+---------------------
// 动画
//+---------------------
var arrow = $('#arrow');
var searchInput = $('#search input');
var searchButton = $('#search button');
var tipsText = $('#tipsText');
// 获取输入框的位置
var searchInputOffset = searchInput.offset();
// 获取按钮位置
var searchButtonOffset = searchButton.offset();
// 设置提示信息
tipsText.html('1、找到输入框并选中');
// 1. 将鼠标从左上角移动到输入框上
// top + 15 与 left + 150 是调整位置显示好看些
arrow.animate({
top: searchInputOffset.top + 15,
left: searchInputOffset.left + 150,
}, 5000, function() {
// 状态: 移动到输入框上后
// 设置提示信息
tipsText.html('2、输入你要找的内容');
// 输入框获取焦点
searchInput.focus();
// 输入内容
var query = getParam('query');
if (!query) new Error('没有搜索词');
// 输入内容
inputContent(searchInput.get(0), query, function(){
// 状态: 输入完成后
// 设置提示信息
tipsText.html('3、点击下“<i class="bi-search text-muted"></i>”按钮');
// 给鼠标设置层级,让鼠显示出来.
arrow.css('z-index', 9);
// 2. 移动鼠标到搜索按钮上
// left + 18 是调整位置显示好看些
arrow.animate({
left: searchButtonOffset.left + 18,
}, 5000, function(){
// 状态: 移动到搜索按钮后
// 设置提示信息
tipsText.html('<strong style="font-size: 36px; color: red;">怎么样,学会了吗?</strong>');
// 3. 点击搜索按钮
searchButton.click();
});
});
});
// 给输入框输入内容
function inputContent(inp, text, fn)
{
var i = 0;
var timer;
// TODO: 判断输入框类型
timer = setInterval(function(){
if (i < text.length) {
inp.value += text[i];
i++;
} else {
clearInterval(timer);
// 回调
fn();
}
}, 200)
return true;
}
</script>
</body>
</html>