-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
492 lines (366 loc) · 16.2 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
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="Zhiyaun Yao">
<title>Zhiyaun Yao' homepage</title>
<link rel="icon" href="/favicon.ico">
<!-- stylesheets list from _config.yml -->
<link rel="stylesheet" href="/css/style.css">
<!-- scripts list from _config.yml -->
<script src="/js/script.js"></script>
<script src="/js/tocbot.min.js"></script>
<script src="/js/jquery.min.js"></script>
<!-- MathJax配置,可通过单美元符号书写行内公式等 -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
preferredFont: "TeX",
availableFonts: ["STIX","TeX"],
linebreaks: { automatic:true },
EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
},
tex2jax: {
inlineMath: [ ["$", "$"], ["\\(","\\)"] ],
processEscapes: true,
ignoreClass: "tex2jax_ignore|dno",
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
TeX: {
equationNumbers: { autoNumber: "AMS" },
noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } },
Macros: { href: "{}" }
},
messageStyle: "none"
});
</script>
<!-- 给MathJax元素添加has-jax class -->
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<!-- 通过连接CDN加载MathJax的js代码 -->
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<!-- 搜索的部分 -->
<script>
// function searchToggle() {
// const width = $(document.body).width()
// if(width > 479) {
// return;
// }
// const search = $('.search');
// const searchForm = $('.form-search')
// if(!search.hasClass("mobile-search")) {
// search.addClass("mobile-search");
// } else {
// search.removeClass("mobile-search");
// }
// }
function searchToggle() {
const width = $(document.body).width()
if(width > 479) {
return;
}
const search = $('.search');
const searchForm = $('.form-search');
const menuToggle = $('.menu-toggle');
const title = $('.navbar-header-title ');
if(!search.hasClass("mobile-search")) {
search.addClass("mobile-search");
menuToggle.addClass("open-search")
title.addClass("mobile-title-hidden")
} else {
search.removeClass("mobile-search");
menuToggle.removeClass("open-search")
// title.css({visibility: 'visible'})
title.removeClass("mobile-title-hidden")
}
}
function search(searchInputEl, formEl, flag) {
const path = "/" + "search.json"; // 可以在public 下查看这个search.json
$(formEl).submit(function(e){
e.preventDefault();
let target = null
if(searchInputEl == null) {
const screenWidth = $(document.body).width();
target = screenWidth > 479 ? $('#pc-search-input') : $('#mobile-search-input');
console.log(target);
} else {
target = $(searchInputEl)
}
if(!flag && target.val() === '') {
return ;
}
$("#u-search").fadeIn(500, function() {
$("body > .wrapper").addClass("modal-active");
$.ajax({
url: path,
dataType: "json",
beforeSend: function (xhr) {
$input = target.val();
$(".form-input").val($input);
const loadingBar = $('.search-loading-bar')
loadingBar.css({
width:'100%',
display: 'block'
});
},
success: function( datas ) {
console.log(datas);
const $resultPanel = $(".modal-body")[0];
let str = `<ul class="modal-results">`;
var keywords = $(".form-input").val().trim().toLowerCase().split(/[\s\-]+/);
$resultPanel.innerHTML = "";
let hasResult = false
let text = `<div class="no-result">找不到与关键词相关的内容....</div>`;
if ($(".form-input").val().trim().length <= 0) {
// 没有结果
$resultPanel.innerHTML = text;
return;
}
datas.forEach(function (data, index) {
var isMatch = true;
if (!data.title || data.title.trim() === '') {
data.title = "Untitled";
}
var data_title = data.title.trim().toLowerCase();
var data_content = data.content && data.content.trim().replace(/<[^>]+>/g, "").toLowerCase() || '';
var data_url = data.url;
var index_title = -1;
var index_content = -1;
var first_occur = -1;
// only match artiles with not empty contents
if (data_content !== '') {
keywords.forEach(function (keyword, i) {
index_title = data_title.indexOf(keyword);
index_content = data_content.indexOf(keyword);
if (index_title < 0 && index_content < 0) {
isMatch = false;
} else {
hasResult = true
if (index_content < 0) {
index_content = 0;
}
if (i == 0) {
first_occur = index_content;
}
}
});
} else {
isMatch = false;
}
// show search results
if (isMatch) {
str += `<li class='result-item'><a href='${data_url}' class='result-item-detail'> <span class="title">${data_title}</span>`;
var content = data.content.trim().replace(/<[^>]+>/g, "");
if (first_occur >= 0) {
// cut out 200 characters
var start = first_occur - 40;
var end = first_occur + 160;
if (start < 0) {
start = 0;
}
if (start == 0) {
end = 200;
}
if (end > content.length) {
end = content.length;
}
var match_content = content.substring(start, end);
// highlight all keywords
keywords.forEach(function (keyword) {
var regS = new RegExp(keyword, "gi");
match_content = match_content.replace(regS, `<em class="search-keyword">${keyword}</em>`);
});
str += `<span class="content"> ${match_content} ...</span></a>`;
}
str += "</li>";
}
});
str += "</ul>";
if(hasResult) {
$resultPanel.innerHTML = str;
} else {
$resultPanel.innerHTML = text;
}
},
complete: function() {
setTimeout(() => {
const loadingBar = $('.search-loading-bar')
loadingBar.css({
width:'0%',
display: 'none'
});
}, 300)
}
});
})
});
}
$(document).ready(function() {
$('.modal-close').click(function () {
$("#u-search").fadeOut();
$("body > .wrapper").removeClass("modal-active")
})
$('.modal-overlay').click(function() {
$("#u-search").fadeOut();
$("body > .wrapper").removeClass("modal-active")
})
search(null, ".form-search", false)
search("#u-search-modal-form .form-input", ".u-search-modal-form", true)
})
</script>
<meta name="generator" content="Hexo 6.3.0"></head>
<body>
<script>
// this function is used to check current theme before page loaded.
(() => {
const currentTheme = window.localStorage && window.localStorage.getItem('theme') || '';
const isDark = currentTheme === 'dark';
const pagebody = document.getElementsByTagName('body')[0]
if (isDark) {
pagebody.classList.add('dark-theme');
// mobile
document.getElementById("mobile-toggle-theme").innerText = "· Dark"
} else {
pagebody.classList.remove('dark-theme');
// mobile
document.getElementById("mobile-toggle-theme").innerText = "· Light"
}
})();
</script>
<div class="wrapper">
<header>
<nav class="navbar">
<div class="container">
<div class="navbar-header header-logo"><a href="/">Zhiyuan Yao's Blog</a></div>
<div class="menu navbar-right">
<!-- 这里表示的是pc端搜索框 -->
<div class="search ">
<div class="search-btn" onClick="searchToggle()">
<img src="/image/search.jpg" class="search-btn-img" />
</div>
<form class="form-search">
<input class="input" placeholder="点此搜索" autocomplete="off" id="pc-search-input"/>
</form>
</div>
<a class="menu-item" href="/archives">Posts</a>
<a class="menu-item" href="/category">Categories</a>
<a class="menu-item" href="/tag">Tags</a>
<a class="menu-item" href="/about">About</a>
<input id="switch_default" type="checkbox" class="switch_default">
<label for="switch_default" class="toggleBtn"></label>
</div>
</div>
</nav>
<nav class="navbar-mobile" id="nav-mobile">
<div class="container">
<div class="navbar-header">
<div>
<a href="/">Zhiyuan Yao's Blog</a><a id="mobile-toggle-theme">· Light</a>
</div>
<div class="navbar-mobile-right">
<div class="search ">
<div class="search-btn" onClick="searchToggle()">
<img src="/image/search.jpg" class="search-btn-img" />
</div>
<form class="form-search">
<input class="input" placeholder="点此搜索" autocomplete="off" id="mobile-search-input"/>
</form>
</div>
<div class="menu-toggle" onclick="mobileBtn()">☰ Menu</div>
</div>
<div class="menu" id="mobile-menu">
<a class="menu-item" href="/archives">Posts</a>
<a class="menu-item" href="/category">Categories</a>
<a class="menu-item" href="/tag">Tags</a>
<a class="menu-item" href="/about">About</a>
</div>
</div>
</nav>
</header>
<script>
var mobileBtn = function f() {
var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
var mobileMenu = document.getElementById("mobile-menu");
if(toggleMenu.classList.contains("active")){
toggleMenu.classList.remove("active")
mobileMenu.classList.remove("active")
}else{
toggleMenu.classList.add("active")
mobileMenu.classList.add("active")
}
}
</script>
<div class="main">
<div class="container profile-container">
<div class="intro">
<div class="avatar">
<a href="/archives"><img src="/image/avatar.jpeg"></a>
</div>
<div class="nickname">Zhiyuan Yao</div>
<div class="description"><p>Lorem ipsum dolor sit amet, <strong>consectetur adipiscing elit.</strong> <br>Fusce eget urna vitae velit <em>eleifend interdum at ac</em> nisi.</p>
</div>
<div class="links">
<a class="link-item" title="Blog" href="/archives">
<i class="iconfont icon-blog"></i>
</a>
<a class="link-item" title="Github" target="_blank" rel="noopener" href="https://github.com/zyYao0720">
<i class="iconfont icon-github"></i>
</a>
</div>
</div>
</div>
</div>
<footer id="footer" class="footer">
<div class="copyright">
<span>© Zhiyaun Yao | Powered by <a href="https://hexo.io" target="_blank">Hexo</a> & <a href="https://github.com/Siricee/hexo-theme-Chic" target="_blank">Chic</a>
|
<!-- 访客数量 -->
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span class="site-uv">
Total visitors:
<i class="busuanzi-value" id="busuanzi_value_site_uv"></i>
</span>
<span class="site-pv">
| Total visits:
<i class="busuanzi-value" id="busuanzi_value_site_pv"></i>
</span>
</span>
</div>
</footer>
</div>
<!-- 搜索功能 -->
<!-- Chic/layout.ejs -->
<div id="u-search">
<div class="modal">
<div class="modal-header">
<div class="container">
<form id="u-search-modal-form" class="u-search-modal-form">
<button type="submit" class="form-submit-btn">
<img src="/image/search.jpg" class="search-btn-img" />
</button>
<input placeholder="搜索内容..." class="form-input" id="modal-form-input">
</form>
<a class="modal-close">x</a>
</div>
<div class="search-loading">
<div class="search-loading-bar"></div>
</div>
</div>
<div class="modal-body">
</div>
</div>
<div class="modal-overlay"></div>
</div>
</body>
</html>