clean-jsdoc-theme 3.3.4 → 4.0.3
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/.eslintignore +4 -4
- package/.eslintrc.js +3 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +43 -43
- package/.github/ISSUE_TEMPLATE/feature_request.md +27 -27
- package/.github/pull_request_template.md +16 -16
- package/.github/workflows/{codeql-analysis.yml → codeql.yml} +72 -67
- package/.github/workflows/greetings.yml +16 -0
- package/.prettierignore +2 -2
- package/.prettierrc +5 -5
- package/.stylelintignore +3 -3
- package/.stylelintrc +23 -23
- package/.travis.yml +30 -30
- package/CHANGELOG.md +232 -216
- package/CODE_OF_CONDUCT.md +76 -76
- package/CODE_OF_CONDUCT_HINDI.md +46 -46
- package/CONTRIBUTING.md +24 -24
- package/LICENSE +21 -21
- package/README.md +441 -546
- package/SECURITY.md +21 -21
- package/helpers/down-arrow.js +9 -9
- package/jsdoc-config.json +62 -60
- package/minify.js +52 -0
- package/package.json +50 -46
- package/publish.js +1131 -1197
- package/static/fonts/Inconsolata-Regular.ttf +0 -0
- package/static/fonts/OpenSans-Regular.ttf +0 -0
- package/static/fonts/WorkSans-Bold.ttf +0 -0
- package/static/scripts/core.js +576 -0
- package/static/scripts/core.min.js +23 -0
- package/static/scripts/resize.js +90 -85
- package/static/scripts/search.js +244 -77
- package/static/scripts/search.min.js +11 -0
- package/static/scripts/third-party/Apache-License-2.0.txt +202 -202
- package/static/scripts/third-party/fuse.js +8 -8
- package/static/scripts/third-party/hljs-line-num.js +1 -0
- package/static/scripts/third-party/hljs-original.js +5162 -0
- package/static/scripts/third-party/hljs.js +1 -0
- package/static/scripts/third-party/popper.js +6 -0
- package/static/scripts/third-party/tippy.js +2 -0
- package/static/scripts/third-party/tocbot.js +1 -0
- package/static/styles/clean-jsdoc-theme-base.css +959 -393
- package/static/styles/clean-jsdoc-theme-dark.css +407 -324
- package/static/styles/clean-jsdoc-theme-light.css +388 -319
- package/static/styles/clean-jsdoc-theme.min.css +1 -0
- package/tmpl/augments.tmpl +10 -10
- package/tmpl/container.tmpl +190 -189
- package/tmpl/details.tmpl +208 -208
- package/tmpl/example.tmpl +3 -3
- package/tmpl/examples.tmpl +40 -38
- package/tmpl/exceptions.tmpl +32 -32
- package/tmpl/icons.tmpl +72 -34
- package/tmpl/layout.tmpl +146 -165
- package/tmpl/mainpage.tmpl +10 -10
- package/tmpl/members.tmpl +42 -43
- package/tmpl/method.tmpl +139 -140
- package/tmpl/mobile-sidebar.tmpl +21 -0
- package/tmpl/navbar-actions.tmpl +19 -0
- package/tmpl/navbar-menu.tmpl +25 -0
- package/tmpl/navbar.tmpl +14 -0
- package/tmpl/params.tmpl +124 -124
- package/tmpl/properties.tmpl +109 -109
- package/tmpl/returns.tmpl +18 -18
- package/tmpl/search.tmpl +17 -0
- package/tmpl/sidebar-items.tmpl +24 -0
- package/tmpl/sidebar-title.tmpl +10 -0
- package/tmpl/sidebar.tmpl +9 -0
- package/tmpl/source.tmpl +12 -7
- package/tmpl/toc.tmpl +4 -0
- package/tmpl/tutorial.tmpl +19 -19
- package/tmpl/type.tmpl +6 -6
- package/helpers/navbarBuilder.js +0 -0
- package/static/fonts/MavenPro-Regular.ttf +0 -0
- package/static/fonts/Montserrat-Regular.ttf +0 -0
- package/static/fonts/Muli-Black.ttf +0 -0
- package/static/fonts/OFL-hind.txt +0 -93
- package/static/fonts/OFL-montserrat.txt +0 -93
- package/static/scripts/fix-code-block.js +0 -53
- package/static/scripts/fix-navbar.js +0 -25
- package/static/scripts/linenumber.js +0 -25
- package/static/scripts/misc.js +0 -217
- package/static/scripts/third-party/lang-css.js +0 -2
- package/static/scripts/third-party/prettify.js +0 -28
- package/static/styles/reset.css +0 -351
- package/static/styles/third-party/ionicons.min.css +0 -11
- package/static/styles/third-party/prettify-jsdoc.css +0 -111
- package/static/styles/third-party/prettify-tomorrow.css +0 -5
package/static/scripts/resize.js
CHANGED
|
@@ -1,85 +1,90 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
1
|
+
/* global document */
|
|
2
|
+
// This file is @deprecated
|
|
3
|
+
|
|
4
|
+
var NAVBAR_OPTIONS = {};
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
var NAVBAR_RESIZE_LOCAL_STORAGE_KEY = 'NAVBAR_RESIZE_LOCAL_STORAGE_KEY';
|
|
8
|
+
|
|
9
|
+
var navbar = document.querySelector('#navbar');
|
|
10
|
+
var footer = document.querySelector('#footer');
|
|
11
|
+
var mainSection = document.querySelector('#main');
|
|
12
|
+
// eslint-disable-next-line no-undef
|
|
13
|
+
var localStorageResizeObject = JSON.parse(
|
|
14
|
+
localStorage.getItem(NAVBAR_RESIZE_LOCAL_STORAGE_KEY)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check whether we have any resize value in local storage or not.
|
|
19
|
+
* If we have resize value then resize the navbar.
|
|
20
|
+
**/
|
|
21
|
+
if (localStorageResizeObject) {
|
|
22
|
+
navbar.style.width = localStorageResizeObject.width;
|
|
23
|
+
mainSection.style.marginLeft = localStorageResizeObject.width;
|
|
24
|
+
footer.style.marginLeft = localStorageResizeObject.width;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var navbarSlider = document.querySelector('#navbar-resize');
|
|
28
|
+
|
|
29
|
+
function resizeNavbar(event) {
|
|
30
|
+
var pageX = event.pageX,
|
|
31
|
+
pageXPlusPx = event.pageX + 'px',
|
|
32
|
+
min = Number.parseInt(NAVBAR_OPTIONS.min, 10) || 300,
|
|
33
|
+
max = Number.parseInt(NAVBAR_OPTIONS.max, 10) || 600;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Just to add some checks. If min is smaller then 10 then
|
|
37
|
+
* user may accidentally end up reducing the size of navbar
|
|
38
|
+
* less than 10. In that case user will not able to resize navbar
|
|
39
|
+
* because navbar slider will be hidden.
|
|
40
|
+
*/
|
|
41
|
+
if (min < 10) {
|
|
42
|
+
min = 10;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Only resize if pageX in range between min and max
|
|
47
|
+
* allowed value.
|
|
48
|
+
*/
|
|
49
|
+
if (min < pageX && pageX < max) {
|
|
50
|
+
navbar.style.width = pageXPlusPx;
|
|
51
|
+
mainSection.style.marginLeft = pageXPlusPx;
|
|
52
|
+
footer.style.marginLeft = pageXPlusPx;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setupEventListeners() {
|
|
57
|
+
// eslint-disable-next-line no-undef
|
|
58
|
+
window.addEventListener('mousemove', resizeNavbar);
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
window.addEventListener('touchmove', resizeNavbar);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function afterRemovingEventListeners() {
|
|
64
|
+
// eslint-disable-next-line no-undef
|
|
65
|
+
localStorage.setItem(
|
|
66
|
+
NAVBAR_RESIZE_LOCAL_STORAGE_KEY,
|
|
67
|
+
JSON.stringify({
|
|
68
|
+
width: navbar.style.width
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function removeEventListeners() {
|
|
74
|
+
// eslint-disable-next-line no-undef
|
|
75
|
+
window.removeEventListener('mousemove', resizeNavbar);
|
|
76
|
+
// eslint-disable-next-line no-undef
|
|
77
|
+
window.removeEventListener('touchend', resizeNavbar);
|
|
78
|
+
afterRemovingEventListeners();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
navbarSlider.addEventListener('mousedown', setupEventListeners);
|
|
82
|
+
navbarSlider.addEventListener('touchstart', setupEventListeners);
|
|
83
|
+
// eslint-disable-next-line no-undef
|
|
84
|
+
window.addEventListener('mouseup', removeEventListeners);
|
|
85
|
+
})();
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line no-unused-vars
|
|
88
|
+
function setupResizeOptions(options) {
|
|
89
|
+
NAVBAR_OPTIONS = options;
|
|
90
|
+
}
|
package/static/scripts/search.js
CHANGED
|
@@ -1,77 +1,244 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
/* global document */
|
|
2
|
+
|
|
3
|
+
var searchData;
|
|
4
|
+
|
|
5
|
+
function hideSearch() {
|
|
6
|
+
var container = document.querySelector('#search-container');
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line no-undef
|
|
9
|
+
if (window.location.hash === '#search') {
|
|
10
|
+
// eslint-disable-next-line no-undef
|
|
11
|
+
history.go(-1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line no-undef
|
|
15
|
+
window.onhashchange = null;
|
|
16
|
+
|
|
17
|
+
if (container) {
|
|
18
|
+
container.style.display = 'none';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function listenKey(event) {
|
|
23
|
+
if (event.key === 'Escape') {
|
|
24
|
+
hideSearch();
|
|
25
|
+
// eslint-disable-next-line no-undef
|
|
26
|
+
window.removeEventListener('keyup', listenKey);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function showSearch() {
|
|
31
|
+
var container = document.querySelector('#search-container');
|
|
32
|
+
var input = document.querySelector('#search-input');
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line no-undef
|
|
35
|
+
window.onhashchange = hideSearch;
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line no-undef
|
|
38
|
+
if (window.location.hash !== '#search') {
|
|
39
|
+
// eslint-disable-next-line no-undef
|
|
40
|
+
history.pushState(null, null, '#search');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (container) {
|
|
44
|
+
container.style.display = 'flex';
|
|
45
|
+
// eslint-disable-next-line no-undef
|
|
46
|
+
window.addEventListener('keyup', listenKey);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (input) {
|
|
50
|
+
input.focus();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fetchAllData(obj = {}) {
|
|
55
|
+
// eslint-disable-next-line no-undef
|
|
56
|
+
var url = baseURL + 'data/search.json';
|
|
57
|
+
|
|
58
|
+
fetch(url)
|
|
59
|
+
.then(function(d) {
|
|
60
|
+
return d.json();
|
|
61
|
+
})
|
|
62
|
+
.then(function(d) {
|
|
63
|
+
searchData = d.list;
|
|
64
|
+
if (typeof obj.onSuccess === 'function') {
|
|
65
|
+
obj.onSuccess(d.list);
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
.catch(function(error) {
|
|
69
|
+
console.error(error);
|
|
70
|
+
if (typeof obj.onError === 'function') {
|
|
71
|
+
obj.onError();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function buildSearchResult(result) {
|
|
77
|
+
var output = '';
|
|
78
|
+
|
|
79
|
+
for (const res of result) {
|
|
80
|
+
var data = res.item;
|
|
81
|
+
var link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
|
|
82
|
+
|
|
83
|
+
output += `
|
|
84
|
+
|
|
85
|
+
<a href="${link}" class="search-result-item">
|
|
86
|
+
<div class="search-result-item-title">
|
|
87
|
+
${data.title}
|
|
88
|
+
</div>
|
|
89
|
+
<div class="search-result-item-p">
|
|
90
|
+
${data.description ? data.description : 'No description available.'}
|
|
91
|
+
</div>
|
|
92
|
+
</a>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return output;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getSearchResult(list, keys, searchKey) {
|
|
100
|
+
var defaultOptions = {
|
|
101
|
+
shouldSort: true,
|
|
102
|
+
threshold: 0.4,
|
|
103
|
+
location: 0,
|
|
104
|
+
distance: 100,
|
|
105
|
+
maxPatternLength: 32,
|
|
106
|
+
minMatchCharLength: 1,
|
|
107
|
+
keys: keys
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// var op = Object.assign({}, defaultOptions, options);
|
|
111
|
+
var op = defaultOptions;
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line no-undef
|
|
114
|
+
var searchIndex = Fuse.createIndex(op.keys, list);
|
|
115
|
+
|
|
116
|
+
/* eslint-disable-next-line */
|
|
117
|
+
var fuse = new Fuse(list, op, searchIndex);
|
|
118
|
+
|
|
119
|
+
var result = fuse.search(searchKey);
|
|
120
|
+
|
|
121
|
+
if (result.length > 20) {
|
|
122
|
+
result = result.slice(0, 20);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function debounce(func, wait, immediate) {
|
|
129
|
+
var timeout;
|
|
130
|
+
|
|
131
|
+
return function() {
|
|
132
|
+
// eslint-disable-next-line consistent-this, no-invalid-this
|
|
133
|
+
var context = this,
|
|
134
|
+
args = arguments;
|
|
135
|
+
|
|
136
|
+
clearTimeout(timeout);
|
|
137
|
+
timeout = setTimeout(function() {
|
|
138
|
+
timeout = null;
|
|
139
|
+
if (!immediate) {
|
|
140
|
+
func.apply(context, args);
|
|
141
|
+
}
|
|
142
|
+
}, wait);
|
|
143
|
+
if (immediate && !timeout) {
|
|
144
|
+
func.apply(context, args);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function search(event) {
|
|
150
|
+
var value = event.target.value;
|
|
151
|
+
var resultBox = document.querySelector('#search-result-c');
|
|
152
|
+
var keys = ['title', 'description'];
|
|
153
|
+
|
|
154
|
+
if (!resultBox) {
|
|
155
|
+
console.error('Search result container not found');
|
|
156
|
+
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!value) {
|
|
161
|
+
resultBox.innerHTML = 'Type anything to view search result';
|
|
162
|
+
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function onSuccess(res) {
|
|
167
|
+
if (res.length === 0) {
|
|
168
|
+
resultBox.innerHTML =
|
|
169
|
+
'No result found! Try some different combination.';
|
|
170
|
+
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
var output = buildSearchResult(res);
|
|
174
|
+
|
|
175
|
+
resultBox.innerHTML = output;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!searchData) {
|
|
179
|
+
resultBox.innerHTML = 'Loading...';
|
|
180
|
+
|
|
181
|
+
fetchAllData({
|
|
182
|
+
onSuccess: function(list) {
|
|
183
|
+
console.log('Onsucess');
|
|
184
|
+
var result = getSearchResult(list, keys, value);
|
|
185
|
+
|
|
186
|
+
onSuccess(result);
|
|
187
|
+
},
|
|
188
|
+
onError: function() {
|
|
189
|
+
resultBox.innerHTML = 'Failed to load result.';
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var result = getSearchResult(searchData, keys, value);
|
|
197
|
+
|
|
198
|
+
onSuccess(result);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function onDomContentLoaded() {
|
|
202
|
+
var input = document.querySelector('#search-input');
|
|
203
|
+
var searchButton = document.querySelectorAll('.search-button');
|
|
204
|
+
var searchContainer = document.querySelector('#search-container');
|
|
205
|
+
var searchWrapper = document.querySelector('#search-wrapper');
|
|
206
|
+
var searchCloseButton = document.querySelector('#search-close-button');
|
|
207
|
+
|
|
208
|
+
var debouncedSearch = debounce(search, 300);
|
|
209
|
+
|
|
210
|
+
if (searchCloseButton) {
|
|
211
|
+
searchCloseButton.addEventListener('click', hideSearch);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (searchButton) {
|
|
215
|
+
searchButton.forEach(function(item) {
|
|
216
|
+
item.addEventListener('click', showSearch);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (searchContainer) {
|
|
221
|
+
searchContainer.addEventListener('click', hideSearch);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (searchWrapper) {
|
|
225
|
+
searchWrapper.addEventListener('click', function(event) {
|
|
226
|
+
event.stopPropagation();
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (input) {
|
|
231
|
+
input.addEventListener('keyup', debouncedSearch);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// eslint-disable-next-line no-undef
|
|
236
|
+
window.addEventListener('DOMContentLoaded', onDomContentLoaded);
|
|
237
|
+
|
|
238
|
+
// eslint-disable-next-line no-undef
|
|
239
|
+
window.addEventListener('hashchange', function() {
|
|
240
|
+
// eslint-disable-next-line no-undef
|
|
241
|
+
if (window.location.hash === '#search') {
|
|
242
|
+
showSearch();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var searchData;function hideSearch(){var e=document.querySelector("#search-container");"#search"===window.location.hash&&history.go(-1),window.onhashchange=null,e&&(e.style.display="none")}function listenKey(e){"Escape"===e.key&&(hideSearch(),window.removeEventListener("keyup",listenKey))}function showSearch(){var e=document.querySelector("#search-container"),n=document.querySelector("#search-input");window.onhashchange=hideSearch,"#search"!==window.location.hash&&history.pushState(null,null,"#search"),e&&(e.style.display="flex",window.addEventListener("keyup",listenKey)),n&&n.focus()}function fetchAllData(n={}){var e=baseURL+"data/search.json";fetch(e).then(function(e){return e.json()}).then(function(e){searchData=e.list,"function"==typeof n.onSuccess&&n.onSuccess(e.list)}).catch(function(e){console.error(e),"function"==typeof n.onError&&n.onError()})}function buildSearchResult(e){var n="";for(const r of e){var t=r.item;n+=`
|
|
2
|
+
|
|
3
|
+
<a href="${r.item.link.replace('<a href="',"").replace(/">.*/,"")}" class="search-result-item">
|
|
4
|
+
<div class="search-result-item-title">
|
|
5
|
+
${t.title}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="search-result-item-p">
|
|
8
|
+
${t.description||"No description available."}
|
|
9
|
+
</div>
|
|
10
|
+
</a>
|
|
11
|
+
`}return n}function getSearchResult(e,n,t){var n={shouldSort:!0,threshold:.4,location:0,distance:100,maxPatternLength:32,minMatchCharLength:1,keys:n},r=Fuse.createIndex(n.keys,e),e=new Fuse(e,n,r).search(t);return e=20<e.length?e.slice(0,20):e}function debounce(t,r,o){var c;return function(){var e=this,n=arguments;clearTimeout(c),c=setTimeout(function(){c=null,o||t.apply(e,n)},r),o&&!c&&t.apply(e,n)}}function search(e){var n=e.target.value,t=document.querySelector("#search-result-c"),r=["title","description"];if(t)if(n){if(!searchData)return t.innerHTML="Loading...",void fetchAllData({onSuccess:function(e){console.log("Onsucess"),o(getSearchResult(e,r,n))},onError:function(){t.innerHTML="Failed to load result."}});o(getSearchResult(searchData,r,n))}else t.innerHTML="Type anything to view search result";else console.error("Search result container not found");function o(e){0===e.length?t.innerHTML="No result found! Try some different combination.":(e=buildSearchResult(e),t.innerHTML=e)}}function onDomContentLoaded(){var e=document.querySelector("#search-input"),n=document.querySelectorAll(".search-button"),t=document.querySelector("#search-container"),r=document.querySelector("#search-wrapper"),o=document.querySelector("#search-close-button"),c=debounce(search,300);o&&o.addEventListener("click",hideSearch),n&&n.forEach(function(e){e.addEventListener("click",showSearch)}),t&&t.addEventListener("click",hideSearch),r&&r.addEventListener("click",function(e){e.stopPropagation()}),e&&e.addEventListener("keyup",c)}window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",function(){"#search"===window.location.hash&&showSearch()});
|