-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 1.7 KB
/
index.js
1
function isat_ac(e,t,n,o,r,c){var i=-1,l=t,a=[];let u=!1;function d(e,t,n){e!=t-1&&"down"==n&&i++,0!=e&&"up"==n&&i--}function s(e,t){if(0!=t.length){for(var n in a=[],e){var o=e[n],r={};for(var c in t)for(var i in o)i==t[c]&&(r[t[c]]=o[i]);a.push(r)}e=a}a=e}!function(t,p){document.addEventListener("click",function(e){let t=r.root,n=r.selector,i=-1;var d=getClosest(e.target,n);if(null!=d){var p=d.parentNode,f=p.children;if(d.parentNode.getAttribute("id")==t||d.parentNode.parentNode.getAttribute("id")==t||d.parentNode.getAttribute("class")==t||d.parentNode.parentNode.getAttribute("class")==t)for(var h=0;h<f.length;h++)f[h]===d&&(i=h)}-1!=i&&null!=i&&"undefined"!=i&&(s(l,c),o("click",i,a,l,u))}),t.addEventListener("input",function(){var e=this.value;i=-1,s(l=p.filter(function(t){return n(t,e)}),c),o("search",i,a,l,u)}),s(l,c),o("begin",i,a,l,u),e.onblur=function(){o("any",i,a,l,u=!1)},e.onfocus=function(){o("any",i,a,l,u=!0)},document.addEventListener("click",function(){s(l,c)}),t.addEventListener("keydown",function(e){40==e.which?(d(i,a.length,"down"),0!=a.length&&(s(l,c),o("down",i,a,l,u))):38==e.keyCode?0!=a.length&&i>-1&&(d(i,a.length,"up"),s(l,c),o("up",i,a,l,u)):13==e.keyCode&&(e.preventDefault(),0!=a.length&&(s(l,c),o("enter",i,a,l,u)))})}(e,t)}var getClosest=function(e,t){for(Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;)return n>-1});e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null};