hugo-theme-wondermod/assets/js/search.min.267e0e84eab2de9e84bc800ae7bab555bc482e82cbf8eed3251743057f6d59b9.js

9 lines
16 KiB
JavaScript
Raw Normal View History

var e,t;e=this,t=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function h(e){return Array.isArray?Array.isArray(e):"[object Array]"===y(e)}function u(e){return"string"==typeof e}function l(e){return"number"==typeof e}function d(t){return!0===t||!1===t||function(t){return function(t){return"object"===e(t)}(t)&&null!==t}(t)&&"[object Boolean]"==y(t)}function f(e){return null!=e}function v(e){return!e.trim().length}function y(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var g=function(e){return"Pattern length exceeds max of ".concat(e,".")},p=Object.prototype.hasOwnProperty,m=function(){function e(n){var r=this;t(this,e),this._keys=[],this._keyMap={};var i=0;n.forEach((function(e){var t=b(e);i+=t.weight,r._keys.push(t),r._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return r(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function b(e){var t=null,n=null,r=null,i=1;if(u(e)||h(e))r=e,t=k(e),n=M(e);else{if(!p.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));var o=e.name;if(r=o,p.call(e,"weight")&&(i=e.weight)<=0)throw new Error(function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")}(o));t=k(o),n=M(o)}return{path:t,id:n,weight:i,src:r}}function k(e){return h(e)?e:e.split(".")}function M(e){return h(e)?e.join("."):e}var x=a({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}},{},{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},{},{location:0,threshold:.6,distance:100},{},{useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(f(t))if(i[o]){var a=t[i[o]];if(!f(a))return;if(o===i.length-1&&(u(a)||l(a)||d(a)))n.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(a));else if(h(a)){r=!0;for(var c=0,s=a.length;c<s;c+=1)e(a
var resultsAvailable=false;function loadSearch(){var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState===4){if(xhr.status===200){var data=JSON.parse(xhr.responseText);if(data){var options={distance:100,threshold:0.4,ignoreLocation:true,keys:['title','permalink','summary','content']};fuse=new Fuse(data,options);}}else{console.log(xhr.responseText);}}};xhr.open('GET',"../index.json");xhr.send();}
function itemGen(name,link){return `<li class="post-entry"><header class="entry-header">${name}&nbsp;»</header><a href="${link}" aria-label="${name}"></a></li>`}
function activeToggle(){document.activeElement.parentElement.classList.toggle("active")}
sInput.onkeyup=function(e){const results=fuse.search(this.value.trim());if(results.length!==0){let resultSet='';for(let item in results){resultSet=resultSet+itemGen(results[item].item.title,results[item].item.permalink)}
document.getElementById("searchResults").innerHTML=resultSet;resultsAvailable=true;first=resList.firstChild;last=resList.lastChild;}else{resultsAvailable=false;document.getElementById("searchResults").innerHTML='';}}
document.onkeydown=function(e){let key=e.key;let ae=document.activeElement;let inbox=document.getElementById("searchbox").contains(ae)
if(ae===sInput){var elements=document.getElementsByClassName('active');while(elements.length>0){elements[0].classList.remove('active');}}
if(key==="ArrowDown"&&resultsAvailable&&inbox){e.preventDefault();if(ae==sInput){activeToggle();resList.firstChild.lastChild.focus();activeToggle();}else if(ae.parentElement==last){}else{activeToggle();ae.parentElement.nextSibling.lastChild.focus();activeToggle();}}else if(key==="ArrowUp"&&resultsAvailable&&inbox){e.preventDefault();if(ae==sInput){}else if(ae.parentElement==first){activeToggle();sInput.focus();}else{activeToggle();ae.parentElement.previousSibling.lastChild.focus();activeToggle();}}else if(key==="ArrowRight"&&resultsAvailable&&inbox){ae.click();}else if(key==="Escape"){resultsAvailable=false;resList.innerHTML=sInput.value='';sInput.focus();}}