From 6dcec618d0ff0a2270f787f62267a0622275c69d Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 22 May 2023 22:37:44 -0700 Subject: Load Tinysearch/Stork On Demand --- static/search_tinysearch.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 static/search_tinysearch.min.js (limited to 'static/search_tinysearch.min.js') diff --git a/static/search_tinysearch.min.js b/static/search_tinysearch.min.js new file mode 100644 index 0000000..7630be3 --- /dev/null +++ b/static/search_tinysearch.min.js @@ -0,0 +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='

Results For: '.concat(document.getElementById("searchinput").value,"

");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}var loaded=!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(new RegExp("(^|)("+t+")(|$)","ig"),"$1$2$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",r=s.querySelector("a"),c=s.querySelector("span:first-child"),i=s.querySelector("span:nth-child(2)"),r.href=u[1]+"?q="+encodeURIComponent(t),c.innerHTML=markTerm(u[0],t),i.innerHTML=markTerm(u[2],t),n.appendChild(s)}})}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=""}};var searchinput=document.getElementById("searchinput");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