sinzmise-cetastories-en 2.0.0-1731114112886 → 2.0.0-1731114604643

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.
Files changed (84) hide show
  1. package/archives/2023/12/index.html +1 -3882
  2. package/archives/2023/index.html +1 -3882
  3. package/archives/index.html +1 -3847
  4. package/assets/algolia/algoliasearch.js +3 -7182
  5. package/assets/algolia/algoliasearchLite.js +3 -4445
  6. package/atom.xml +2 -2
  7. package/baidu_verify_codeva-NA6uDlCuZg.html +1 -3960
  8. package/categories/Test/index.html +1 -3885
  9. package/categories/index.html +1 -4014
  10. package/content.json +1 -1
  11. package/css/custom2.css +2 -3
  12. package/css/first.css +2 -1868
  13. package/css/pace/big-counter.css +2 -39
  14. package/css/pace/corner-indicator.css +2 -72
  15. package/css/pace/flash.css +2 -76
  16. package/css/pace/mac-osx.css +2 -86
  17. package/css/pace/pace.css +2 -50
  18. package/css/plane.css +2 -59
  19. package/css/style.css +2 -8570
  20. package/css/tags.css +2 -3516
  21. package/games +2 -2
  22. package/google8073542809160a67.html +1 -3960
  23. package/index.html +1 -3926
  24. package/js/app.js +2 -1341
  25. package/js/autoload.js +2 -62
  26. package/js/ceta/fancybox.css +2 -2
  27. package/js/ceta/fancybox.umd.js +2 -2
  28. package/js/ceta/iconfontInkss.js +2 -1
  29. package/js/ceta/message.css +2 -6
  30. package/js/ceta/message.js +2 -6
  31. package/js/clock.js +2 -1
  32. package/js/kslink.js +2 -38
  33. package/js/newyear.js +2 -76
  34. package/js/plane.js +2 -2200
  35. package/js/plugins/aplayer.js +2 -186
  36. package/js/plugins/parallax.js +2 -191
  37. package/js/plugins/rightMenus.js +2 -623
  38. package/js/plugins/tags/contributors.js +2 -92
  39. package/js/plugins/tags/friends.js +2 -93
  40. package/js/plugins/tags/sites.js +2 -96
  41. package/js/search/algolia.js +2 -239
  42. package/js/search/hexo.js +2 -195
  43. package/js/search/meilisearch.js +2 -220
  44. package/js/txmap.js +2 -248
  45. package/load.html +1 -294
  46. package/maps/assets/algolia/algoliasearch.js.map +1 -0
  47. package/maps/assets/algolia/algoliasearchLite.js.map +1 -0
  48. package/maps/css/custom2.css.map +1 -0
  49. package/maps/css/first.css.map +1 -0
  50. package/maps/css/pace/big-counter.css.map +1 -0
  51. package/maps/css/pace/corner-indicator.css.map +1 -0
  52. package/maps/css/pace/flash.css.map +1 -0
  53. package/maps/css/pace/mac-osx.css.map +1 -0
  54. package/maps/css/pace/pace.css.map +1 -0
  55. package/maps/css/plane.css.map +1 -0
  56. package/maps/css/style.css.map +1 -0
  57. package/maps/css/tags.css.map +1 -0
  58. package/maps/js/app.js.map +1 -0
  59. package/maps/js/autoload.js.map +1 -0
  60. package/maps/js/ceta/fancybox.css.map +1 -0
  61. package/maps/js/ceta/fancybox.umd.js.map +1 -0
  62. package/maps/js/ceta/iconfontInkss.js.map +1 -0
  63. package/maps/js/ceta/message.css.map +1 -0
  64. package/maps/js/ceta/message.js.map +1 -0
  65. package/maps/js/clock.js.map +1 -0
  66. package/maps/js/kslink.js.map +1 -0
  67. package/maps/js/newyear.js.map +1 -0
  68. package/maps/js/plane.js.map +1 -0
  69. package/maps/js/plugins/aplayer.js.map +1 -0
  70. package/maps/js/plugins/parallax.js.map +1 -0
  71. package/maps/js/plugins/rightMenus.js.map +1 -0
  72. package/maps/js/plugins/tags/contributors.js.map +1 -0
  73. package/maps/js/plugins/tags/friends.js.map +1 -0
  74. package/maps/js/plugins/tags/sites.js.map +1 -0
  75. package/maps/js/search/algolia.js.map +1 -0
  76. package/maps/js/search/hexo.js.map +1 -0
  77. package/maps/js/search/meilisearch.js.map +1 -0
  78. package/maps/js/txmap.js.map +1 -0
  79. package/maps/sw.js.map +1 -0
  80. package/package.json +1 -1
  81. package/posts/46521/index.html +1 -4049
  82. package/sw.js +2 -798
  83. package/tags/Test/index.html +1 -3885
  84. package/tags/index.html +1 -3997
@@ -1,92 +1,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
+ const ContributorsJS={requestAPI:(t,r,e)=>{let n=5;!function o(){return new Promise(((a,s)=>{let l=0,i=setTimeout((()=>{0===l&&(l=2,i=null,s("请求超时"),0==n&&e())}),5e3);fetch(t).then((function(t){if(2!==l&&(clearTimeout(i),a(t),i=null,l=1),t.ok)return t.json();throw new Error("Network response was not ok.")})).then((function(t){n=0,r(t)})).catch((function(t){n>0?(n-=1,setTimeout((()=>{o()}),5e3)):e()}))}))}()},layout:t=>{const r=t.el;ContributorsJS.requestAPI(t.api,(function(e){r.querySelector(".loading-wrap").remove();var n="";(e||[]).forEach(((r,e)=>{var o='<div class="user-card">';o+='<a class="card-link" target="_blank" rel="external noopener noreferrer"',o+=' href="'+r.html_url+'">',o+='<img alt="'+r.login+'" src="'+(r.avatar_url||t.avatar)+'" onerror="errorImgAvatar(this)">',o+='<div class="name"><span>'+r.login+"</span></div>",o+="</a>",n+=o+="</div>"})),r.querySelector(".group-body").innerHTML=n}),(function(){try{r.querySelector(".loading-wrap svg").remove(),r.querySelector(".loading-wrap p").innerText("加载失败,请稍后重试。")}catch(t){}}))},start:()=>{const t=document.getElementsByClassName("contributorsjs-wrap");for(var r=0;r<t.length;r++){const n=t[r],o=n.getAttribute("api");if(null!=o){var e=new Object;e.el=n,e.api=o,e.class=n.getAttribute("class"),e.avatar=volantis.GLOBAL_CONFIG.default.avatar,ContributorsJS.layout(e)}}}};ContributorsJS.start(),document.addEventListener("pjax:complete",(function(){ContributorsJS.start()}));
2
+ //# sourceMappingURL=../../../maps/js/plugins/tags/contributors.js.map
@@ -1,93 +1,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
- });
1
+ const FriendsJS={requestAPI:(e,t,r)=>{let n=5;!function a(){return new Promise(((o,s)=>{let i=0,l=setTimeout((()=>{0===i&&(i=2,l=null,s("请求超时"),0==n&&r())}),5e3);fetch(e).then((function(e){if(2!==i&&(clearTimeout(l),o(e),l=null,i=1),e.ok)return e.json();throw new Error("Network response was not ok.")})).then((function(e){n=0,t(e)})).catch((function(e){n>0?(n-=1,setTimeout((()=>{a()}),5e3)):r()}))}))}()},layout:e=>{const t=e.el;FriendsJS.requestAPI(e.api,(function(r){t.querySelector(".loading-wrap").remove();const n=r.content;var a="";n.forEach(((t,r)=>{var n='<div class="user-card">';n+='<a class="card-link" target="_blank" rel="external noopener noreferrer"',n+=' href="'+t.url+'">',n+='<img alt="'+t.title+'" src="'+(t.avatar||e.avatar)+'" onerror="errorImgAvatar(this)">',n+='<div class="name"><span>'+t.title+"</span></div>",n+="</a>",a+=n+="</div>"})),t.querySelector(".group-body").innerHTML=a}),(function(){try{t.querySelector(".loading-wrap svg").remove(),t.querySelector(".loading-wrap p").innerText("加载失败,请稍后重试。")}catch(e){}}))},start:()=>{const e=document.getElementsByClassName("friendsjs-wrap");for(var t=0;t<e.length;t++){const n=e[t],a=n.getAttribute("api");if(null!=a){var r=new Object;r.el=n,r.api=a,r.class=n.getAttribute("class"),r.avatar=volantis.GLOBAL_CONFIG.default.avatar,FriendsJS.layout(r)}}}};FriendsJS.start(),document.addEventListener("pjax:complete",(function(){FriendsJS.start()}));
2
+ //# sourceMappingURL=../../../maps/js/plugins/tags/friends.js.map
@@ -1,96 +1,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
- });
1
+ const SitesJS={requestAPI:(e,t,r)=>{let n=5;!function a(){return new Promise(((o,s)=>{let i=0,l=setTimeout((()=>{0===i&&(i=2,l=null,s("请求超时"),0==n&&r())}),5e3);fetch(e).then((function(e){if(2!==i&&(clearTimeout(l),o(e),l=null,i=1),e.ok)return e.json();throw new Error("Network response was not ok.")})).then((function(e){n=0,t(e)})).catch((function(e){n>0?(n-=1,setTimeout((()=>{a()}),5e3)):r()}))}))}()},layout:e=>{const t=e.el;SitesJS.requestAPI(e.api,(function(r){t.querySelector(".loading-wrap").remove();const n=r.content;var a="";n.forEach(((t,r)=>{var n='<div class="site-card">';n+='<a class="card-link" target="_blank" rel="external noopener noreferrer" href="'+t.url+'">',n+='<img alt="'+t.title+'" src="'+(t.screenshot||"https://image.thum.io/get/width/1024/crop/768/"+t.url)+'" onerror="errorImgCover(this)"/>',n+='<div class="info">',n+='<img alt="'+t.title+'" src="'+(t.avatar||e.avatar)+'" onerror="errorImgAvatar(this)"/>',n+='<span class="title">'+t.title+"</span>",n+='<span class="desc">'+(t.description||t.url)+"</span>",n+="</div>",n+="</a>",a+=n+="</div>"})),t.querySelector(".group-body").innerHTML=a}),(function(){try{t.querySelector(".loading-wrap svg").remove(),t.querySelector(".loading-wrap p").innerText("加载失败,请稍后重试。")}catch(e){}}))},start:e=>{const t=document.getElementsByClassName("sitesjs-wrap");for(var r=0;r<t.length;r++){const n=t[r],a=n.getAttribute("api");if(null!=a)(e=new Object).class=n.getAttribute("class"),e.el=n,e.api=a,e.avatar=volantis.GLOBAL_CONFIG.default.link,e.screenshot=volantis.GLOBAL_CONFIG.default.cover,SitesJS.layout(e)}}};SitesJS.start(),document.addEventListener("pjax:complete",(function(){SitesJS.start()}));
2
+ //# sourceMappingURL=../../../maps/js/plugins/tags/sites.js.map
@@ -1,239 +1,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);
1
+ let SearchService=(()=>{const e={};let t,a,n;return e.queryText=null,e.template='<div id="u-search">\n <div class="modal">\n <header class="modal-header" class="clearfix">\n <button type="submit" id="u-search-modal-btn-submit" class="u-search-btn-submit">\n <span class="fa-solid fa-search"></span>\n </button>\n <div id="algolia-search-input"></div>\n <a id="u-search-btn-close" class="btn-close"> <span class="fa-solid fa-times"></span> </a>\n </header>\n <main class="modal-body">\n <div id="algolia-search-results">\n <div id="algolia-hits">\n <div class="search-icon"><i class="fa-sharp fa-solid fa-telescope"></i></i></div>\n </div>\n </div>\n </main>\n <footer>\n <div id="algolia-pagination"></div>\n <hr>\n <div id="algolia-info">\n <div class="algolia-stats"></div>\n <div class="algolia-poweredBy"></div>\n </div>\n </footer>\n </div>\n <div id="modal-overlay" class="modal-overlay"></div>\n </div>\n ',e.init=()=>{let t=document.createElement("div");t.innerHTML+=e.template,document.body.append(t),a=volantis.GLOBAL_CONFIG.search,a.appId&&a.apiKey&&a.indexName?(e.event(),e.setAlgolia()):(document.querySelector("#u-search main.modal-body").innerHTML="Algolia setting is invalid!",document.querySelector("#u-search main.modal-body").style.textAlign="center",document.querySelector("#u-search .modal").style.maxHeight="128px")},e.event=()=>{document.querySelector("#u-search-btn-close").addEventListener("click",e.close,!1),document.querySelector("#modal-overlay").addEventListener("click",e.close,!1),document.querySelectorAll(".u-search-form").forEach((t=>{t.addEventListener("submit",e.onSubmit,!1)})),document.querySelector("#algolia-search-input").addEventListener("input",(t=>{let a=t.target.querySelector(".ais-SearchBox-input");e.queryText=a?a.value:t.target.value}))},e.setAlgolia=()=>{t=instantsearch({indexName:a.indexName,searchClient:algoliasearch(a.appId,a.apiKey),searchFunction(e){e.state.query&&e.search()}});const i=instantsearch.widgets.configure({hitsPerPage:a.hitsPerPage}),s=instantsearch.widgets.searchBox({container:"#algolia-search-input",autofocus:!0,showReset:!1,showSubmit:!1,showLoadingIndicator:!1,searchAsYouType:a.searchAsYouType,placeholder:a.placeholder,templates:{input:"algolia-input"},queryHook(e,t){clearTimeout(n),n=setTimeout((()=>t(e)),500)}}),l=instantsearch.widgets.hits({container:"#algolia-hits",templates:{item(t){const a=e.queryText?`?keyword=${e.queryText}`:"",n=t.permalink?t.permalink:`${volantis.GLOBAL_CONFIG.root}${t.path}`,i=t._highlightResult,s=i.contentStripTruncate?e.cutContent(i.contentStripTruncate.value):i.contentStrip?e.cutContent(i.contentStrip.value):i.content?e.cutContent(i.content.value):"";return`\n <a href="${n}${a}" class="result">\n <span class="title">${i.title.value||"no-title"}</span>\n <span class="digest">${s}</span>\n </a>`},empty:function(e){return`<div id="resule-hits-empty"><i class="fa-solid fa-box-open"></i><p>${volantis.GLOBAL_CONFIG.languages.search.hits_empty.replace(/\$\{query}/,e.query)}</p></div>`}}}),r=instantsearch.widgets.stats({container:"#algolia-info > .algolia-stats",templates:{text:function(e){return`${volantis.GLOBAL_CONFIG.languages.search.hits_stats.replace(/\$\{hits}/,e.nbHits).replace(/\$\{time}/,e.processingTimeMS)}`}}}),o=instantsearch.widgets.poweredBy({container:"#algolia-info > .algolia-poweredBy",theme:"dark"===volantis.dark?.mode?"dark":"light"}),c=instantsearch.widgets.pagination({container:"#algolia-pagination",totalPages:5,templates:{first:'<i class="fas fa-angle-double-left"></i>',last:'<i class="fas fa-angle-double-right"></i>',previous:'<i class="fas fa-angle-left"></i>',next:'<i class="fas fa-angle-right"></i>'}});t.addWidgets([i,s,l,r,o,c]),t.start(),window.pjax&&t.on("render",(()=>{window.pjax.refresh(document.getElementById("algolia-hits"))}))},e.setQueryText=n=>{e.queryText=n,t||e.init(),t?.setUiState({[a.indexName]:{query:n}})},e.search=()=>{document.querySelector("#u-search").style.display="block",document.addEventListener("keydown",(t=>{"Escape"===t.code&&e.close()}),{once:!0})},e.onSubmit=t=>{t.preventDefault();let a=t.target.querySelector(".u-search-input");e.setQueryText(a?.value?a.value:t.target.value),e.search()},e.cutContent=e=>{if(""===e)return"";const t=e.indexOf("<mark>");let a=t-30,n=t+120,i="",s="";return a<=0?(a=0,n=140):i="...",n>e.length?n=e.length:s="...",i+e.substring(a,n)+s},e.close=()=>{document.querySelector("#u-search").style.display="none"},{init:e.init,setQueryText:t=>{e.setQueryText(t)},search:e.search,close:e.close}})();Object.freeze(SearchService),SearchService.init(),document.addEventListener("pjax:send",SearchService.close);
2
+ //# sourceMappingURL=../../maps/js/search/algolia.js.map