parent
f321503b94
commit
7dff0a3f08
|
@ -558,6 +558,8 @@
|
||||||
var searchMenu = null;
|
var searchMenu = null;
|
||||||
var searchText = null;
|
var searchText = null;
|
||||||
|
|
||||||
|
{{ $enableSearch := ($.Param "enableSearch") }}
|
||||||
|
var enableSearch = JSON.parse({{ $enableSearch | jsonify }});
|
||||||
{{ $enableSearchHighlight := ($.Param "enableSearchHighlight") }}
|
{{ $enableSearchHighlight := ($.Param "enableSearchHighlight") }}
|
||||||
var enableSearchHighlight = JSON.parse({{ $enableSearchHighlight | jsonify }});
|
var enableSearchHighlight = JSON.parse({{ $enableSearchHighlight | jsonify }});
|
||||||
{{ $searchResultPosition := ($.Param "searchResultPosition") }}
|
{{ $searchResultPosition := ($.Param "searchResultPosition") }}
|
||||||
|
@ -567,30 +569,32 @@
|
||||||
|
|
||||||
var fuse = null;
|
var fuse = null;
|
||||||
|
|
||||||
(function initFuse() {
|
if (enableSearch) {
|
||||||
var xhr = new XMLHttpRequest();
|
(function initFuse() {
|
||||||
xhr.open('GET', baseurl + "/index.json");
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
|
xhr.open('GET', baseurl + "/index.json");
|
||||||
xhr.onload = function () {
|
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
|
||||||
if (xhr.status === 200) {
|
xhr.onload = function () {
|
||||||
fuse = new Fuse(JSON.parse(xhr.response.toString('utf-8')), {
|
if (xhr.status === 200) {
|
||||||
keys: sectionType.includes('publication') ? ['title', 'abstract'] : ['title', 'description', 'content'],
|
fuse = new Fuse(JSON.parse(xhr.response.toString('utf-8')), {
|
||||||
includeMatches: enableSearchHighlight,
|
keys: sectionType.includes('publication') ? ['title', 'abstract'] : ['title', 'description', 'content'],
|
||||||
shouldSort: true,
|
includeMatches: enableSearchHighlight,
|
||||||
threshold: 0.4,
|
shouldSort: true,
|
||||||
location: 0,
|
threshold: 0.4,
|
||||||
distance: 100,
|
location: 0,
|
||||||
maxPatternLength: 32,
|
distance: 100,
|
||||||
minMatchCharLength: 1,
|
maxPatternLength: 32,
|
||||||
});
|
minMatchCharLength: 1,
|
||||||
window.fuse = fuse;
|
});
|
||||||
}
|
window.fuse = fuse;
|
||||||
else {
|
}
|
||||||
console.error('[' + xhr.status + ']Error:', xhr.statusText);
|
else {
|
||||||
}
|
console.error('[' + xhr.status + ']Error:', xhr.statusText);
|
||||||
};
|
}
|
||||||
xhr.send();
|
};
|
||||||
})();
|
xhr.send();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
function makeLi(ulElem, obj) {
|
function makeLi(ulElem, obj) {
|
||||||
var li = document.createElement('li');
|
var li = document.createElement('li');
|
||||||
|
|
Loading…
Reference in New Issue