sinzmise-cetastories 2.0.0-1731066602594 → 2.0.0-1731114112124
Sign up to get free protection for your applications and to get access to all the features.
- package/404/index.html +4033 -1
- package/about/index.html +4041 -1
- package/album/index.html +4050 -1
- package/archives/2021/12/index.html +3917 -1
- package/archives/2021/index.html +3917 -1
- package/archives/2022/12/index.html +3917 -1
- package/archives/2022/index.html +3917 -1
- package/archives/2023/01/index.html +4072 -1
- package/archives/2023/02/index.html +3917 -1
- package/archives/2023/03/index.html +4063 -1
- package/archives/2023/04/index.html +3992 -1
- package/archives/2023/07/index.html +4217 -1
- package/archives/2023/08/index.html +4067 -1
- package/archives/2023/09/index.html +3917 -1
- package/archives/2023/10/index.html +3917 -1
- package/archives/2023/11/index.html +3917 -1
- package/archives/2023/12/index.html +3918 -1
- package/archives/2023/index.html +4591 -1
- package/archives/2023/page/2/index.html +4572 -1
- package/archives/2023/page/3/index.html +3930 -1
- package/archives/2024/01/index.html +4142 -1
- package/archives/2024/02/index.html +3922 -1
- package/archives/2024/03/index.html +3916 -1
- package/archives/2024/04/index.html +3997 -1
- package/archives/2024/05/index.html +4065 -1
- package/archives/2024/06/index.html +3917 -1
- package/archives/2024/07/index.html +3917 -1
- package/archives/2024/08/index.html +3992 -1
- package/archives/2024/09/index.html +3917 -1
- package/archives/2024/10/index.html +3984 -1
- package/archives/2024/index.html +4576 -1
- package/archives/2024/page/2/index.html +4433 -1
- package/archives/index.html +4560 -1
- package/archives/page/2/index.html +4560 -1
- package/archives/page/3/index.html +4560 -1
- package/archives/page/4/index.html +4560 -1
- package/archives/page/5/index.html +4560 -1
- package/assets/algolia/algoliasearch.js +7182 -3
- package/assets/algolia/algoliasearchLite.js +4445 -3
- package/atom.xml +31 -31
- package/bbs/bbs.html +4012 -1
- package/bbs/bbs.js +12 -2
- package/bbs/index.html +4031 -1
- package/categories/index.html +4050 -1
- package/categories//344/270/252/344/272/272/345/260/217/350/256/260/index.html +4570 -1
- package/categories//344/270/252/344/272/272/345/260/217/350/256/260/page/2/index.html +4485 -1
- package/categories//346/255/214/346/233/262/346/224/266/351/233/206/index.html +3920 -1
- package/categories//346/270/270/346/210/217/347/233/270/345/205/263/index.html +4148 -1
- package/categories//347/253/231/347/202/271/346/212/230/350/205/276/index.html +4610 -1
- package/categories//347/253/231/347/202/271/346/212/230/350/205/276/page/2/index.html +4148 -1
- package/categories//351/241/271/347/233/256/346/212/230/350/205/276/index.html +4072 -1
- package/charts/index.html +4039 -1
- package/comments/index.html +4052 -1
- package/content.json +1 -0
- package/css/custom2.css +3 -2
- package/css/first.css +1868 -2
- package/css/pace/big-counter.css +39 -2
- package/css/pace/corner-indicator.css +72 -2
- package/css/pace/flash.css +76 -2
- package/css/pace/mac-osx.css +86 -2
- package/css/pace/pace.css +50 -2
- package/css/plane.css +59 -2
- package/css/style.css +8585 -2
- package/css/tags.css +3516 -2
- package/essay/index.html +4050 -1
- package/fcircle/index.html +4075 -1
- package/games +61 -19
- package/index.html +4717 -1
- package/js/app.js +1341 -2
- package/js/autoload.js +62 -2
- package/js/ceta/fancybox.css +2 -2
- package/js/ceta/fancybox.umd.js +2 -2
- package/js/ceta/iconfontInkss.js +1 -2
- package/js/ceta/message.css +6 -2
- package/js/ceta/message.js +6 -2
- package/js/clock.js +1 -2
- package/js/kslink.js +38 -2
- package/js/newyear.js +76 -2
- package/js/plane.js +2200 -2
- package/js/plugins/aplayer.js +186 -2
- package/js/plugins/parallax.js +191 -2
- package/js/plugins/rightMenus.js +623 -2
- package/js/plugins/tags/contributors.js +92 -2
- package/js/plugins/tags/friends.js +93 -2
- package/js/plugins/tags/sites.js +96 -2
- package/js/search/algolia.js +239 -2
- package/js/search/hexo.js +195 -2
- package/js/search/meilisearch.js +220 -2
- package/js/txmap.js +248 -2
- package/link/index.html +6180 -1
- package/load.html +294 -1
- package/music/index.html +4033 -1
- package/package.json +1 -1
- package/page/2/index.html +4578 -1
- package/page/3/index.html +4575 -1
- package/page/4/index.html +4572 -1
- package/page/5/index.html +3924 -1
- package/posts/10021/index.html +4130 -5
- package/posts/10045/index.html +4224 -1
- package/posts/10733/index.html +4125 -1
- package/posts/10996/index.html +4127 -5
- package/posts/12779/index.html +4134 -1
- package/posts/13624/index.html +4179 -1
- package/posts/15688/index.html +4133 -1
- package/posts/15748/index.html +4121 -5
- package/posts/15799/index.html +4130 -1
- package/posts/15842/index.html +4121 -5
- package/posts/16107/index.html +4111 -1
- package/posts/18063/index.html +4124 -1
- package/posts/20412/index.html +4134 -1
- package/posts/21375/index.html +4124 -1
- package/posts/22945/index.html +4169 -4
- package/posts/23021/index.html +4104 -1
- package/posts/27531/index.html +4121 -5
- package/posts/28536/index.html +4116 -1
- package/posts/28733/index.html +4168 -1
- package/posts/29196/index.html +4106 -1
- package/posts/38917/index.html +4144 -1
- package/posts/38964/index.html +4208 -1
- package/posts/42487/index.html +4135 -1
- package/posts/42580/index.html +4128 -1
- package/posts/45875/index.html +4118 -1
- package/posts/46640/index.html +4147 -1
- package/posts/48762/index.html +4109 -1
- package/posts/50710/index.html +4114 -1
- package/posts/52677/index.html +4125 -1
- package/posts/53662/index.html +4123 -1
- package/posts/54386/index.html +4116 -1
- package/posts/54481/index.html +4133 -1
- package/posts/54787/index.html +4124 -5
- package/posts/56467/index.html +4121 -1
- package/posts/57692/index.html +4143 -1
- package/posts/58203/index.html +4116 -1
- package/posts/61417/index.html +4117 -1
- package/posts/61712/index.html +4113 -1
- package/posts/646/index.html +4106 -1
- package/posts/64856/index.html +4120 -1
- package/posts/64935/index.html +4120 -1
- package/search.xml +78 -78
- package/seas/index.html +4050 -1
- package/sw.js +798 -2
- package/tags/Flash/347/233/270/345/205/263/index.html +3924 -1
- package/tags/Steam/346/270/270/346/210/217/index.html +3924 -1
- package/tags/Windows/350/275/257/344/273/266/index.html +3997 -1
- package/tags/index.html +4033 -1
- package/tags//344/270/252/344/272/272/345/260/217/350/256/260/index.html +4570 -1
- package/tags//344/270/252/344/272/272/345/260/217/350/256/260/page/2/index.html +4485 -1
- package/tags//345/205/266/345/256/203/346/270/270/346/210/217/index.html +4073 -1
- package/tags//345/212/240/350/275/275/345/212/250/347/224/273/index.html +3924 -1
- package/tags//346/202/254/346/265/256/345/256/240/347/211/251-/347/234/213/346/235/277/345/250/230/index.html +3925 -1
- package/tags//346/255/214/346/233/262/346/224/266/351/233/206/index.html +3920 -1
- package/tags//346/270/270/346/210/217/347/233/270/345/205/263/index.html +4148 -1
- package/tags//347/253/231/347/202/271/345/272/225/351/203/250/351/255/224/346/224/271/index.html +3924 -1
- package/tags//347/253/231/347/202/271/346/212/230/350/205/276/index.html +4610 -1
- package/tags//347/253/231/347/202/271/346/212/230/350/205/276/page/2/index.html +4148 -1
- package/tags//350/207/252/345/273/272/351/203/250/347/275/262/index.html +4224 -1
- package/tags//351/241/265/351/235/242/351/255/224/346/224/271/index.html +4075 -1
- package/tags//351/241/271/347/233/256/346/212/230/350/205/276/index.html +4072 -1
- package/update/index.html +4112 -1
- package/weichuncai/css/style.css +25 -2
- package/weichuncai/js/common.js +449 -2
- package/weichuncai/js/jquery.js +139 -2
- package/weichuncai/wcc-config.js +17 -2
- package/maps/assets/algolia/algoliasearch.js.map +0 -1
- package/maps/assets/algolia/algoliasearchLite.js.map +0 -1
- package/maps/bbs/bbs.js.map +0 -1
- package/maps/css/custom2.css.map +0 -1
- package/maps/css/first.css.map +0 -1
- package/maps/css/pace/big-counter.css.map +0 -1
- package/maps/css/pace/corner-indicator.css.map +0 -1
- package/maps/css/pace/flash.css.map +0 -1
- package/maps/css/pace/mac-osx.css.map +0 -1
- package/maps/css/pace/pace.css.map +0 -1
- package/maps/css/plane.css.map +0 -1
- package/maps/css/style.css.map +0 -1
- package/maps/css/tags.css.map +0 -1
- package/maps/js/app.js.map +0 -1
- package/maps/js/autoload.js.map +0 -1
- package/maps/js/ceta/fancybox.css.map +0 -1
- package/maps/js/ceta/fancybox.umd.js.map +0 -1
- package/maps/js/ceta/iconfontInkss.js.map +0 -1
- package/maps/js/ceta/message.css.map +0 -1
- package/maps/js/ceta/message.js.map +0 -1
- package/maps/js/clock.js.map +0 -1
- package/maps/js/kslink.js.map +0 -1
- package/maps/js/newyear.js.map +0 -1
- package/maps/js/plane.js.map +0 -1
- package/maps/js/plugins/aplayer.js.map +0 -1
- package/maps/js/plugins/parallax.js.map +0 -1
- package/maps/js/plugins/rightMenus.js.map +0 -1
- package/maps/js/plugins/tags/contributors.js.map +0 -1
- package/maps/js/plugins/tags/friends.js.map +0 -1
- package/maps/js/plugins/tags/sites.js.map +0 -1
- package/maps/js/search/algolia.js.map +0 -1
- package/maps/js/search/hexo.js.map +0 -1
- package/maps/js/search/meilisearch.js.map +0 -1
- package/maps/js/txmap.js.map +0 -1
- package/maps/sw.js.map +0 -1
- package/maps/weichuncai/css/style.css.map +0 -1
- package/maps/weichuncai/js/common.js.map +0 -1
- package/maps/weichuncai/js/jquery.js.map +0 -1
- package/maps/weichuncai/wcc-config.js.map +0 -1
@@ -1,2 +1,92 @@
|
|
1
|
-
const ContributorsJS
|
2
|
-
|
1
|
+
const ContributorsJS = {
|
2
|
+
requestAPI: (url, callback, timeout) => {
|
3
|
+
let retryTimes = 5;
|
4
|
+
|
5
|
+
function request() {
|
6
|
+
return new Promise((resolve, reject) => {
|
7
|
+
let status = 0; // 0 等待 1 完成 2 超时
|
8
|
+
let timer = setTimeout(() => {
|
9
|
+
if (status === 0) {
|
10
|
+
status = 2;
|
11
|
+
timer = null;
|
12
|
+
reject('请求超时');
|
13
|
+
if (retryTimes == 0) {
|
14
|
+
timeout();
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}, 5000);
|
18
|
+
fetch(url).then(function (response) {
|
19
|
+
if (status !== 2) {
|
20
|
+
clearTimeout(timer);
|
21
|
+
resolve(response);
|
22
|
+
timer = null;
|
23
|
+
status = 1;
|
24
|
+
}
|
25
|
+
if (response.ok) {
|
26
|
+
return response.json();
|
27
|
+
}
|
28
|
+
throw new Error('Network response was not ok.');
|
29
|
+
}).then(function (data) {
|
30
|
+
retryTimes = 0;
|
31
|
+
callback(data);
|
32
|
+
}).catch(function (error) {
|
33
|
+
if (retryTimes > 0) {
|
34
|
+
retryTimes -= 1;
|
35
|
+
setTimeout(() => {
|
36
|
+
request();
|
37
|
+
}, 5000);
|
38
|
+
} else {
|
39
|
+
timeout();
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
}
|
44
|
+
request();
|
45
|
+
},
|
46
|
+
layout: (cfg) => {
|
47
|
+
const el = cfg.el;
|
48
|
+
ContributorsJS.requestAPI(cfg.api, function (data) {
|
49
|
+
el.querySelector('.loading-wrap').remove();
|
50
|
+
var cellALL = "";
|
51
|
+
(data || []).forEach((item, i) => {
|
52
|
+
var user = '<div class="user-card">';
|
53
|
+
user += '<a class="card-link" target="_blank" rel="external noopener noreferrer"';
|
54
|
+
user += ' href="' + item.html_url + '">';
|
55
|
+
user += '<img alt="' + item.login + '" src="' + (item.avatar_url || cfg.avatar) + '" onerror="errorImgAvatar(this)">';
|
56
|
+
user += '<div class="name"><span>' + item.login + '</span></div>';
|
57
|
+
user += '</a>';
|
58
|
+
user += '</div>';
|
59
|
+
cellALL += user;
|
60
|
+
});
|
61
|
+
el.querySelector('.group-body').innerHTML = cellALL;
|
62
|
+
}, function () {
|
63
|
+
try {
|
64
|
+
el.querySelector('.loading-wrap svg').remove();
|
65
|
+
el.querySelector('.loading-wrap p').innerText('加载失败,请稍后重试。');
|
66
|
+
} catch (e) { }
|
67
|
+
});
|
68
|
+
},
|
69
|
+
start: () => {
|
70
|
+
const els = document.getElementsByClassName('contributorsjs-wrap');
|
71
|
+
for (var i = 0; i < els.length; i++) {
|
72
|
+
const el = els[i];
|
73
|
+
const api = el.getAttribute('api');
|
74
|
+
if (api == null) {
|
75
|
+
continue;
|
76
|
+
}
|
77
|
+
var cfg = new Object();
|
78
|
+
cfg.el = el;
|
79
|
+
cfg.api = api;
|
80
|
+
cfg.class = el.getAttribute('class');
|
81
|
+
cfg.avatar = volantis.GLOBAL_CONFIG.default.avatar;
|
82
|
+
ContributorsJS.layout(cfg);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
ContributorsJS.start();
|
90
|
+
document.addEventListener('pjax:complete', function () {
|
91
|
+
ContributorsJS.start();
|
92
|
+
});
|
@@ -1,2 +1,93 @@
|
|
1
|
-
const FriendsJS
|
2
|
-
|
1
|
+
const FriendsJS = {
|
2
|
+
requestAPI: (url, callback, timeout) => {
|
3
|
+
let retryTimes = 5;
|
4
|
+
|
5
|
+
function request() {
|
6
|
+
return new Promise((resolve, reject) => {
|
7
|
+
let status = 0; // 0 等待 1 完成 2 超时
|
8
|
+
let timer = setTimeout(() => {
|
9
|
+
if (status === 0) {
|
10
|
+
status = 2;
|
11
|
+
timer = null;
|
12
|
+
reject('请求超时');
|
13
|
+
if (retryTimes == 0) {
|
14
|
+
timeout();
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}, 5000);
|
18
|
+
fetch(url).then(function (response) {
|
19
|
+
if (status !== 2) {
|
20
|
+
clearTimeout(timer);
|
21
|
+
resolve(response);
|
22
|
+
timer = null;
|
23
|
+
status = 1;
|
24
|
+
}
|
25
|
+
if (response.ok) {
|
26
|
+
return response.json();
|
27
|
+
}
|
28
|
+
throw new Error('Network response was not ok.');
|
29
|
+
}).then(function (data) {
|
30
|
+
retryTimes = 0;
|
31
|
+
callback(data);
|
32
|
+
}).catch(function (error) {
|
33
|
+
if (retryTimes > 0) {
|
34
|
+
retryTimes -= 1;
|
35
|
+
setTimeout(() => {
|
36
|
+
request();
|
37
|
+
}, 5000);
|
38
|
+
} else {
|
39
|
+
timeout();
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
}
|
44
|
+
request();
|
45
|
+
},
|
46
|
+
layout: (cfg) => {
|
47
|
+
const el = cfg.el;
|
48
|
+
FriendsJS.requestAPI(cfg.api, function (data) {
|
49
|
+
el.querySelector('.loading-wrap').remove();
|
50
|
+
const arr = data.content;
|
51
|
+
var cellALL = "";
|
52
|
+
arr.forEach((item, i) => {
|
53
|
+
var user = '<div class="user-card">';
|
54
|
+
user += '<a class="card-link" target="_blank" rel="external noopener noreferrer"';
|
55
|
+
user += ' href="' + item.url + '">';
|
56
|
+
user += '<img alt="' + item.title + '" src="' + (item.avatar || cfg.avatar) + '" onerror="errorImgAvatar(this)">';
|
57
|
+
user += '<div class="name"><span>' + item.title + '</span></div>';
|
58
|
+
user += '</a>';
|
59
|
+
user += '</div>';
|
60
|
+
cellALL += user;
|
61
|
+
});
|
62
|
+
el.querySelector('.group-body').innerHTML = cellALL;
|
63
|
+
}, function () {
|
64
|
+
try {
|
65
|
+
el.querySelector('.loading-wrap svg').remove();
|
66
|
+
el.querySelector('.loading-wrap p').innerText('加载失败,请稍后重试。');
|
67
|
+
} catch (e) { }
|
68
|
+
});
|
69
|
+
},
|
70
|
+
start: () => {
|
71
|
+
const els = document.getElementsByClassName('friendsjs-wrap');
|
72
|
+
for (var i = 0; i < els.length; i++) {
|
73
|
+
const el = els[i];
|
74
|
+
const api = el.getAttribute('api');
|
75
|
+
if (api == null) {
|
76
|
+
continue;
|
77
|
+
}
|
78
|
+
var cfg = new Object();
|
79
|
+
cfg.el = el;
|
80
|
+
cfg.api = api;
|
81
|
+
cfg.class = el.getAttribute('class');
|
82
|
+
cfg.avatar = volantis.GLOBAL_CONFIG.default.avatar;
|
83
|
+
FriendsJS.layout(cfg);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
FriendsJS.start();
|
91
|
+
document.addEventListener('pjax:complete', function () {
|
92
|
+
FriendsJS.start();
|
93
|
+
});
|
package/js/plugins/tags/sites.js
CHANGED
@@ -1,2 +1,96 @@
|
|
1
|
-
const SitesJS
|
2
|
-
|
1
|
+
const SitesJS = {
|
2
|
+
requestAPI: (url, callback, timeout) => {
|
3
|
+
let retryTimes = 5;
|
4
|
+
|
5
|
+
function request() {
|
6
|
+
return new Promise((resolve, reject) => {
|
7
|
+
let status = 0; // 0 等待 1 完成 2 超时
|
8
|
+
let timer = setTimeout(() => {
|
9
|
+
if (status === 0) {
|
10
|
+
status = 2;
|
11
|
+
timer = null;
|
12
|
+
reject('请求超时');
|
13
|
+
if (retryTimes == 0) {
|
14
|
+
timeout();
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}, 5000);
|
18
|
+
fetch(url).then(function (response) {
|
19
|
+
if (status !== 2) {
|
20
|
+
clearTimeout(timer);
|
21
|
+
resolve(response);
|
22
|
+
timer = null;
|
23
|
+
status = 1;
|
24
|
+
}
|
25
|
+
if (response.ok) {
|
26
|
+
return response.json();
|
27
|
+
}
|
28
|
+
throw new Error('Network response was not ok.');
|
29
|
+
}).then(function (data) {
|
30
|
+
retryTimes = 0;
|
31
|
+
callback(data);
|
32
|
+
}).catch(function (error) {
|
33
|
+
if (retryTimes > 0) {
|
34
|
+
retryTimes -= 1;
|
35
|
+
setTimeout(() => {
|
36
|
+
request();
|
37
|
+
}, 5000);
|
38
|
+
} else {
|
39
|
+
timeout();
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
}
|
44
|
+
request();
|
45
|
+
},
|
46
|
+
layout: (cfg) => {
|
47
|
+
const el = cfg.el;
|
48
|
+
SitesJS.requestAPI(cfg.api, function (data) {
|
49
|
+
el.querySelector('.loading-wrap').remove();
|
50
|
+
const arr = data.content;
|
51
|
+
var cellALL = "";
|
52
|
+
arr.forEach((item, i) => {
|
53
|
+
var cell = '<div class="site-card">';
|
54
|
+
cell += '<a class="card-link" target="_blank" rel="external noopener noreferrer" href="' + item.url + '">';
|
55
|
+
cell += '<img alt="' + item.title + '" src="' + (item.screenshot || ('https://image.thum.io/get/width/1024/crop/768/' + item.url)) + '" onerror="errorImgCover(this)"/>';
|
56
|
+
cell += '<div class="info">';
|
57
|
+
cell += '<img alt="' + item.title + '" src="' + (item.avatar || cfg.avatar) + '" onerror="errorImgAvatar(this)"/>';
|
58
|
+
cell += '<span class="title">' + item.title + '</span>';
|
59
|
+
cell += '<span class="desc">' + (item.description || item.url) + '</span>';
|
60
|
+
cell += '</div>';
|
61
|
+
cell += '</a>';
|
62
|
+
cell += '</div>';
|
63
|
+
cellALL += cell;
|
64
|
+
});
|
65
|
+
el.querySelector('.group-body').innerHTML = cellALL;
|
66
|
+
}, function () {
|
67
|
+
try {
|
68
|
+
el.querySelector('.loading-wrap svg').remove();
|
69
|
+
el.querySelector('.loading-wrap p').innerText('加载失败,请稍后重试。');
|
70
|
+
} catch (e) { }
|
71
|
+
});
|
72
|
+
},
|
73
|
+
start: (cfg) => {
|
74
|
+
const els = document.getElementsByClassName('sitesjs-wrap');
|
75
|
+
for (var i = 0; i < els.length; i++) {
|
76
|
+
const el = els[i];
|
77
|
+
const api = el.getAttribute('api');
|
78
|
+
if (api == null) {
|
79
|
+
continue;
|
80
|
+
}
|
81
|
+
var cfg = new Object();
|
82
|
+
cfg.class = el.getAttribute('class');
|
83
|
+
cfg.el = el;
|
84
|
+
cfg.api = api;
|
85
|
+
cfg.avatar = volantis.GLOBAL_CONFIG.default.link;
|
86
|
+
cfg.screenshot = volantis.GLOBAL_CONFIG.default.cover;
|
87
|
+
SitesJS.layout(cfg);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
SitesJS.start();
|
94
|
+
document.addEventListener('pjax:complete', function () {
|
95
|
+
SitesJS.start();
|
96
|
+
});
|
package/js/search/algolia.js
CHANGED
@@ -1,2 +1,239 @@
|
|
1
|
-
let SearchService
|
2
|
-
|
1
|
+
let SearchService = (() => {
|
2
|
+
const fn = {};
|
3
|
+
let search, algolia, timerId;
|
4
|
+
fn.queryText = null;
|
5
|
+
fn.template = `<div id="u-search">
|
6
|
+
<div class="modal">
|
7
|
+
<header class="modal-header" class="clearfix">
|
8
|
+
<button type="submit" id="u-search-modal-btn-submit" class="u-search-btn-submit">
|
9
|
+
<span class="fa-solid fa-search"></span>
|
10
|
+
</button>
|
11
|
+
<div id="algolia-search-input"></div>
|
12
|
+
<a id="u-search-btn-close" class="btn-close"> <span class="fa-solid fa-times"></span> </a>
|
13
|
+
</header>
|
14
|
+
<main class="modal-body">
|
15
|
+
<div id="algolia-search-results">
|
16
|
+
<div id="algolia-hits">
|
17
|
+
<div class="search-icon"><i class="fa-sharp fa-solid fa-telescope"></i></i></div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</main>
|
21
|
+
<footer>
|
22
|
+
<div id="algolia-pagination"></div>
|
23
|
+
<hr>
|
24
|
+
<div id="algolia-info">
|
25
|
+
<div class="algolia-stats"></div>
|
26
|
+
<div class="algolia-poweredBy"></div>
|
27
|
+
</div>
|
28
|
+
</footer>
|
29
|
+
</div>
|
30
|
+
<div id="modal-overlay" class="modal-overlay"></div>
|
31
|
+
</div>
|
32
|
+
`;
|
33
|
+
|
34
|
+
fn.init = () => {
|
35
|
+
let div = document.createElement("div");
|
36
|
+
div.innerHTML += fn.template;
|
37
|
+
document.body.append(div);
|
38
|
+
|
39
|
+
algolia = volantis.GLOBAL_CONFIG.search;
|
40
|
+
if (algolia.appId && algolia.apiKey && algolia.indexName) {
|
41
|
+
fn.event();
|
42
|
+
fn.setAlgolia();
|
43
|
+
} else {
|
44
|
+
document.querySelector('#u-search main.modal-body').innerHTML = 'Algolia setting is invalid!';
|
45
|
+
document.querySelector('#u-search main.modal-body').style.textAlign = 'center';
|
46
|
+
document.querySelector('#u-search .modal').style.maxHeight = '128px';
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
fn.event = () => {
|
51
|
+
document
|
52
|
+
.querySelector("#u-search-btn-close")
|
53
|
+
.addEventListener("click", fn.close, false);
|
54
|
+
document
|
55
|
+
.querySelector("#modal-overlay")
|
56
|
+
.addEventListener("click", fn.close, false);
|
57
|
+
document.querySelectorAll(".u-search-form").forEach((e) => {
|
58
|
+
e.addEventListener("submit", fn.onSubmit, false);
|
59
|
+
});
|
60
|
+
document.querySelector("#algolia-search-input").addEventListener("input", event => {
|
61
|
+
let input = event.target.querySelector(".ais-SearchBox-input");
|
62
|
+
if (input) {
|
63
|
+
fn.queryText = input.value;
|
64
|
+
} else {
|
65
|
+
fn.queryText = event.target.value;
|
66
|
+
}
|
67
|
+
})
|
68
|
+
}
|
69
|
+
|
70
|
+
fn.setAlgolia = () => {
|
71
|
+
search = instantsearch({
|
72
|
+
indexName: algolia.indexName,
|
73
|
+
searchClient: algoliasearch(algolia.appId, algolia.apiKey),
|
74
|
+
searchFunction(helper) {
|
75
|
+
helper.state.query && helper.search()
|
76
|
+
},
|
77
|
+
})
|
78
|
+
|
79
|
+
const configure = instantsearch.widgets.configure({
|
80
|
+
hitsPerPage: algolia.hitsPerPage
|
81
|
+
})
|
82
|
+
|
83
|
+
const searchBox = instantsearch.widgets.searchBox({
|
84
|
+
container: '#algolia-search-input',
|
85
|
+
autofocus: true,
|
86
|
+
showReset: false,
|
87
|
+
showSubmit: false,
|
88
|
+
showLoadingIndicator: false,
|
89
|
+
searchAsYouType: algolia.searchAsYouType,
|
90
|
+
placeholder: algolia.placeholder,
|
91
|
+
templates: {
|
92
|
+
input: 'algolia-input'
|
93
|
+
},
|
94
|
+
queryHook(query, refine) {
|
95
|
+
clearTimeout(timerId)
|
96
|
+
timerId = setTimeout(() => refine(query), 500)
|
97
|
+
}
|
98
|
+
})
|
99
|
+
|
100
|
+
const hits = instantsearch.widgets.hits({
|
101
|
+
container: '#algolia-hits',
|
102
|
+
templates: {
|
103
|
+
item(data) {
|
104
|
+
const keyword = !!fn.queryText ? `?keyword=${fn.queryText}` : ''
|
105
|
+
const link = data.permalink ? data.permalink : `${volantis.GLOBAL_CONFIG.root}${data.path}`
|
106
|
+
const result = data._highlightResult
|
107
|
+
const content = result.contentStripTruncate
|
108
|
+
? fn.cutContent(result.contentStripTruncate.value)
|
109
|
+
: result.contentStrip
|
110
|
+
? fn.cutContent(result.contentStrip.value)
|
111
|
+
: result.content
|
112
|
+
? fn.cutContent(result.content.value)
|
113
|
+
: ''
|
114
|
+
return `
|
115
|
+
<a href="${link}${keyword}" class="result">
|
116
|
+
<span class="title">${result.title.value || 'no-title'}</span>
|
117
|
+
<span class="digest">${content}</span>
|
118
|
+
</a>`
|
119
|
+
},
|
120
|
+
empty: function (data) {
|
121
|
+
return (
|
122
|
+
`<div id="resule-hits-empty"><i class="fa-solid fa-box-open"></i><p>${volantis.GLOBAL_CONFIG.languages.search.hits_empty.replace(/\$\{query}/, data.query)}</p></div>`
|
123
|
+
)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
})
|
127
|
+
|
128
|
+
const stats = instantsearch.widgets.stats({
|
129
|
+
container: '#algolia-info > .algolia-stats',
|
130
|
+
templates: {
|
131
|
+
text: function (data) {
|
132
|
+
const stats = volantis.GLOBAL_CONFIG.languages.search.hits_stats
|
133
|
+
.replace(/\$\{hits}/, data.nbHits)
|
134
|
+
.replace(/\$\{time}/, data.processingTimeMS)
|
135
|
+
return (
|
136
|
+
`${stats}`
|
137
|
+
)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
})
|
141
|
+
|
142
|
+
const powerBy = instantsearch.widgets.poweredBy({
|
143
|
+
container: '#algolia-info > .algolia-poweredBy',
|
144
|
+
theme: volantis.dark?.mode === 'dark' ? 'dark' : 'light'
|
145
|
+
})
|
146
|
+
|
147
|
+
const pagination = instantsearch.widgets.pagination({
|
148
|
+
container: '#algolia-pagination',
|
149
|
+
totalPages: 5,
|
150
|
+
templates: {
|
151
|
+
first: '<i class="fas fa-angle-double-left"></i>',
|
152
|
+
last: '<i class="fas fa-angle-double-right"></i>',
|
153
|
+
previous: '<i class="fas fa-angle-left"></i>',
|
154
|
+
next: '<i class="fas fa-angle-right"></i>'
|
155
|
+
}
|
156
|
+
})
|
157
|
+
|
158
|
+
search.addWidgets([configure, searchBox, hits, stats, powerBy, pagination])
|
159
|
+
|
160
|
+
search.start()
|
161
|
+
|
162
|
+
window.pjax && search.on('render', () => {
|
163
|
+
window.pjax.refresh(document.getElementById('algolia-hits'))
|
164
|
+
})
|
165
|
+
}
|
166
|
+
|
167
|
+
fn.setQueryText = queryText => {
|
168
|
+
fn.queryText = queryText;
|
169
|
+
if (!search) {
|
170
|
+
fn.init()
|
171
|
+
}
|
172
|
+
search?.setUiState({
|
173
|
+
[algolia.indexName]: {
|
174
|
+
query: queryText
|
175
|
+
}
|
176
|
+
})
|
177
|
+
}
|
178
|
+
|
179
|
+
fn.search = () => {
|
180
|
+
document.querySelector("#u-search").style.display = "block";
|
181
|
+
document.addEventListener("keydown", event => {
|
182
|
+
if (event.code === "Escape") {
|
183
|
+
fn.close();
|
184
|
+
}
|
185
|
+
}, { once: true })
|
186
|
+
}
|
187
|
+
|
188
|
+
fn.onSubmit = (event) => {
|
189
|
+
event.preventDefault();
|
190
|
+
let input = event.target.querySelector(".u-search-input");
|
191
|
+
fn.setQueryText(input?.value ? input.value : event.target.value)
|
192
|
+
fn.search();
|
193
|
+
};
|
194
|
+
|
195
|
+
fn.cutContent = content => {
|
196
|
+
if (content === '') return ''
|
197
|
+
|
198
|
+
const firstOccur = content.indexOf('<mark>')
|
199
|
+
|
200
|
+
let start = firstOccur - 30
|
201
|
+
let end = firstOccur + 120
|
202
|
+
let pre = ''
|
203
|
+
let post = ''
|
204
|
+
|
205
|
+
if (start <= 0) {
|
206
|
+
start = 0
|
207
|
+
end = 140
|
208
|
+
} else {
|
209
|
+
pre = '...'
|
210
|
+
}
|
211
|
+
|
212
|
+
if (end > content.length) {
|
213
|
+
end = content.length
|
214
|
+
} else {
|
215
|
+
post = '...'
|
216
|
+
}
|
217
|
+
|
218
|
+
let matchContent = pre + content.substring(start, end) + post
|
219
|
+
return matchContent
|
220
|
+
}
|
221
|
+
|
222
|
+
fn.close = () => {
|
223
|
+
document.querySelector("#u-search").style.display = "none";
|
224
|
+
};
|
225
|
+
|
226
|
+
return {
|
227
|
+
init: fn.init,
|
228
|
+
setQueryText: queryText => {
|
229
|
+
fn.setQueryText(queryText);
|
230
|
+
},
|
231
|
+
search: fn.search,
|
232
|
+
close: fn.close
|
233
|
+
}
|
234
|
+
})()
|
235
|
+
|
236
|
+
Object.freeze(SearchService);
|
237
|
+
|
238
|
+
SearchService.init();
|
239
|
+
document.addEventListener("pjax:send", SearchService.close);
|