summaryrefslogtreecommitdiff
path: root/exampleSite/resources/_gen/assets/js
diff options
context:
space:
mode:
authorAlex Shpak <alex-shpak@users.noreply.github.com>2019-07-15 18:25:21 +0200
committerAlex Shpak <alex-shpak@users.noreply.github.com>2019-08-06 11:33:42 +0200
commitdda0a0eab19457598b71f2b2b2f978b09d3f95c7 (patch)
tree035ca254fe7a8c7c7df316bce0b777f9a9dd06fe /exampleSite/resources/_gen/assets/js
parentb199d72e5fd7ec76b3c17fc9a6368868978d6328 (diff)
Start work on search feature with lunr
Diffstat (limited to 'exampleSite/resources/_gen/assets/js')
-rw-r--r--exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content6
-rw-r--r--exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json1
2 files changed, 7 insertions, 0 deletions
diff --git a/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content
new file mode 100644
index 0000000..9c34794
--- /dev/null
+++ b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content
@@ -0,0 +1,6 @@
+addEventListener("load",function(){let input=document.querySelector("#book-search");let results=document.querySelector("#book-search-results");Promise.all([loadScript("/example/lunr.min.js"),loadScript("/example/index.json")]).then(enableLunr);function enableLunr(){results.idx=lunr(function(){this.ref('href')
+this.field('title')
+this.field('content')
+window.lunrData.forEach(function(page){this.add(page)},this)});input.addEventListener("keyup",search);}
+function search(){if(input.value){var hits=results.idx.search(`${input.value}*`);results.innerHTML=JSON.stringify(hits);}else{results.innerHTML='';}}
+function loadScript(src){return new Promise(function(resolve,reject){let script=document.createElement('script');script.src=src;script.onload=()=>resolve(script);document.head.append(script);});}}); \ No newline at end of file
diff --git a/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json
new file mode 100644
index 0000000..0c68ef7
--- /dev/null
+++ b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json
@@ -0,0 +1 @@
+{"Target":"search.min.f37565c4baa28364f7b8e1e53c35bdb0ab92f2215165bd3f083f3f4f1ae78c71.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-83VlxLqig2T3uOHlPDW9sKuS8iFRZb0/CD8/TxrnjHE="}} \ No newline at end of file