sinzmise-cetastories-en 2.0.0-1731064227934 → 2.0.0-1731114112886
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/archives/2023/12/index.html +3882 -1
- package/archives/2023/index.html +3882 -1
- package/archives/index.html +3847 -1
- package/assets/algolia/algoliasearch.js +7182 -3
- package/assets/algolia/algoliasearchLite.js +4445 -3
- package/atom.xml +2 -2
- package/baidu_verify_codeva-NA6uDlCuZg.html +3960 -1
- package/categories/Test/index.html +3885 -1
- package/categories/index.html +4014 -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 +8570 -2
- package/css/tags.css +3516 -2
- package/games +57 -15
- package/google8073542809160a67.html +3960 -1
- package/index.html +3926 -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/load.html +294 -1
- package/package.json +1 -1
- package/posts/46521/index.html +4049 -1
- package/sw.js +798 -2
- package/tags/Test/index.html +3885 -1
- package/tags/index.html +3997 -1
- package/maps/assets/algolia/algoliasearch.js.map +0 -1
- package/maps/assets/algolia/algoliasearchLite.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
@@ -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);
|