-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (151 loc) · 5.22 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
<!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;
}
.main h2 {
font-size: 24px;
font-weight: normal;
margin: 20px 0;
color: #DAE5EA;
}
.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>
<h2>我来“帮你”进行搜索</h2>
<form id="search">
<div class="form-group">
<label for="engine">选择搜索引擎</label>
<select class="custom-select custom-select-lg" id="engine" name="type">
<option selected value="baidu">百度</option>
<option value="bing">必应</option>
<option value="google">谷歌</option>
<option value="sogou">搜狗</option>
<option value="360">360</option>
</select>
</div>
<div class="form-group">
<label for="search">搜索内容</label>
<input type="text" name="query" class="form-control form-control-lg" id="search" placeholder="输入一个问题">
</div>
<div class="form-group fs-wz-12">
<div class="form-check form-check-inline">
<input class="form-check-input" name="jump" type="checkbox" id="jump" checked>
<label class="form-check-label" for="jump">使用跳转页</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn bth-lg btn-warning">生成“教你”搜索地址</button>
</div>
</form>
<div class="card invisible" style="margin-top: 80px;" id="resultArea">
<div class="card-"></div>
<div class="card-body text-dark">
<a href="javascript:void(0);" class="card-link btn btn-outline-primary" id="copyLink" data-clipboard-text="">复制地址</a>
<a href="" target="_blank" class="card-link btn btn-outline-secondary" id="showDemo">查看效果</a>
<hr>
<div id="showUrl"></div>
</div>
</div>
</div>
</div>
<footer class="footer text-center">
<div class="github"><a href="https://github.com/wzblog"><i class="bi-github text-muted"></i></a></div>
<div class="copyright text-muted">© 2021 <a href="https://blog.wz52.cn" class="text-muted">惜梦</a>. All rights reserved.</div>
</footer>
<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="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script>
<script src="./common.js"></script>
<script type="text/javascript">
var clipboard = new ClipboardJS('#copyLink');
$('#search').submit(function() {
// 获取表单所有参数
var formDataArray = $(this).serializeArray();
// 遍历生成参数
// 将 [{}, {}] 转为 {name: value, name: value}
var formData = {};
for (var i = 0; i < formDataArray.length; i++) {
var name = formDataArray[i].name;
var value = formDataArray[i].value;
formData[name] = encodeURI(value);
}
// 生成搜索url
var url = CONFIG.engine[formData.type].format(formData.query);
// 判断是否使用跳转页
if (formData.jump) {
url = CONFIG.jumpPage.format(btoa(url), formData.query);
}
// 显示到网页中
$('#showUrl').html(url);
// 设置复制属性
$('#copyLink').attr('data-clipboard-text', url);
// 设置演示链接
$('#showDemo').attr('href', url);
// 显示结果
$('#resultArea').removeClass('invisible');
// 获取结果区域位置
var resultAreaOffset = $('#resultArea').offset();
// 跳转到结果区域
scrollTo({
top: resultAreaOffset.top,
behavior: "smooth"
});
// 取消默认操作
return false;
});
</script>
</body>
</html>