/*! * Simple-Jekyll-Search * Copyright 2015-2020, Christian Fei * Licensed under the MIT License. */ String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var r,n if(null==this)throw new TypeError(" this is null or not defined") var i=Object(this),o=i.length>>>0 if("function"!=typeof t)throw new TypeError(t+" is not a function") for(arguments.length>1&&(r=e),n=0;o>n;){var u n in i&&(u=i[n],t.call(r,u,n,i)),n++}}),Array.prototype.filter||(Array.prototype.filter=function(t,e){if("Function"!=typeof t&&"function"!=typeof t||!this)throw new TypeError var r=this.length>>>0,n=Array(r),i=this,o=0,u=-1 if(void 0===e)for(;++u!==r;)u in this&&t(i[u],u,i)&&(n[o++]=i[u]) else for(;++u!==r;)u in this&&t.call(e,i[u],u,i)&&(n[o++]=i[u]) return n.length=o,n}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var r if(null==this)throw new TypeError('"this" is null or not defined') var n=Object(this),i=n.length>>>0 if(0===i)return-1 var o=+e||0 if(Math.abs(o)===1/0&&(o=0),o>=i)return-1 for(r=Math.max(o>=0?o:i-Math.abs(o),0);i>r;){if(r in n&&n[r]===t)return r r++}return-1}),Object.prototype.toString||(Object.prototype.toString=function(){return"[object "+(this===window?"Window":this===document?"Document":"Object")+"]"}),function(){function t(t){j.pattern=t.pattern||j.pattern,j.template=t.template||j.template,"function"==typeof t.middleware&&(j.middleware=t.middleware)}function e(t){return j.template.replace(j.pattern,function(e,r){var n=j.middleware(r,t[r],j.template) return void 0!==n?n:t[r]||e})}function r(t,e){var r=e.length,n=t.length if(n>r)return!1 if(n===r)return t===e t:for(var i=0,o=0;n>i;i++){for(var u=t.charCodeAt(i);r>o;)if(e.charCodeAt(o++)===u)continue t return!1}return!0}function n(){this.matches=function(t,e){return T(e.toLowerCase(),t.toLowerCase())}}function i(){this.matches=function(t,e){if(!t)return!1 t=t.trim().toLowerCase(),e=e.trim().toLowerCase() for(var r=e.split(" "),n=!0,i=0;ir;r++)c(t[r])&&e.push(f(t[r])) return e}function p(t){return t?d(A,t,M.searchStrategy,M).sort(M.sort):[]}function h(t){M=t||{},M.fuzzy=t.fuzzy||!1,M.limit=t.limit||10,M.searchStrategy=t.fuzzy?x:E,M.sort=t.sort||o,M.exclude=t.exclude||[]}function d(t,e,r,n){for(var i=[],o=0;or;r++){var i=e[r] if(RegExp(i).test(t))return!0}return!1}function m(t,e){var r=g() r.open("GET",t,!0),r.onreadystatechange=w(r,e),r.send()}function w(t,e){return function(){if(4===t.readyState&&200===t.status)try{e(null,JSON.parse(t.responseText))}catch(r){e(r,null)}}}function g(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")}function O(t,e){var r={} for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n],void 0!==e[n]&&(r[n]=e[n])) return r}function S(t){try{return t instanceof Object&&JSON.parse(JSON.stringify(t))?!0:!1}catch(e){return!1}}var b={compile:e,setOptions:t},j={} j.pattern=/\{(.*?)\}/g,j.template="",j.middleware=function(){} var T=r,x=new n,E=new i,z={put:u,clear:a,search:p,setOptions:h},A=[],M={} M.fuzzy=!1,M.limit=10,M.searchStrategy=M.fuzzy?x:E,M.sort=o,M.exclude=[] var L={load:m},q=function F(t){function e(t){return t?void 0!==t.required&&t.required instanceof Array:!1}if(!e(t))throw Error("-- OptionsValidator: required options missing") if(!(this instanceof F))return new F(t) var r=t.required this.getRequiredOptions=function(){return r},this.validate=function(t){for(var e=[],n=0;nn;n++)t[n].query=e,i(b.compile(t[n]))}function c(t){return t&&t.length>0}function s(t){for(var e=[13,16,20,37,38,39,40,91],r=0;r{title}',templateMiddleware:Function.prototype,sortMiddleware:function(){return 0},noResultsText:"No results found",limit:10,fuzzy:!1,debounceTime:null,exclude:[]},h=function(t,e){e?(clearTimeout(l),l=setTimeout(t,e)):t.call()},d=["searchInput","resultsContainer","json"],y=q({required:d}) t.SimpleJekyllSearch=function(t){var n=y.validate(t) n.length>0&&f("You must specify the following required options: "+d),p=C.merge(p,t),b.setOptions({template:p.searchResultTemplate,middleware:p.templateMiddleware}),z.setOptions({fuzzy:p.fuzzy,limit:p.limit,sort:p.sortMiddleware,exclude:p.exclude}),C.isJSON(p.json)?e(p.json):r(p.json) var i={search:u} return"function"==typeof p.success&&p.success.call(i),i}}(window)}()