sinzmise-cetastories 2.0.0-1731064238567 → 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 +84 -84
- 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
package/js/search/hexo.js
CHANGED
@@ -1,2 +1,195 @@
|
|
1
|
-
let SearchService
|
2
|
-
|
1
|
+
let SearchService = (() => {
|
2
|
+
const fn = {};
|
3
|
+
fn.queryText = null;
|
4
|
+
fn.data = null;
|
5
|
+
fn.template = `<div id="u-search">
|
6
|
+
<div class="modal">
|
7
|
+
<header class="modal-header" class="clearfix">
|
8
|
+
<form id="u-search-modal-form" class="u-search-form" name="uSearchModalForm">
|
9
|
+
<input type="text" id="u-search-modal-input" class="u-search-input" />
|
10
|
+
<button type="submit" id="u-search-modal-btn-submit" class="u-search-btn-submit">
|
11
|
+
<span class="fa-solid fa-search"></span>
|
12
|
+
</button>
|
13
|
+
</form>
|
14
|
+
<a id="u-search-btn-close" class="btn-close"> <span class="fa-solid fa-times"></span> </a>
|
15
|
+
</header>
|
16
|
+
<main class="modal-body">
|
17
|
+
<ul class="modal-results"></ul>
|
18
|
+
</main>
|
19
|
+
</div>
|
20
|
+
<div id="modal-overlay" class="modal-overlay"></div>
|
21
|
+
</div>
|
22
|
+
`;
|
23
|
+
fn.init = () => {
|
24
|
+
let div = document.createElement("div");
|
25
|
+
div.innerHTML += fn.template;
|
26
|
+
document.body.append(div);
|
27
|
+
document.querySelectorAll(".u-search-form").forEach((e) => {
|
28
|
+
e.addEventListener("submit", fn.onSubmit, false);
|
29
|
+
});
|
30
|
+
let uSearchModalInput = document.querySelector("#u-search-modal-input");
|
31
|
+
uSearchModalInput.addEventListener("input", fn.onSubmit);
|
32
|
+
document
|
33
|
+
.querySelector("#u-search-btn-close")
|
34
|
+
.addEventListener("click", fn.close, false);
|
35
|
+
document
|
36
|
+
.querySelector("#modal-overlay")
|
37
|
+
.addEventListener("click", fn.close, false);
|
38
|
+
};
|
39
|
+
fn.onSubmit = (event) => {
|
40
|
+
event.preventDefault();
|
41
|
+
let input = event.target.querySelector(".u-search-input");
|
42
|
+
if (input) {
|
43
|
+
fn.queryText = input.value;
|
44
|
+
} else {
|
45
|
+
fn.queryText = event.target.value;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (fn.queryText) {
|
49
|
+
fn.search();
|
50
|
+
}
|
51
|
+
};
|
52
|
+
fn.search = async () => {
|
53
|
+
document.querySelectorAll(".u-search-input").forEach((e) => {
|
54
|
+
e.value = fn.queryText;
|
55
|
+
});
|
56
|
+
document.querySelector("#u-search").style.display = "block";
|
57
|
+
if (!fn.data) {
|
58
|
+
fn.data = await fn.fetchData();
|
59
|
+
}
|
60
|
+
let results = "";
|
61
|
+
results += fn.buildResultList(fn.data.pages);
|
62
|
+
results += fn.buildResultList(fn.data.posts);
|
63
|
+
if (results === "") {
|
64
|
+
results = `<div id="resule-hits-empty"><i class="fa-solid fa-box-open"></i><p>${volantis.GLOBAL_CONFIG.languages.search.hits_empty.replace(/\$\{query}/, fn.queryText)}</p></div>`
|
65
|
+
}
|
66
|
+
document.querySelector("#u-search .modal-results").innerHTML = results;
|
67
|
+
window.pjax && pjax.refresh(document.querySelector("#u-search"));
|
68
|
+
document.addEventListener("keydown", function f(event) {
|
69
|
+
if (event.code === "Escape") {
|
70
|
+
fn.close();
|
71
|
+
document.removeEventListener("keydown", f);
|
72
|
+
}
|
73
|
+
});
|
74
|
+
};
|
75
|
+
fn.close = () => {
|
76
|
+
document.querySelector("#u-search").style.display = "none";
|
77
|
+
};
|
78
|
+
fn.fetchData = () => {
|
79
|
+
return fetch(volantis.GLOBAL_CONFIG.search.dataPath)
|
80
|
+
.then((response) => response.text())
|
81
|
+
.then((res) => {
|
82
|
+
const data = JSON.parse(res);
|
83
|
+
// console.log(data);
|
84
|
+
return data;
|
85
|
+
});
|
86
|
+
};
|
87
|
+
fn.buildResultList = (data) => {
|
88
|
+
let html = "";
|
89
|
+
data.forEach((post) => {
|
90
|
+
if (post.text) {
|
91
|
+
post.text = post.text.replace(/12345\d*/g, "") // 简易移除代码行号
|
92
|
+
}
|
93
|
+
if (!post.title && post.text) {
|
94
|
+
post.title = post.text.trim().slice(0, 15)
|
95
|
+
}
|
96
|
+
if (fn.contentSearch(post)) {
|
97
|
+
html += fn.buildResult(post.permalink, post.title, post.digest);
|
98
|
+
}
|
99
|
+
});
|
100
|
+
return html;
|
101
|
+
};
|
102
|
+
fn.contentSearch = (post) => {
|
103
|
+
let post_title = post.title.trim().toLowerCase();
|
104
|
+
let post_content = post.text.trim().toLowerCase();
|
105
|
+
let keywords = fn.queryText
|
106
|
+
.trim()
|
107
|
+
.toLowerCase()
|
108
|
+
.split(/[-\s]+/);
|
109
|
+
let foundMatch = false;
|
110
|
+
let index_title = -1;
|
111
|
+
let index_content = -1;
|
112
|
+
let first_occur = -1;
|
113
|
+
if (post_title && post_content) {
|
114
|
+
keywords.forEach((word, index) => {
|
115
|
+
index_title = post_title.indexOf(word);
|
116
|
+
index_content = post_content.indexOf(word);
|
117
|
+
if (index_title < 0 && index_content < 0) {
|
118
|
+
foundMatch = false;
|
119
|
+
} else {
|
120
|
+
foundMatch = true;
|
121
|
+
if (index_content < 0) {
|
122
|
+
index_content = 0;
|
123
|
+
}
|
124
|
+
if (index === 0) {
|
125
|
+
first_occur = index_content;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (foundMatch) {
|
129
|
+
post_content = post.text.trim();
|
130
|
+
let start = 0;
|
131
|
+
let end = 0;
|
132
|
+
if (first_occur >= 0) {
|
133
|
+
start = Math.max(first_occur - 40, 0);
|
134
|
+
end =
|
135
|
+
start === 0
|
136
|
+
? Math.min(200, post_content.length)
|
137
|
+
: Math.min(first_occur + 120, post_content.length);
|
138
|
+
let match_content = post_content.substring(start, end);
|
139
|
+
keywords.forEach(function (keyword) {
|
140
|
+
let regS = new RegExp(keyword, "gi");
|
141
|
+
match_content = match_content.replace(
|
142
|
+
regS,
|
143
|
+
"<b mark>" + keyword + "</b>"
|
144
|
+
);
|
145
|
+
});
|
146
|
+
post.digest = match_content + "......";
|
147
|
+
} else {
|
148
|
+
end = Math.min(200, post_content.length);
|
149
|
+
post.digest = post_content.trim().substring(0, end);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
});
|
153
|
+
}
|
154
|
+
return foundMatch;
|
155
|
+
};
|
156
|
+
fn.buildResult = (url, title, digest) => {
|
157
|
+
let result = fn.getUrlRelativePath(url);
|
158
|
+
let html = "";
|
159
|
+
html += "<li>";
|
160
|
+
html +=
|
161
|
+
"<a class='result' href='" + result + "?keyword=" + fn.queryText + "'>";
|
162
|
+
html += "<span class='title'>" + title + "</span>";
|
163
|
+
if (digest !== "") html += "<span class='digest'>" + digest + "</span>";
|
164
|
+
html += "</a>";
|
165
|
+
html += "</li>";
|
166
|
+
return html;
|
167
|
+
};
|
168
|
+
fn.getUrlRelativePath = function (url) {
|
169
|
+
let arrUrl = url.split("//");
|
170
|
+
let start = arrUrl[1].indexOf("/");
|
171
|
+
let relUrl = arrUrl[1].substring(start);
|
172
|
+
if (relUrl.indexOf("?") != -1) {
|
173
|
+
relUrl = relUrl.split("?")[0];
|
174
|
+
}
|
175
|
+
return relUrl;
|
176
|
+
};
|
177
|
+
return {
|
178
|
+
init: () => {
|
179
|
+
fn.init();
|
180
|
+
},
|
181
|
+
setQueryText: (queryText) => {
|
182
|
+
fn.queryText = queryText;
|
183
|
+
},
|
184
|
+
search: () => {
|
185
|
+
fn.search();
|
186
|
+
},
|
187
|
+
};
|
188
|
+
})();
|
189
|
+
Object.freeze(SearchService);
|
190
|
+
|
191
|
+
SearchService.init();
|
192
|
+
document.addEventListener("pjax:success", SearchService.init);
|
193
|
+
document.addEventListener("pjax:send", function () {
|
194
|
+
document.querySelector("#u-search").style.display = "none";
|
195
|
+
});
|
package/js/search/meilisearch.js
CHANGED
@@ -1,2 +1,220 @@
|
|
1
|
-
let SearchService
|
2
|
-
|
1
|
+
let SearchService = (() => {
|
2
|
+
const fn = {};
|
3
|
+
let search, meilisearch, 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="meilisearch-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="meilisearch-search-results">
|
16
|
+
<div id="meilisearch-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
|
+
<hr>
|
23
|
+
<div id="meilisearch-info">
|
24
|
+
<div class="meilisearch-stats"></div>
|
25
|
+
<div class="meilisearch-poweredBy">
|
26
|
+
<a href="https://www.meilisearch.com" titile="meilisearch" target="_blank">
|
27
|
+
<svg width="97" height="20" viewBox="0 0 537 83" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M49.8729 49.6398C49.8729 41.9727 53.5489 37.4565 60.5858 37.4565C67.2026 37.4565 69.4082 42.1827 69.4082 48.2744V80.9383H84.3222V46.5939C84.3222 33.7805 77.6004 24.643 64.3668 24.643C56.4897 24.643 50.9232 27.0586 46.0919 32.4151C42.941 27.5838 37.5846 24.643 30.1275 24.643C22.2504 24.643 16.7889 27.8989 14.2682 32.6251V25.9033H0.509521V80.9383H15.4236V49.3247C15.4236 41.9727 19.2046 37.4565 26.1365 37.4565C32.7532 37.4565 34.9588 42.1827 34.9588 48.2744V80.9383H49.8729V49.6398Z" fill="black"/><path d="M145.538 57.727C145.538 57.727 145.748 55.7314 145.748 53.3158C145.748 37.0363 134.72 24.643 118.441 24.643C102.161 24.643 90.8184 37.0363 90.8184 53.3158C90.8184 70.2253 102.266 82.1986 118.546 82.1986C131.254 82.1986 141.337 74.5315 144.593 63.3985H129.574C127.788 67.3896 123.482 69.3851 118.966 69.3851C111.509 69.3851 106.678 65.289 105.627 57.727H145.538ZM118.336 36.6162C125.268 36.6162 129.784 40.8174 130.834 47.014H105.837C107.098 40.7123 111.509 36.6162 118.336 36.6162Z" fill="black"/><path d="M147.947 38.7168H154.564V80.9383H169.478V25.9033H147.947V38.7168ZM162.021 18.7614C167.272 18.7614 171.054 15.0854 171.054 9.83396C171.054 4.58254 167.272 0.801514 162.021 0.801514C156.77 0.801514 152.989 4.58254 152.989 9.83396C152.989 15.0854 156.77 18.7614 162.021 18.7614Z" fill="black"/><path d="M200.361 68.1248C199.94 68.1248 199.31 68.2298 198.365 68.2298C195.004 68.2298 194.584 66.6544 194.584 64.3438V2.16688H179.67V65.394C179.67 76.317 183.871 81.1483 195.739 81.1483C197.735 81.1483 199.625 80.9382 200.361 80.8332V68.1248Z" fill="black"/><path d="M202.057 38.7168H208.674V80.9383H223.588V25.9033H202.057V38.7168ZM216.131 18.7614C221.383 18.7614 225.164 15.0854 225.164 9.83396C225.164 4.58254 221.383 0.801514 216.131 0.801514C210.88 0.801514 207.099 4.58254 207.099 9.83396C207.099 15.0854 210.88 18.7614 216.131 18.7614Z" fill="black"/><path d="M253.531 81.5175C268.025 81.5175 274.852 73.8504 274.852 65.7632C274.852 43.2871 241.768 55.7855 241.768 40.9765C241.768 36.1452 245.864 32.0491 254.161 32.0491C262.669 32.0491 266.66 36.6703 267.29 42.4469H274.747C274.117 35.1999 269.18 25.5373 254.371 25.5373C241.663 25.5373 234.521 33.0994 234.521 41.2916C234.521 63.2425 267.605 50.6391 267.605 65.9733C267.605 71.3297 262.564 75.0057 253.531 75.0057C244.289 75.0057 239.667 70.3845 239.142 63.5576H231.58C232.21 72.9051 238.092 81.5175 253.531 81.5175Z" fill="black"/><path d="M334.078 55.6805C334.078 55.6805 334.183 54 334.183 52.8447C334.183 37.7206 324.415 25.5373 308.451 25.5373C292.382 25.5373 282.194 38.6659 282.194 53.4749C282.194 68.4939 291.647 81.5175 308.556 81.5175C321.265 81.5175 330.087 73.7454 333.238 63.5576H325.466C323.155 70.0694 316.853 74.7956 308.661 74.7956C297.423 74.7956 290.386 66.4984 289.651 55.6805H334.078ZM308.451 32.2592C318.954 32.2592 325.781 39.2961 326.726 49.5888H289.861C291.121 39.7162 298.053 32.2592 308.451 32.2592Z" fill="black"/><path d="M380.477 54.8402V59.8816C380.477 69.0191 373.86 75.3208 361.152 75.3208C353.274 75.3208 348.968 72.0649 348.968 65.028C348.968 61.457 350.649 58.7263 353.274 57.2559C356.005 55.7855 359.681 54.8402 380.477 54.8402ZM360.311 81.5175C369.554 81.5175 377.011 78.5767 380.792 72.485V80.2571H387.934V45.2827C387.934 33.4145 381.107 25.5373 365.668 25.5373C350.859 25.5373 344.347 32.9944 342.982 42.5519H350.229C351.699 34.9899 357.476 31.9441 365.353 31.9441C375.435 31.9441 380.477 36.1452 380.477 45.1776V48.6436C363.567 48.6436 356.53 48.9587 351.279 51.0592C345.187 53.4749 341.616 58.8313 341.616 65.2381C341.616 74.5856 347.603 81.5175 360.311 81.5175Z" fill="black"/><path d="M428.703 26.3776C428.703 26.3776 427.443 26.2725 426.917 26.2725C417.045 26.2725 411.793 31.4189 409.798 35.0949V26.7977H402.656V80.2571H410.113V49.9039C410.113 38.7709 416.94 33.3094 426.077 33.3094C427.443 33.3094 428.703 33.4145 428.703 33.4145V26.3776Z" fill="black"/><path d="M429.976 53.5799C429.976 68.1789 440.059 81.5175 456.338 81.5175C470.832 81.5175 479.235 71.8548 481.335 61.247H473.773C471.568 69.5442 465.476 74.7956 456.338 74.7956C445.1 74.7956 437.538 65.8682 437.538 53.5799C437.538 41.1866 445.1 32.2592 456.338 32.2592C465.476 32.2592 471.568 37.5106 473.773 45.8078H481.335C479.235 35.1999 470.832 25.5373 456.338 25.5373C440.059 25.5373 429.976 38.8759 429.976 53.5799Z" fill="black"/><path d="M498.891 1.48584H491.434V80.2571H498.891V48.6436C498.891 37.7206 505.927 32.0491 514.96 32.0491C524.517 32.0491 529.034 37.9307 529.034 47.5933V80.2571H536.491V46.1229C536.491 34.2547 529.454 25.5373 516.22 25.5373C506.243 25.5373 500.781 30.9988 498.891 34.2547V1.48584Z" fill="black"/></svg>
|
28
|
+
</a>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</footer>
|
32
|
+
</div>
|
33
|
+
<div id="modal-overlay" class="modal-overlay"></div>
|
34
|
+
</div>
|
35
|
+
`;
|
36
|
+
|
37
|
+
fn.init = () => {
|
38
|
+
let div = document.createElement("div");
|
39
|
+
div.innerHTML += fn.template;
|
40
|
+
document.body.append(div);
|
41
|
+
|
42
|
+
meilisearch = volantis.GLOBAL_CONFIG.search;
|
43
|
+
if (meilisearch.appId && meilisearch.apiKey && meilisearch.indexName) {
|
44
|
+
fn.event();
|
45
|
+
fn.setAlgolia();
|
46
|
+
} else {
|
47
|
+
document.querySelector('#u-search main.modal-body').innerHTML = 'Algolia setting is invalid!';
|
48
|
+
document.querySelector('#u-search main.modal-body').style.textAlign = 'center';
|
49
|
+
document.querySelector('#u-search .modal').style.maxHeight = '128px';
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
fn.event = () => {
|
54
|
+
document
|
55
|
+
.querySelector("#u-search-btn-close")
|
56
|
+
.addEventListener("click", fn.close, false);
|
57
|
+
document
|
58
|
+
.querySelector("#modal-overlay")
|
59
|
+
.addEventListener("click", fn.close, false);
|
60
|
+
document.querySelectorAll(".u-search-form").forEach((e) => {
|
61
|
+
e.addEventListener("submit", fn.onSubmit, false);
|
62
|
+
});
|
63
|
+
document.querySelector("#meilisearch-search-input").addEventListener("input", event => {
|
64
|
+
let input = event.target.querySelector(".ais-SearchBox-input");
|
65
|
+
if (input) {
|
66
|
+
fn.queryText = input.value;
|
67
|
+
} else {
|
68
|
+
fn.queryText = event.target.value;
|
69
|
+
}
|
70
|
+
})
|
71
|
+
}
|
72
|
+
|
73
|
+
fn.setAlgolia = () => {
|
74
|
+
search = instantsearch({
|
75
|
+
indexName: meilisearch.indexName,
|
76
|
+
searchClient: instantMeiliSearch(meilisearch.appId, meilisearch.apiKey),
|
77
|
+
searchFunction(helper) {
|
78
|
+
helper.state.query && helper.search()
|
79
|
+
},
|
80
|
+
})
|
81
|
+
|
82
|
+
const configure = instantsearch.widgets.configure({
|
83
|
+
hitsPerPage: meilisearch.hitsPerPage
|
84
|
+
})
|
85
|
+
|
86
|
+
const searchBox = instantsearch.widgets.searchBox({
|
87
|
+
container: '#meilisearch-search-input',
|
88
|
+
autofocus: true,
|
89
|
+
showReset: false,
|
90
|
+
showSubmit: false,
|
91
|
+
showLoadingIndicator: false,
|
92
|
+
searchAsYouType: meilisearch.searchAsYouType,
|
93
|
+
placeholder: meilisearch.placeholder,
|
94
|
+
templates: {
|
95
|
+
input: 'meilisearch-input'
|
96
|
+
},
|
97
|
+
queryHook(query, refine) {
|
98
|
+
clearTimeout(timerId)
|
99
|
+
timerId = setTimeout(() => refine(query), 500)
|
100
|
+
}
|
101
|
+
})
|
102
|
+
|
103
|
+
const hits = instantsearch.widgets.hits({
|
104
|
+
container: '#meilisearch-hits',
|
105
|
+
templates: {
|
106
|
+
item(data) {
|
107
|
+
const keyword = !!fn.queryText ? `?keyword=${fn.queryText}` : ''
|
108
|
+
const link = data.permalink ? data.permalink : `${volantis.GLOBAL_CONFIG.root}${data.path}`
|
109
|
+
const result = data._highlightResult
|
110
|
+
const content = fn.cutContent(result.text.value)
|
111
|
+
return `
|
112
|
+
<a href="${link}${keyword}" class="result">
|
113
|
+
<span class="title">${result.title.value || 'no-title'}</span>
|
114
|
+
<span class="digest">${content}</span>
|
115
|
+
</a>`
|
116
|
+
},
|
117
|
+
empty: function (data) {
|
118
|
+
return (
|
119
|
+
`<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>`
|
120
|
+
)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
})
|
124
|
+
|
125
|
+
const stats = instantsearch.widgets.stats({
|
126
|
+
container: '#meilisearch-info > .meilisearch-stats',
|
127
|
+
templates: {
|
128
|
+
text: function (data) {
|
129
|
+
const stats = volantis.GLOBAL_CONFIG.languages.search.hits_stats
|
130
|
+
.replace(/\$\{hits}/, data.nbHits)
|
131
|
+
.replace(/\$\{time}/, data.processingTimeMS)
|
132
|
+
return (
|
133
|
+
`${stats}`
|
134
|
+
)
|
135
|
+
}
|
136
|
+
}
|
137
|
+
})
|
138
|
+
|
139
|
+
search.addWidgets([searchBox, hits, stats])
|
140
|
+
|
141
|
+
search.start()
|
142
|
+
|
143
|
+
window.pjax && search.on('render', () => {
|
144
|
+
window.pjax.refresh(document.getElementById('meilisearch-hits'))
|
145
|
+
})
|
146
|
+
}
|
147
|
+
|
148
|
+
fn.setQueryText = queryText => {
|
149
|
+
fn.queryText = queryText;
|
150
|
+
if (!search) {
|
151
|
+
fn.init()
|
152
|
+
}
|
153
|
+
search?.setUiState({
|
154
|
+
[meilisearch.indexName]: {
|
155
|
+
query: queryText
|
156
|
+
}
|
157
|
+
})
|
158
|
+
}
|
159
|
+
|
160
|
+
fn.search = () => {
|
161
|
+
document.querySelector("#u-search").style.display = "block";
|
162
|
+
document.addEventListener("keydown", event => {
|
163
|
+
if (event.code === "Escape") {
|
164
|
+
fn.close();
|
165
|
+
}
|
166
|
+
}, { once: true })
|
167
|
+
}
|
168
|
+
|
169
|
+
fn.onSubmit = (event) => {
|
170
|
+
event.preventDefault();
|
171
|
+
let input = event.target.querySelector(".u-search-input");
|
172
|
+
fn.setQueryText(input?.value ? input.value : event.target.value)
|
173
|
+
fn.search();
|
174
|
+
};
|
175
|
+
|
176
|
+
fn.cutContent = content => {
|
177
|
+
if (content === '') return ''
|
178
|
+
|
179
|
+
const firstOccur = content.indexOf('<mark>')
|
180
|
+
|
181
|
+
let start = firstOccur - 30
|
182
|
+
let end = firstOccur + 120
|
183
|
+
let pre = ''
|
184
|
+
let post = ''
|
185
|
+
|
186
|
+
if (start <= 0) {
|
187
|
+
start = 0
|
188
|
+
end = 140
|
189
|
+
} else {
|
190
|
+
pre = '...'
|
191
|
+
}
|
192
|
+
|
193
|
+
if (end > content.length) {
|
194
|
+
end = content.length
|
195
|
+
} else {
|
196
|
+
post = '...'
|
197
|
+
}
|
198
|
+
|
199
|
+
let matchContent = pre + content.substring(start, end) + post
|
200
|
+
return matchContent
|
201
|
+
}
|
202
|
+
|
203
|
+
fn.close = () => {
|
204
|
+
document.querySelector("#u-search").style.display = "none";
|
205
|
+
};
|
206
|
+
|
207
|
+
return {
|
208
|
+
init: fn.init,
|
209
|
+
setQueryText: queryText => {
|
210
|
+
fn.setQueryText(queryText);
|
211
|
+
},
|
212
|
+
search: fn.search,
|
213
|
+
close: fn.close
|
214
|
+
}
|
215
|
+
})()
|
216
|
+
|
217
|
+
Object.freeze(SearchService);
|
218
|
+
|
219
|
+
SearchService.init();
|
220
|
+
document.addEventListener("pjax:send", SearchService.close);
|