diff options
| author | Jieiku | 2023-05-22 22:31:34 -0700 |
|---|---|---|
| committer | Jieiku | 2023-05-22 22:31:34 -0700 |
| commit | 940b40688a7cf595eee061b696187e2fe4a578e2 (patch) | |
| tree | 15f9ef4ea0170d61c263c26c32f13398a2ec348a /static | |
| parent | 5c3cc8966834a0d140f82aa178ba26109f79dd8f (diff) | |
| download | abridge-940b40688a7cf595eee061b696187e2fe4a578e2.tar.gz abridge-940b40688a7cf595eee061b696187e2fe4a578e2.tar.bz2 abridge-940b40688a7cf595eee061b696187e2fe4a578e2.zip | |
Json-Index and config.toml optional
Diffstat (limited to 'static')
| -rw-r--r-- | static/font/Roboto-Mono-Italic.woff2 | bin | 0 -> 13572 bytes | |||
| -rw-r--r-- | static/font/Roboto-Mono.woff2 | bin | 0 -> 12312 bytes | |||
| -rw-r--r-- | static/search.js | 20 |
3 files changed, 17 insertions, 3 deletions
diff --git a/static/font/Roboto-Mono-Italic.woff2 b/static/font/Roboto-Mono-Italic.woff2 Binary files differnew file mode 100644 index 0000000..ece53bd --- /dev/null +++ b/static/font/Roboto-Mono-Italic.woff2 diff --git a/static/font/Roboto-Mono.woff2 b/static/font/Roboto-Mono.woff2 Binary files differnew file mode 100644 index 0000000..f8894ba --- /dev/null +++ b/static/font/Roboto-Mono.woff2 diff --git a/static/search.js b/static/search.js index 61c67c0..e6adedf 100644 --- a/static/search.js +++ b/static/search.js @@ -165,11 +165,24 @@ Source: - https://github.com/aaranxu/adidoks/blob/main/static/js/search.js */ (function(){ - var index = elasticlunr.Index.load(window.searchIndex); + //var index = elasticlunr.Index.load(window.searchIndex); + var index; searchinput.addEventListener('input', show_results, true); suggestions.addEventListener('click', accept_suggestion, true); - function show_results(){ + async function show_results(){ + var initIndex = async function () { + if (index === undefined) { + index = fetch("/search_index.en.json") + .then( + async function(response) { + return await elasticlunr.Index.load(await response.json()); + } + ); + } + let res = await index; + return res; + } var value = this.value.trim(); var options = { bool: "OR", @@ -178,7 +191,8 @@ Source: body: {boost: 1}, } }; - var results = index.search(value, options); + //var results = index.search(value, options); + var results = (await initIndex()).search(value, options); var entry, childs = suggestions.childNodes; var i = 0, len = results.length; |
