diff options
Diffstat (limited to 'static/js/search_tinysearch.min.js')
| -rw-r--r-- | static/js/search_tinysearch.min.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/static/js/search_tinysearch.min.js b/static/js/search_tinysearch.min.js index 08cbe19..a3516db 100644 --- a/static/js/search_tinysearch.min.js +++ b/static/js/search_tinysearch.min.js @@ -1 +1 @@ -function closeSearchNow(){document.querySelector("main").innerHTML=window.main}function goSearchNow(){var e=document.querySelector("main"),t=(window.main||(window.main=e.innerHTML),document.getElementById("suggestions")),n=t.cloneNode(!0),o=(n.id="results",document.createElement("div")),a='<form name="closeSearch"><h2><button type="submit" title="Close Search"><i class="svgs x"></i></button> <i class="svgs search"></i> '.concat(document.getElementById("searchinput").value,"</h2></form>");return o.innerHTML=a,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){closeSearchNow()}),!1}async function lazyLoad(){var e=document.querySelector("meta[name='base']").getAttribute("content");await init((e="/"==e.slice(-1)?e.slice(0,-1):e)+"/tinysearch_engine_bg.wasm")}function closeAllLists(e){for(var t=document.getElementById("suggestions");t.firstChild;)t.removeChild(t.firstChild)}function markTerm(e,t){return e.replace(RegExp("(^|)("+t+")(|$)","ig"),"$1<mark><b>$2</b></mark>$3")}function autocomplete(e){e.addEventListener("input",function(e){var t=this.value;if(closeAllLists(),!t)return!1;for(var n=document.getElementById("suggestions"),o=search(t,99),a=0;a<o.length;a++){var c,r,i,s,u=o[a];(s=document.createElement("DIV")).innerHTML="<a href><span></span><span></span></a>",c=s.querySelector("a"),r=s.querySelector("span:first-child"),i=s.querySelector("span:nth-child(2)"),c.href=u[1]+"?q="+encodeURIComponent(t),r.innerHTML=markTerm(u[0],t),i.innerHTML=markTerm(u[2],t),n.appendChild(s)}})}function suggestionFocus(t){191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),searchinput.focus(),suggestions.classList.remove("d-none")),27===t.keyCode&&(searchinput.blur(),suggestions.classList.add("d-none"),closeAllLists());var n=suggestions.querySelectorAll("a");if(!suggestions.classList.contains("d-none")&&0!==n.length){var o=[...n],a=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0<a?a-1:0].focus()):40===t.keyCode&&(t.preventDefault(),n[e=1+a<o.length?1+a:a].focus())}}function getUint8Memory0(){return cachegetUint8Memory0=null!==cachegetUint8Memory0&&cachegetUint8Memory0.buffer===wasm.memory.buffer?cachegetUint8Memory0:new Uint8Array(wasm.memory.buffer)}function getStringFromWasm0(e,t){return cachedTextDecoder.decode(getUint8Memory0().subarray(e,e+t))}function addHeapObject(e){heap_next===heap.length&&heap.push(heap.length+1);var t=heap_next;return heap_next=heap[t],heap[t]=e,t}function passStringToWasm0(n,o,t){if(void 0===t){let e=cachedTextEncoder.encode(n),t=o(e.length);return getUint8Memory0().subarray(t,t+e.length).set(e),WASM_VECTOR_LEN=e.length,t}let a=n.length,c=o(a);var r=getUint8Memory0();let i=0;for(;i<a;i++){let e=n.charCodeAt(i);if(127<e)break;r[c+i]=e}if(i!==a){0!==i&&(n=n.slice(i)),c=t(c,a,a=i+3*n.length);let e=getUint8Memory0().subarray(c+i,c+a);i+=encodeString(n,e).written}return WASM_VECTOR_LEN=i,c}function getObject(e){return heap[e]}function dropObject(e){e<36||(heap[e]=heap_next,heap_next=e)}function takeObject(e){var t=getObject(e);return dropObject(e),t}function search(e,t){var e=passStringToWasm0(e,wasm.__wbindgen_malloc,wasm.__wbindgen_realloc),n=WASM_VECTOR_LEN;return takeObject(wasm.search(e,n,t))}async function load(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t}var n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}return(n=await WebAssembly.instantiate(e,t))instanceof WebAssembly.Instance?{instance:n,module:e}:n}async function init(e){var t=document.querySelector("meta[name='base']").getAttribute("content"),t=("/"==t.slice(-1)&&(t=t.slice(0,-1)),void 0===e&&(e=new URL(t+"/tinysearch_engine_bg.wasm")),{wbg:{}}),{instance:e,module:t}=(t.wbg.__wbindgen_json_parse=function(e,t){return addHeapObject(JSON.parse(getStringFromWasm0(e,t)))},await load(await(e="string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL?fetch(e):e),t));return wasm=e.exports,init.__wbindgen_wasm_module=t,wasm}var loaded=!1,searchinput=(window.onload=function(){document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()}),document.getElementById("searchinput").onfocus=function(){loaded||(lazyLoad(),loaded=!0,document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()})),document.getElementById("searchinput").onfocus=""}},document.getElementById("searchinput"));document.addEventListener("keydown",suggestionFocus);let wasm,cachedTextDecoder=(autocomplete(document.getElementById("searchinput")),new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0})),cachegetUint8Memory0=(cachedTextDecoder.decode(),null),heap=Array(32).fill(void 0),heap_next=(heap.push(void 0,null,!0,!1),heap.length),WASM_VECTOR_LEN=0,cachedTextEncoder=new TextEncoder("utf-8"),encodeString="function"==typeof cachedTextEncoder.encodeInto?function(e,t){return cachedTextEncoder.encodeInto(e,t)}:function(e,t){var n=cachedTextEncoder.encode(e);return t.set(n),{read:e.length,written:n.length}};
\ No newline at end of file +window.onload=function(){if(document.body.contains(document.goSearch)){document.goSearch.onsubmit=function(){return goSearchNow()};{function n(){var e=document.querySelector("main"),n=(window.main||(window.main=e.innerHTML),document.getElementById("suggestions")),t=n.cloneNode(!0),o=(t.id="results",document.createElement("div")),r='<form name="closeSearch"><h2><button type="submit" title="Close Search"><i class="svgs x"></i></button> <i class="svgs search"></i> '.concat(document.getElementById("searchinput").value,"</h2></form>");return o.innerHTML=r,t.insertBefore(o,t.firstChild),e.innerHTML=t.outerHTML,n.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function v(){for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}function w(){return e=null!==e&&e.buffer===f.memory.buffer?e:new Uint8Array(f.memory.buffer)}async function o(e){var n=document.querySelector("meta[name='base']").getAttribute("content"),n=("/"==n.slice(-1)&&(n=n.slice(0,-1)),void 0===e&&(e=new URL(n+"/tinysearch_engine_bg.wasm")),{wbg:{}}),{instance:e,module:n}=(n.wbg.__wbindgen_json_parse=function(e,n){return e=JSON.parse((e=e,n=n,t.decode(w().subarray(e,e+n)))),h===g.length&&g.push(g.length+1),n=h,h=g[n],g[n]=e,n},await async function(e,n){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,n)}catch(n){if("application/wasm"==e.headers.get("Content-Type"))throw n}var t=await e.arrayBuffer();return WebAssembly.instantiate(t,n)}return(t=await WebAssembly.instantiate(e,n))instanceof WebAssembly.Instance?{instance:t,module:e}:t}(await(e="string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL?fetch(e):e),n));return f=e.exports,o.__wbindgen_wasm_module=n,f}var i=document.getElementById("searchinput"),r=(document.addEventListener("keydown",function(n){191===n.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(n.preventDefault(),i.focus(),suggestions.classList.remove("d-none")),27===n.keyCode&&(i.blur(),suggestions.classList.add("d-none"),v());var t=suggestions.querySelectorAll("a");if(!suggestions.classList.contains("d-none")&&0!==t.length){var o=[...t],r=o.indexOf(document.activeElement);let e=0;38===n.keyCode?(n.preventDefault(),t[e=0<r?r-1:0].focus()):40===n.keyCode&&(n.preventDefault(),t[e=1+r<o.length?1+r:r].focus())}}),!1);document.getElementById("searchinput").onfocus=function(){r||(!async function(){var e=document.querySelector("meta[name='base']").getAttribute("content");await o((e="/"==e.slice(-1)?e.slice(0,-1):e)+"/tinysearch_engine_bg.wasm")}(),r=!0),document.getElementById("searchinput").onfocus=""};let f,t=(document.getElementById("searchinput").addEventListener("input",function(e){var n=this.value;if(v(),!n)return!1;for(var t,o,r,i=document.getElementById("suggestions"),a=(o=99,t=function(t,o,n){if(void 0===n){let e=b.encode(t),n=o(e.length);return w().subarray(n,n+e.length).set(e),y=e.length,n}let r=t.length,i=o(r),a=w(),c=0;for(;c<r;c++){let e=t.charCodeAt(c);if(127<e)break;a[i+c]=e}if(c!==r){0!==c&&(t=t.slice(c)),i=n(i,r,r=c+3*t.length);let e=w().subarray(i+c,i+r);c+=p(t,e).written}return y=c,i}(t=n,f.__wbindgen_malloc,f.__wbindgen_realloc),r=y,function(e){var n=function(e){return g[e]}(e);return function(e){e<36||(g[e]=h,h=e)}(e),n}(f.search(t,r,o))),c=0;c<a.length;c++){var s,u,l,d,m=a[c];(d=document.createElement("DIV")).innerHTML="<a href><span></span><span></span></a>",s=d.querySelector("a"),u=d.querySelector("span:first-child"),l=d.querySelector("span:nth-child(2)"),s.href=m[1]+"?q="+encodeURIComponent(n),u.innerHTML=m[0],l.innerHTML=m[2].replace(RegExp("(^|)("+n+")(|$)","ig"),"$1<mark>$2</mark>$3"),i.appendChild(d)}}),new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0})),e=(t.decode(),null),g=Array(32).fill(void 0),h=(g.push(void 0,null,!0,!1),g.length),y=0,b=new TextEncoder("utf-8"),p="function"==typeof b.encodeInto?function(e,n){return b.encodeInto(e,n)}:function(e,n){var t=b.encode(e);return n.set(t),{read:e.length,written:t.length}};document.goSearch.onsubmit=n}}};
\ No newline at end of file |
