diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/js/abridge.min.js | 2 | ||||
| -rw-r--r-- | static/js/abridge_nopwa.min.js | 2 | ||||
| -rw-r--r-- | static/js/abridge_nosearch.min.js | 2 | ||||
| -rw-r--r-- | static/js/abridge_nosearch_nopwa.min.js | 2 | ||||
| -rw-r--r-- | static/js/codecopy.js | 23 | ||||
| -rw-r--r-- | static/js/search_tinysearch.min.js | 2 | ||||
| -rw-r--r-- | static/js/tinysearch.js | 350 | ||||
| -rw-r--r-- | static/sw.js | 382 | ||||
| -rw-r--r-- | static/sw.min.js | 2 | ||||
| -rw-r--r-- | static/tinysearch.toml | 4 | ||||
| -rwxr-xr-x | static/tinysearch_engine.wasm | bin | 0 -> 94942 bytes | |||
| -rw-r--r-- | static/tinysearch_engine_bg.wasm | bin | 97522 -> 0 bytes |
12 files changed, 390 insertions, 381 deletions
diff --git a/static/js/abridge.min.js b/static/js/abridge.min.js index 003dc31..a9d097a 100644 --- a/static/js/abridge.min.js +++ b/static/js/abridge.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var l,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,k,L,_,N,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i<n;i++){for(var r=e[i],s=0;s<o&&null!=(r=this._queue[s](r,i,e));s++);null!=r&&t.push(r)}return t},g.Pipeline.prototype.reset=function(){this._queue=[]},g.Pipeline.prototype.get=function(){return this._queue},g.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return g.Pipeline.warnIfFunctionNotRegistered(e),e.label})},(g.Index=function(){this._fields=[],this._ref="id",this.pipeline=new g.Pipeline,this.documentStore=new g.DocumentStore,this.index={},this.eventEmitter=new g.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))}).prototype.on=function(){var e=[].slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},g.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},g.Index.load=function(e){e.version!==g.version&&g.utils.warn("version mismatch: current "+g.version+" importing "+e.version);var t,n=new this;for(t in n._fields=e.fields,n._ref=e.ref,n.documentStore=g.DocumentStore.load(e.documentStore),n.pipeline=g.Pipeline.load(e.pipeline),n.index={},e.index)n.index[t]=g.InvertedIndex.load(e.index[t]);return n},g.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new g.InvertedIndex,this},g.Index.prototype.setRef=function(e){return this._ref=e,this},g.Index.prototype.saveDocument=function(e){return this.documentStore=new g.DocumentStore(e),this},g.Index.prototype.addDoc=function(i,e){var r;i&&(e=void 0===e||e,r=i[this._ref],this.documentStore.addDoc(r,i),this._fields.forEach(function(e){var t,n=this.pipeline.run(g.tokenizer(i[e])),o=(this.documentStore.addFieldLength(r,e,n.length),{});for(t in n.forEach(function(e){e in o?o[e]+=1:o[e]=1},this),o)this.index[e].addToken(t,{ref:r,tf:Math.sqrt(o[t])})},this),e)&&this.eventEmitter.emit("add",i,this)},g.Index.prototype.removeDocByRef=function(e){e&&!1!==this.documentStore.isDocStored()&&this.documentStore.hasDoc(e)&&(e=this.documentStore.getDoc(e),this.removeDoc(e,!1))},g.Index.prototype.removeDoc=function(e,t){var n;e&&(t=void 0===t||t,n=e[this._ref],this.documentStore.hasDoc(n))&&(this.documentStore.removeDoc(n),this._fields.forEach(function(t){this.pipeline.run(g.tokenizer(e[t])).forEach(function(e){this.index[t].removeToken(e,n)},this)},this),t)&&this.eventEmitter.emit("remove",e,this)},g.Index.prototype.updateDoc=function(e,t){t=void 0===t||t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},g.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;return{}.hasOwnProperty.call(this._idfCache,n)?this._idfCache[n]:(t=this.index[t].getDocFreq(e),e=1+Math.log(this.documentStore.length/(t+1)),this._idfCache[n]=e)},g.Index.prototype.getFields=function(){return this._fields.slice()},g.Index.prototype.search=function(e,t){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var n=null;null!=t&&(n=JSON.stringify(t));for(var o=new g.Configuration(n,this.getFields()).get(),i={},r=Object.keys(e),s=0;s<r.length;s++){var u=r[s];i[u]=this.pipeline.run(g.tokenizer(e[u]))}var a,l={};for(a in o){var c=i[a]||i.any;if(c){var d=this.fieldSearch(c,a,o),h=o[a].boost;for(p in d)d[p]=d[p]*h;for(p in d)p in l?l[p]+=d[p]:l[p]=d[p]}}var f,p,m=[];for(p in l)f={ref:p,score:l[p]},this.documentStore.hasDoc(p)&&(f.doc=this.documentStore.getDoc(p)),m.push(f);return m.sort(function(e,t){return t.score-e.score}),m},g.Index.prototype.fieldSearch=function(e,d,t){var h=t[d].bool,n=t[d].expand,t=t[d].boost,f=null,p={};return 0!==t?(e.forEach(function(l){var e=[l],c=(1==n&&(e=this.index[d].expandToken(l)),{});e.forEach(function(e){var t=this.index[d].getDocs(e),n=this.idf(e,d);if(f&&"AND"==h){var o,i={};for(o in f)o in t&&(i[o]=t[o]);t=i}for(o in e==l&&this.fieldSearchStats(p,e,t),t){var r=this.index[d].getTermFrequency(e,o),s=this.documentStore.getFieldLength(o,d),u=1,a=1,r=r*n*(u=0!=s?1/Math.sqrt(s):u)*(a=e!=l?.15*(1-(e.length-l.length)/e.length):a);o in c?c[o]+=r:c[o]=r}},this),f=this.mergeScores(f,c,h)},this),f=this.coordNorm(f,p,e.length)):void 0},g.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var o={};for(i in t)i in e&&(o[i]=e[i]+t[i]);return o}for(var i in t)i in e?e[i]+=t[i]:e[i]=t[i];return e},g.Index.prototype.fieldSearchStats=function(e,t,n){for(var o in n)o in e?e[o].push(t):e[o]=[t]},g.Index.prototype.coordNorm=function(e,t,n){for(var o in e){var i;o in t&&(i=t[o].length,e[o]=e[o]*i/n)}return e},g.Index.prototype.toJSON=function(){var t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:g.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},g.Index.prototype.use=function(e){var t=[].slice.call(arguments,1);t.unshift(this),e.apply(this,t)},(g.DocumentStore=function(e){this._save=null==e||e,this.docs={},this.docInfo={},this.length=0}).load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},g.DocumentStore.prototype.isDocStored=function(){return this._save},g.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,this.docs[e]=!0===this._save?(e=>{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},l={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,C=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,D=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,L=/^(.+?)e$/,_=/ll$/,N=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,a;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(a=r.exec(e),(r=d).test(a[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(a=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(a=r.exec(e))[1])+"i"),(r=C).test(e)&&(s=(a=r.exec(e))[1],t=a[2],(r=d).test(s))&&(e=s+l[t]),(r=D).test(e)&&(s=(a=r.exec(e))[1],t=a[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=F).test(e)?(s=(a=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(a=u.exec(e))[1]+a[2],(u=h).test(s))&&(e=s),(r=L).test(e)&&(s=(a=r.exec(e))[1],u=f,o=N,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=_).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},g.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},g.InvertedIndex.prototype.getDocs=function(e){e=this.getNode(e);return null==e?{}:e.docs},g.InvertedIndex.prototype.getTermFrequency=function(e,t){e=this.getNode(e);return null!=e&&t in e.docs?e.docs[t].tf:0},g.InvertedIndex.prototype.getDocFreq=function(e){e=this.getNode(e);return null==e?0:e.df},g.InvertedIndex.prototype.removeToken=function(e,t){e&&null!=(e=this.getNode(e))&&t in e.docs&&(delete e.docs[t],--e.df)},g.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];t=t||[];if(null!=n||null!=(n=this.getNode(e)))for(var o in 0<n.df&&t.push(e),n)"docs"!==o&&"df"!==o&&this.expandToken(e+o,t,n[o]);return t},g.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},(g.Configuration=function(e,t){var n,e=e||"";if(null==t)throw Error("fields should not be null");this.config={};try{n=JSON.parse(e),this.buildUserConfig(n,t)}catch(e){g.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(t)}}).prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},g.Configuration.prototype.buildUserConfig=function(e,t){var n,o,i="OR",r=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(r=e.expand||r),"fields"in e)for(var s in e.fields)~t.indexOf(s)?(o=r,null!=(n=e.fields[s]).expand&&(o=n.expand),this.config[s]={boost:n.boost||0===n.boost?n.boost:1,bool:n.bool||i,expand:o}):g.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,r,t)},g.Configuration.prototype.addAllFields2UserConfig=function(t,n,e){e.forEach(function(e){this.config[e]={boost:1,bool:t,expand:n}},this)},g.Configuration.prototype.get=function(){return this.config},g.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){for(var e,t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;){if(r===e)return i;r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;)r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)];return e<r?i:r<e?i+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,o=0,i=this.length,r=e.length,s=this.elements,u=e.elements;i-1>=n&&r-1>=o;)s[n]!==u[o]?s[n]<u[o]?n++:s[n]>u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length<e.length?(t=e,this):(t=this,e),n=t.clone(),o=0,i=e.toArray();o<i.length;o++)n.add(i[o]);return n},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},t=this,e=function(){return g},"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=g:t.elasticlunr=g}(),window.onload=function(){function e(){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")),i='<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=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0<i?i-1:0].focus()):40===t.keyCode&&(t.preventDefault(),n[e=1+i<o.length?1+i:i].focus())}}),document.addEventListener("click",function(e){u.contains(e.target)||u.classList.add("d-none")}),c=document.documentElement.getAttribute("lang").substring(0,2),"/"==(h=document.querySelector("meta[name='base']").getAttribute("content")).slice(-1)&&(h=h.slice(0,-1)),r.addEventListener("input",async function(){var n,e=this.value.trim(),o=(await(l=void 0===l?fetch(h+"/search_index."+c+".json").then(async function(e){return elasticlunr.Index.load(await e.json())}):l)).search(e,{bool:"OR",fields:{title:{boost:2},body:{boost:1}}}),i=u.childNodes,r=o.length,s=e.split(/\s+/);for(u.classList.remove("d-none"),o.forEach(function(e){""!==e.doc.body&&((n=document.createElement("div")).innerHTML="<a href><span></span><span></span></a>",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,a=s[p].split(/[\s\n]/),l=8;for(u in a){if(0<(v=a[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(l=40,o=!0);r.push([v,l,i]),l=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300<e.length?e.substring(0,300)+"...":e;for(var d=[],h=Math.min(r.length,30),f=0,p=0;p<h;p++)f+=r[p][1];for(d.push(f),p=0;p<r.length-h;p++)f=(f-=r[p][1])+r[p+h][1],d.push(f);var m=0;if(o)for(var g=0,p=d.length-1;0<=p;p--)g<d[p]&&(g=d[p],m=p);for(var v,y,S=[],x=r[m][2],p=m;p<m+h;p++){x<(v=r[p])[2]&&(S.push(e.substring(x,v[2])),x=v[2]),40===v[1]&&S.push("<mark>"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u<e.length;u++){var a=e.codePointAt(u).toString(16);if(o=4<a.length&&++u+1<e.length?"200d"==e.codePointAt(u+1).toString(16):o){if(i+=b(a),u==e.length-1){if(t<(r+=i))break;n+=e.substr(s,u-s+1)}}else if(0!=i){if(r=(r+=i)+b(a),t<r)break;n+=e.substr(s,u-s+1),s=u+1,i=0}else{if(r+=b(a),t<r)break;4<a.length?n+=e[u-1]+e[u]:n+=e[u],s=u+1}}return n})(e.substring(v[2],x),12),S.push(y)),40===v[1]&&S.push("</mark>")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)},"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.12.1",{scope:"/"}).then(()=>{},e=>{}),navigator.serviceWorker.ready.then(()=>{}));
\ No newline at end of file +let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=getCodeContent(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getCodeContent=e=>[...e.querySelectorAll(".giallo-l")].map(e=>{var e=e.cloneNode(!0),t=e.querySelector(".giallo-ln");return t&&t.remove(),e.textContent}).join("\n");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var l,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,k,L,_,N,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i<n;i++){for(var r=e[i],s=0;s<o&&null!=(r=this._queue[s](r,i,e));s++);null!=r&&t.push(r)}return t},g.Pipeline.prototype.reset=function(){this._queue=[]},g.Pipeline.prototype.get=function(){return this._queue},g.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return g.Pipeline.warnIfFunctionNotRegistered(e),e.label})},(g.Index=function(){this._fields=[],this._ref="id",this.pipeline=new g.Pipeline,this.documentStore=new g.DocumentStore,this.index={},this.eventEmitter=new g.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))}).prototype.on=function(){var e=[].slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},g.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},g.Index.load=function(e){e.version!==g.version&&g.utils.warn("version mismatch: current "+g.version+" importing "+e.version);var t,n=new this;for(t in n._fields=e.fields,n._ref=e.ref,n.documentStore=g.DocumentStore.load(e.documentStore),n.pipeline=g.Pipeline.load(e.pipeline),n.index={},e.index)n.index[t]=g.InvertedIndex.load(e.index[t]);return n},g.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new g.InvertedIndex,this},g.Index.prototype.setRef=function(e){return this._ref=e,this},g.Index.prototype.saveDocument=function(e){return this.documentStore=new g.DocumentStore(e),this},g.Index.prototype.addDoc=function(i,e){var r;i&&(e=void 0===e||e,r=i[this._ref],this.documentStore.addDoc(r,i),this._fields.forEach(function(e){var t,n=this.pipeline.run(g.tokenizer(i[e])),o=(this.documentStore.addFieldLength(r,e,n.length),{});for(t in n.forEach(function(e){e in o?o[e]+=1:o[e]=1},this),o)this.index[e].addToken(t,{ref:r,tf:Math.sqrt(o[t])})},this),e)&&this.eventEmitter.emit("add",i,this)},g.Index.prototype.removeDocByRef=function(e){e&&!1!==this.documentStore.isDocStored()&&this.documentStore.hasDoc(e)&&(e=this.documentStore.getDoc(e),this.removeDoc(e,!1))},g.Index.prototype.removeDoc=function(e,t){var n;e&&(t=void 0===t||t,n=e[this._ref],this.documentStore.hasDoc(n))&&(this.documentStore.removeDoc(n),this._fields.forEach(function(t){this.pipeline.run(g.tokenizer(e[t])).forEach(function(e){this.index[t].removeToken(e,n)},this)},this),t)&&this.eventEmitter.emit("remove",e,this)},g.Index.prototype.updateDoc=function(e,t){t=void 0===t||t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},g.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;return{}.hasOwnProperty.call(this._idfCache,n)?this._idfCache[n]:(t=this.index[t].getDocFreq(e),e=1+Math.log(this.documentStore.length/(t+1)),this._idfCache[n]=e)},g.Index.prototype.getFields=function(){return this._fields.slice()},g.Index.prototype.search=function(e,t){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var n=null;null!=t&&(n=JSON.stringify(t));for(var o=new g.Configuration(n,this.getFields()).get(),i={},r=Object.keys(e),s=0;s<r.length;s++){var u=r[s];i[u]=this.pipeline.run(g.tokenizer(e[u]))}var a,l={};for(a in o){var c=i[a]||i.any;if(c){var d=this.fieldSearch(c,a,o),h=o[a].boost;for(p in d)d[p]=d[p]*h;for(p in d)p in l?l[p]+=d[p]:l[p]=d[p]}}var f,p,m=[];for(p in l)f={ref:p,score:l[p]},this.documentStore.hasDoc(p)&&(f.doc=this.documentStore.getDoc(p)),m.push(f);return m.sort(function(e,t){return t.score-e.score}),m},g.Index.prototype.fieldSearch=function(e,d,t){var h=t[d].bool,n=t[d].expand,t=t[d].boost,f=null,p={};return 0!==t?(e.forEach(function(l){var e=[l],c=(1==n&&(e=this.index[d].expandToken(l)),{});e.forEach(function(e){var t=this.index[d].getDocs(e),n=this.idf(e,d);if(f&&"AND"==h){var o,i={};for(o in f)o in t&&(i[o]=t[o]);t=i}for(o in e==l&&this.fieldSearchStats(p,e,t),t){var r=this.index[d].getTermFrequency(e,o),s=this.documentStore.getFieldLength(o,d),u=1,a=1,r=r*n*(u=0!=s?1/Math.sqrt(s):u)*(a=e!=l?.15*(1-(e.length-l.length)/e.length):a);o in c?c[o]+=r:c[o]=r}},this),f=this.mergeScores(f,c,h)},this),f=this.coordNorm(f,p,e.length)):void 0},g.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var o={};for(i in t)i in e&&(o[i]=e[i]+t[i]);return o}for(var i in t)i in e?e[i]+=t[i]:e[i]=t[i];return e},g.Index.prototype.fieldSearchStats=function(e,t,n){for(var o in n)o in e?e[o].push(t):e[o]=[t]},g.Index.prototype.coordNorm=function(e,t,n){for(var o in e){var i;o in t&&(i=t[o].length,e[o]=e[o]*i/n)}return e},g.Index.prototype.toJSON=function(){var t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:g.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},g.Index.prototype.use=function(e){var t=[].slice.call(arguments,1);t.unshift(this),e.apply(this,t)},(g.DocumentStore=function(e){this._save=null==e||e,this.docs={},this.docInfo={},this.length=0}).load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},g.DocumentStore.prototype.isDocStored=function(){return this._save},g.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,this.docs[e]=!0===this._save?(e=>{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},l={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,C=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,D=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,L=/^(.+?)e$/,_=/ll$/,N=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,a;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(a=r.exec(e),(r=d).test(a[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(a=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(a=r.exec(e))[1])+"i"),(r=C).test(e)&&(s=(a=r.exec(e))[1],t=a[2],(r=d).test(s))&&(e=s+l[t]),(r=D).test(e)&&(s=(a=r.exec(e))[1],t=a[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=F).test(e)?(s=(a=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(a=u.exec(e))[1]+a[2],(u=h).test(s))&&(e=s),(r=L).test(e)&&(s=(a=r.exec(e))[1],u=f,o=N,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=_).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},g.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},g.InvertedIndex.prototype.getDocs=function(e){e=this.getNode(e);return null==e?{}:e.docs},g.InvertedIndex.prototype.getTermFrequency=function(e,t){e=this.getNode(e);return null!=e&&t in e.docs?e.docs[t].tf:0},g.InvertedIndex.prototype.getDocFreq=function(e){e=this.getNode(e);return null==e?0:e.df},g.InvertedIndex.prototype.removeToken=function(e,t){e&&null!=(e=this.getNode(e))&&t in e.docs&&(delete e.docs[t],--e.df)},g.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];t=t||[];if(null!=n||null!=(n=this.getNode(e)))for(var o in 0<n.df&&t.push(e),n)"docs"!==o&&"df"!==o&&this.expandToken(e+o,t,n[o]);return t},g.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},(g.Configuration=function(e,t){var n,e=e||"";if(null==t)throw Error("fields should not be null");this.config={};try{n=JSON.parse(e),this.buildUserConfig(n,t)}catch(e){g.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(t)}}).prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},g.Configuration.prototype.buildUserConfig=function(e,t){var n,o,i="OR",r=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(r=e.expand||r),"fields"in e)for(var s in e.fields)~t.indexOf(s)?(o=r,null!=(n=e.fields[s]).expand&&(o=n.expand),this.config[s]={boost:n.boost||0===n.boost?n.boost:1,bool:n.bool||i,expand:o}):g.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,r,t)},g.Configuration.prototype.addAllFields2UserConfig=function(t,n,e){e.forEach(function(e){this.config[e]={boost:1,bool:t,expand:n}},this)},g.Configuration.prototype.get=function(){return this.config},g.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){for(var e,t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;){if(r===e)return i;r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;)r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)];return e<r?i:r<e?i+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,o=0,i=this.length,r=e.length,s=this.elements,u=e.elements;i-1>=n&&r-1>=o;)s[n]!==u[o]?s[n]<u[o]?n++:s[n]>u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length<e.length?(t=e,this):(t=this,e),n=t.clone(),o=0,i=e.toArray();o<i.length;o++)n.add(i[o]);return n},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},t=this,e=function(){return g},"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=g:t.elasticlunr=g}(),window.onload=function(){function e(){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")),i='<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=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0<i?i-1:0].focus()):40===t.keyCode&&(t.preventDefault(),n[e=1+i<o.length?1+i:i].focus())}}),document.addEventListener("click",function(e){u.contains(e.target)||u.classList.add("d-none")}),c=document.documentElement.getAttribute("lang").substring(0,2),"/"==(h=document.querySelector("meta[name='base']").getAttribute("content")).slice(-1)&&(h=h.slice(0,-1)),r.addEventListener("input",async function(){var n,e=this.value.trim(),o=(await(l=void 0===l?fetch(h+"/search_index."+c+".json").then(async function(e){return elasticlunr.Index.load(await e.json())}):l)).search(e,{bool:"OR",fields:{title:{boost:2},body:{boost:1}}}),i=u.childNodes,r=o.length,s=e.split(/\s+/);for(u.classList.remove("d-none"),o.forEach(function(e){""!==e.doc.body&&((n=document.createElement("div")).innerHTML="<a href><span></span><span></span></a>",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,a=s[p].split(/[\s\n]/),l=8;for(u in a){if(0<(v=a[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(l=40,o=!0);r.push([v,l,i]),l=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300<e.length?e.substring(0,300)+"...":e;for(var d=[],h=Math.min(r.length,30),f=0,p=0;p<h;p++)f+=r[p][1];for(d.push(f),p=0;p<r.length-h;p++)f=(f-=r[p][1])+r[p+h][1],d.push(f);var m=0;if(o)for(var g=0,p=d.length-1;0<=p;p--)g<d[p]&&(g=d[p],m=p);for(var v,y,S=[],x=r[m][2],p=m;p<m+h;p++){x<(v=r[p])[2]&&(S.push(e.substring(x,v[2])),x=v[2]),40===v[1]&&S.push("<mark>"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u<e.length;u++){var a=e.codePointAt(u).toString(16);if(o=4<a.length&&++u+1<e.length?"200d"==e.codePointAt(u+1).toString(16):o){if(i+=b(a),u==e.length-1){if(t<(r+=i))break;n+=e.substr(s,u-s+1)}}else if(0!=i){if(r=(r+=i)+b(a),t<r)break;n+=e.substr(s,u-s+1),s=u+1,i=0}else{if(r+=b(a),t<r)break;4<a.length?n+=e[u-1]+e[u]:n+=e[u],s=u+1}}return n})(e.substring(v[2],x),12),S.push(y)),40===v[1]&&S.push("</mark>")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)},"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.12.1",{scope:"/"}).then(()=>{},e=>{}),navigator.serviceWorker.ready.then(()=>{}));
\ No newline at end of file diff --git a/static/js/abridge_nopwa.min.js b/static/js/abridge_nopwa.min.js index fc3090c..e71dcf1 100644 --- a/static/js/abridge_nopwa.min.js +++ b/static/js/abridge_nopwa.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var a,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,k,L,_,N,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i<n;i++){for(var r=e[i],s=0;s<o&&null!=(r=this._queue[s](r,i,e));s++);null!=r&&t.push(r)}return t},g.Pipeline.prototype.reset=function(){this._queue=[]},g.Pipeline.prototype.get=function(){return this._queue},g.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return g.Pipeline.warnIfFunctionNotRegistered(e),e.label})},(g.Index=function(){this._fields=[],this._ref="id",this.pipeline=new g.Pipeline,this.documentStore=new g.DocumentStore,this.index={},this.eventEmitter=new g.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))}).prototype.on=function(){var e=[].slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},g.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},g.Index.load=function(e){e.version!==g.version&&g.utils.warn("version mismatch: current "+g.version+" importing "+e.version);var t,n=new this;for(t in n._fields=e.fields,n._ref=e.ref,n.documentStore=g.DocumentStore.load(e.documentStore),n.pipeline=g.Pipeline.load(e.pipeline),n.index={},e.index)n.index[t]=g.InvertedIndex.load(e.index[t]);return n},g.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new g.InvertedIndex,this},g.Index.prototype.setRef=function(e){return this._ref=e,this},g.Index.prototype.saveDocument=function(e){return this.documentStore=new g.DocumentStore(e),this},g.Index.prototype.addDoc=function(i,e){var r;i&&(e=void 0===e||e,r=i[this._ref],this.documentStore.addDoc(r,i),this._fields.forEach(function(e){var t,n=this.pipeline.run(g.tokenizer(i[e])),o=(this.documentStore.addFieldLength(r,e,n.length),{});for(t in n.forEach(function(e){e in o?o[e]+=1:o[e]=1},this),o)this.index[e].addToken(t,{ref:r,tf:Math.sqrt(o[t])})},this),e)&&this.eventEmitter.emit("add",i,this)},g.Index.prototype.removeDocByRef=function(e){e&&!1!==this.documentStore.isDocStored()&&this.documentStore.hasDoc(e)&&(e=this.documentStore.getDoc(e),this.removeDoc(e,!1))},g.Index.prototype.removeDoc=function(e,t){var n;e&&(t=void 0===t||t,n=e[this._ref],this.documentStore.hasDoc(n))&&(this.documentStore.removeDoc(n),this._fields.forEach(function(t){this.pipeline.run(g.tokenizer(e[t])).forEach(function(e){this.index[t].removeToken(e,n)},this)},this),t)&&this.eventEmitter.emit("remove",e,this)},g.Index.prototype.updateDoc=function(e,t){t=void 0===t||t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},g.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;return{}.hasOwnProperty.call(this._idfCache,n)?this._idfCache[n]:(t=this.index[t].getDocFreq(e),e=1+Math.log(this.documentStore.length/(t+1)),this._idfCache[n]=e)},g.Index.prototype.getFields=function(){return this._fields.slice()},g.Index.prototype.search=function(e,t){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var n=null;null!=t&&(n=JSON.stringify(t));for(var o=new g.Configuration(n,this.getFields()).get(),i={},r=Object.keys(e),s=0;s<r.length;s++){var u=r[s];i[u]=this.pipeline.run(g.tokenizer(e[u]))}var l,a={};for(l in o){var c=i[l]||i.any;if(c){var d=this.fieldSearch(c,l,o),h=o[l].boost;for(p in d)d[p]=d[p]*h;for(p in d)p in a?a[p]+=d[p]:a[p]=d[p]}}var f,p,m=[];for(p in a)f={ref:p,score:a[p]},this.documentStore.hasDoc(p)&&(f.doc=this.documentStore.getDoc(p)),m.push(f);return m.sort(function(e,t){return t.score-e.score}),m},g.Index.prototype.fieldSearch=function(e,d,t){var h=t[d].bool,n=t[d].expand,t=t[d].boost,f=null,p={};return 0!==t?(e.forEach(function(a){var e=[a],c=(1==n&&(e=this.index[d].expandToken(a)),{});e.forEach(function(e){var t=this.index[d].getDocs(e),n=this.idf(e,d);if(f&&"AND"==h){var o,i={};for(o in f)o in t&&(i[o]=t[o]);t=i}for(o in e==a&&this.fieldSearchStats(p,e,t),t){var r=this.index[d].getTermFrequency(e,o),s=this.documentStore.getFieldLength(o,d),u=1,l=1,r=r*n*(u=0!=s?1/Math.sqrt(s):u)*(l=e!=a?.15*(1-(e.length-a.length)/e.length):l);o in c?c[o]+=r:c[o]=r}},this),f=this.mergeScores(f,c,h)},this),f=this.coordNorm(f,p,e.length)):void 0},g.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var o={};for(i in t)i in e&&(o[i]=e[i]+t[i]);return o}for(var i in t)i in e?e[i]+=t[i]:e[i]=t[i];return e},g.Index.prototype.fieldSearchStats=function(e,t,n){for(var o in n)o in e?e[o].push(t):e[o]=[t]},g.Index.prototype.coordNorm=function(e,t,n){for(var o in e){var i;o in t&&(i=t[o].length,e[o]=e[o]*i/n)}return e},g.Index.prototype.toJSON=function(){var t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:g.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},g.Index.prototype.use=function(e){var t=[].slice.call(arguments,1);t.unshift(this),e.apply(this,t)},(g.DocumentStore=function(e){this._save=null==e||e,this.docs={},this.docInfo={},this.length=0}).load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},g.DocumentStore.prototype.isDocStored=function(){return this._save},g.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,this.docs[e]=!0===this._save?(e=>{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,C=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,D=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,L=/^(.+?)e$/,_=/ll$/,N=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,l;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(l=r.exec(e),(r=d).test(l[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(l=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(l=r.exec(e))[1])+"i"),(r=C).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+a[t]),(r=D).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=F).test(e)?(s=(l=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(l=u.exec(e))[1]+l[2],(u=h).test(s))&&(e=s),(r=L).test(e)&&(s=(l=r.exec(e))[1],u=f,o=N,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=_).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},g.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},g.InvertedIndex.prototype.getDocs=function(e){e=this.getNode(e);return null==e?{}:e.docs},g.InvertedIndex.prototype.getTermFrequency=function(e,t){e=this.getNode(e);return null!=e&&t in e.docs?e.docs[t].tf:0},g.InvertedIndex.prototype.getDocFreq=function(e){e=this.getNode(e);return null==e?0:e.df},g.InvertedIndex.prototype.removeToken=function(e,t){e&&null!=(e=this.getNode(e))&&t in e.docs&&(delete e.docs[t],--e.df)},g.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];t=t||[];if(null!=n||null!=(n=this.getNode(e)))for(var o in 0<n.df&&t.push(e),n)"docs"!==o&&"df"!==o&&this.expandToken(e+o,t,n[o]);return t},g.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},(g.Configuration=function(e,t){var n,e=e||"";if(null==t)throw Error("fields should not be null");this.config={};try{n=JSON.parse(e),this.buildUserConfig(n,t)}catch(e){g.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(t)}}).prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},g.Configuration.prototype.buildUserConfig=function(e,t){var n,o,i="OR",r=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(r=e.expand||r),"fields"in e)for(var s in e.fields)~t.indexOf(s)?(o=r,null!=(n=e.fields[s]).expand&&(o=n.expand),this.config[s]={boost:n.boost||0===n.boost?n.boost:1,bool:n.bool||i,expand:o}):g.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,r,t)},g.Configuration.prototype.addAllFields2UserConfig=function(t,n,e){e.forEach(function(e){this.config[e]={boost:1,bool:t,expand:n}},this)},g.Configuration.prototype.get=function(){return this.config},g.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){for(var e,t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;){if(r===e)return i;r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;)r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)];return e<r?i:r<e?i+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,o=0,i=this.length,r=e.length,s=this.elements,u=e.elements;i-1>=n&&r-1>=o;)s[n]!==u[o]?s[n]<u[o]?n++:s[n]>u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length<e.length?(t=e,this):(t=this,e),n=t.clone(),o=0,i=e.toArray();o<i.length;o++)n.add(i[o]);return n},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},t=this,e=function(){return g},"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=g:t.elasticlunr=g}(),window.onload=function(){function e(){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")),i='<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=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0<i?i-1:0].focus()):40===t.keyCode&&(t.preventDefault(),n[e=1+i<o.length?1+i:i].focus())}}),document.addEventListener("click",function(e){u.contains(e.target)||u.classList.add("d-none")}),c=document.documentElement.getAttribute("lang").substring(0,2),"/"==(h=document.querySelector("meta[name='base']").getAttribute("content")).slice(-1)&&(h=h.slice(0,-1)),r.addEventListener("input",async function(){var n,e=this.value.trim(),o=(await(l=void 0===l?fetch(h+"/search_index."+c+".json").then(async function(e){return elasticlunr.Index.load(await e.json())}):l)).search(e,{bool:"OR",fields:{title:{boost:2},body:{boost:1}}}),i=u.childNodes,r=o.length,s=e.split(/\s+/);for(u.classList.remove("d-none"),o.forEach(function(e){""!==e.doc.body&&((n=document.createElement("div")).innerHTML="<a href><span></span><span></span></a>",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,l=s[p].split(/[\s\n]/),a=8;for(u in l){if(0<(v=l[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(a=40,o=!0);r.push([v,a,i]),a=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300<e.length?e.substring(0,300)+"...":e;for(var d=[],h=Math.min(r.length,30),f=0,p=0;p<h;p++)f+=r[p][1];for(d.push(f),p=0;p<r.length-h;p++)f=(f-=r[p][1])+r[p+h][1],d.push(f);var m=0;if(o)for(var g=0,p=d.length-1;0<=p;p--)g<d[p]&&(g=d[p],m=p);for(var v,y,S=[],x=r[m][2],p=m;p<m+h;p++){x<(v=r[p])[2]&&(S.push(e.substring(x,v[2])),x=v[2]),40===v[1]&&S.push("<mark>"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u<e.length;u++){var l=e.codePointAt(u).toString(16);if(o=4<l.length&&++u+1<e.length?"200d"==e.codePointAt(u+1).toString(16):o){if(i+=b(l),u==e.length-1){if(t<(r+=i))break;n+=e.substr(s,u-s+1)}}else if(0!=i){if(r=(r+=i)+b(l),t<r)break;n+=e.substr(s,u-s+1),s=u+1,i=0}else{if(r+=b(l),t<r)break;4<l.length?n+=e[u-1]+e[u]:n+=e[u],s=u+1}}return n})(e.substring(v[2],x),12),S.push(y)),40===v[1]&&S.push("</mark>")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)};
\ No newline at end of file +let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=getCodeContent(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getCodeContent=e=>[...e.querySelectorAll(".giallo-l")].map(e=>{var e=e.cloneNode(!0),t=e.querySelector(".giallo-ln");return t&&t.remove(),e.textContent}).join("\n");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var a,c,e,t,d,h,f,p,m,v,y,S,x,b,w,I,E,C,D,F,k,L,_,N,n;g.version="0.9.5",((lunr=g).utils={}).warn=(n=this,function(e){n.console}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=[].slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!=(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0==this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){var t;this.hasHandler(e)&&(t=[].slice.call(arguments,1),this.events[e].forEach(function(e){e.apply(void 0,t)},this))},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(e){var t,n;return arguments.length&&null!=e?Array.isArray(e)?(t=(t=e.filter(function(e){return null!=e})).map(function(e){return g.utils.toString(e).toLowerCase()}),n=[],t.forEach(function(e){e=e.split(g.tokenizer.seperator);n=n.concat(e)},this),n):e.toString().trim().toLowerCase().split(g.tokenizer.seperator):[]}).defaultSeperator=/[\s\-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){var n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){[].slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(1+e,0,t)},g.Pipeline.prototype.before=function(e,t){g.Pipeline.warnIfFunctionNotRegistered(t);e=this._queue.indexOf(e);if(-1==e)throw Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){e=this._queue.indexOf(e);-1!=e&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,o=this._queue.length,i=0;i<n;i++){for(var r=e[i],s=0;s<o&&null!=(r=this._queue[s](r,i,e));s++);null!=r&&t.push(r)}return t},g.Pipeline.prototype.reset=function(){this._queue=[]},g.Pipeline.prototype.get=function(){return this._queue},g.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return g.Pipeline.warnIfFunctionNotRegistered(e),e.label})},(g.Index=function(){this._fields=[],this._ref="id",this.pipeline=new g.Pipeline,this.documentStore=new g.DocumentStore,this.index={},this.eventEmitter=new g.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))}).prototype.on=function(){var e=[].slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},g.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},g.Index.load=function(e){e.version!==g.version&&g.utils.warn("version mismatch: current "+g.version+" importing "+e.version);var t,n=new this;for(t in n._fields=e.fields,n._ref=e.ref,n.documentStore=g.DocumentStore.load(e.documentStore),n.pipeline=g.Pipeline.load(e.pipeline),n.index={},e.index)n.index[t]=g.InvertedIndex.load(e.index[t]);return n},g.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new g.InvertedIndex,this},g.Index.prototype.setRef=function(e){return this._ref=e,this},g.Index.prototype.saveDocument=function(e){return this.documentStore=new g.DocumentStore(e),this},g.Index.prototype.addDoc=function(i,e){var r;i&&(e=void 0===e||e,r=i[this._ref],this.documentStore.addDoc(r,i),this._fields.forEach(function(e){var t,n=this.pipeline.run(g.tokenizer(i[e])),o=(this.documentStore.addFieldLength(r,e,n.length),{});for(t in n.forEach(function(e){e in o?o[e]+=1:o[e]=1},this),o)this.index[e].addToken(t,{ref:r,tf:Math.sqrt(o[t])})},this),e)&&this.eventEmitter.emit("add",i,this)},g.Index.prototype.removeDocByRef=function(e){e&&!1!==this.documentStore.isDocStored()&&this.documentStore.hasDoc(e)&&(e=this.documentStore.getDoc(e),this.removeDoc(e,!1))},g.Index.prototype.removeDoc=function(e,t){var n;e&&(t=void 0===t||t,n=e[this._ref],this.documentStore.hasDoc(n))&&(this.documentStore.removeDoc(n),this._fields.forEach(function(t){this.pipeline.run(g.tokenizer(e[t])).forEach(function(e){this.index[t].removeToken(e,n)},this)},this),t)&&this.eventEmitter.emit("remove",e,this)},g.Index.prototype.updateDoc=function(e,t){t=void 0===t||t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},g.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;return{}.hasOwnProperty.call(this._idfCache,n)?this._idfCache[n]:(t=this.index[t].getDocFreq(e),e=1+Math.log(this.documentStore.length/(t+1)),this._idfCache[n]=e)},g.Index.prototype.getFields=function(){return this._fields.slice()},g.Index.prototype.search=function(e,t){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var n=null;null!=t&&(n=JSON.stringify(t));for(var o=new g.Configuration(n,this.getFields()).get(),i={},r=Object.keys(e),s=0;s<r.length;s++){var u=r[s];i[u]=this.pipeline.run(g.tokenizer(e[u]))}var l,a={};for(l in o){var c=i[l]||i.any;if(c){var d=this.fieldSearch(c,l,o),h=o[l].boost;for(p in d)d[p]=d[p]*h;for(p in d)p in a?a[p]+=d[p]:a[p]=d[p]}}var f,p,m=[];for(p in a)f={ref:p,score:a[p]},this.documentStore.hasDoc(p)&&(f.doc=this.documentStore.getDoc(p)),m.push(f);return m.sort(function(e,t){return t.score-e.score}),m},g.Index.prototype.fieldSearch=function(e,d,t){var h=t[d].bool,n=t[d].expand,t=t[d].boost,f=null,p={};return 0!==t?(e.forEach(function(a){var e=[a],c=(1==n&&(e=this.index[d].expandToken(a)),{});e.forEach(function(e){var t=this.index[d].getDocs(e),n=this.idf(e,d);if(f&&"AND"==h){var o,i={};for(o in f)o in t&&(i[o]=t[o]);t=i}for(o in e==a&&this.fieldSearchStats(p,e,t),t){var r=this.index[d].getTermFrequency(e,o),s=this.documentStore.getFieldLength(o,d),u=1,l=1,r=r*n*(u=0!=s?1/Math.sqrt(s):u)*(l=e!=a?.15*(1-(e.length-a.length)/e.length):l);o in c?c[o]+=r:c[o]=r}},this),f=this.mergeScores(f,c,h)},this),f=this.coordNorm(f,p,e.length)):void 0},g.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var o={};for(i in t)i in e&&(o[i]=e[i]+t[i]);return o}for(var i in t)i in e?e[i]+=t[i]:e[i]=t[i];return e},g.Index.prototype.fieldSearchStats=function(e,t,n){for(var o in n)o in e?e[o].push(t):e[o]=[t]},g.Index.prototype.coordNorm=function(e,t,n){for(var o in e){var i;o in t&&(i=t[o].length,e[o]=e[o]*i/n)}return e},g.Index.prototype.toJSON=function(){var t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:g.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},g.Index.prototype.use=function(e){var t=[].slice.call(arguments,1);t.unshift(this),e.apply(this,t)},(g.DocumentStore=function(e){this._save=null==e||e,this.docs={},this.docInfo={},this.length=0}).load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},g.DocumentStore.prototype.isDocStored=function(){return this._save},g.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,this.docs[e]=!0===this._save?(e=>{if(null===e||"object"!=typeof e)return e;var t,n=e.constructor();for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n})(t):null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},d=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,h=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*/,f=/^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$/,p=/^([^aeiou][^aeiouy]*)?[aeiouy]/,m=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,S=/^(.+?)(ed|ing)$/,x=/.$/,b=/(at|bl|iz)$/,w=/([^aeiouylsz])\1$/,I=RegExp("^"+(t="[^aeiou][^aeiouy]*")+(e="[aeiouy]")+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,C=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,D=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,k=/^(.+?)(s|t)(ion)$/,L=/^(.+?)e$/,_=/ll$/,N=RegExp("^"+t+e+"[^aeiouwxy]$"),g.Pipeline.registerFunction(g.stemmer=function(e){var t,n,o,i,r,s,u,l;return e.length<3||("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),u=v,(r=m).test(e)?e=e.replace(r,"$1$2"):u.test(e)&&(e=e.replace(u,"$1$2")),u=S,(r=y).test(e)?(l=r.exec(e),(r=d).test(l[1])&&(e=e.replace(r=x,""))):u.test(e)&&(s=(l=u.exec(e))[1],(u=p).test(s))&&(e=s,o=w,i=I,(u=b).test(e)?e+="e":o.test(e)?e=e.replace(r=x,""):i.test(e)&&(e+="e")),(r=E).test(e)&&(e=(s=(l=r.exec(e))[1])+"i"),(r=C).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+a[t]),(r=D).test(e)&&(s=(l=r.exec(e))[1],t=l[2],(r=d).test(s))&&(e=s+c[t]),u=k,(r=F).test(e)?(s=(l=r.exec(e))[1],(r=h).test(s)&&(e=s)):u.test(e)&&(s=(l=u.exec(e))[1]+l[2],(u=h).test(s))&&(e=s),(r=L).test(e)&&(s=(l=r.exec(e))[1],u=f,o=N,(r=h).test(s)||u.test(s)&&!o.test(s))&&(e=s),u=h,(r=_).test(e)&&u.test(e)&&(e=e.replace(r=x,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1))),e},"stemmer"),g.stopWordFilter=function(e){return e&&!0!==g.stopWordFilter.stopWords[e]?e:void 0},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,o=0;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},g.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},g.InvertedIndex.prototype.getDocs=function(e){e=this.getNode(e);return null==e?{}:e.docs},g.InvertedIndex.prototype.getTermFrequency=function(e,t){e=this.getNode(e);return null!=e&&t in e.docs?e.docs[t].tf:0},g.InvertedIndex.prototype.getDocFreq=function(e){e=this.getNode(e);return null==e?0:e.df},g.InvertedIndex.prototype.removeToken=function(e,t){e&&null!=(e=this.getNode(e))&&t in e.docs&&(delete e.docs[t],--e.df)},g.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];t=t||[];if(null!=n||null!=(n=this.getNode(e)))for(var o in 0<n.df&&t.push(e),n)"docs"!==o&&"df"!==o&&this.expandToken(e+o,t,n[o]);return t},g.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},(g.Configuration=function(e,t){var n,e=e||"";if(null==t)throw Error("fields should not be null");this.config={};try{n=JSON.parse(e),this.buildUserConfig(n,t)}catch(e){g.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(t)}}).prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},g.Configuration.prototype.buildUserConfig=function(e,t){var n,o,i="OR",r=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(r=e.expand||r),"fields"in e)for(var s in e.fields)~t.indexOf(s)?(o=r,null!=(n=e.fields[s]).expand&&(o=n.expand),this.config[s]={boost:n.boost||0===n.boost?n.boost:1,bool:n.bool||i,expand:o}):g.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,r,t)},g.Configuration.prototype.addAllFields2UserConfig=function(t,n,e){e.forEach(function(e){this.config[e]={boost:1,bool:t,expand:n}},this)},g.Configuration.prototype.get=function(){return this.config},g.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){for(var e,t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;){if(r===e)return i;r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];1<o;)r<e&&(t=i),e<r&&(n=i),r=this.elements[i=t+Math.floor((o=n-t)/2)];return e<r?i:r<e?i+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,o=0,i=this.length,r=e.length,s=this.elements,u=e.elements;i-1>=n&&r-1>=o;)s[n]!==u[o]?s[n]<u[o]?n++:s[n]>u[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){for(var t,e=this.length<e.length?(t=e,this):(t=this,e),n=t.clone(),o=0,i=e.toArray();o<i.length;o++)n.add(i[o]);return n},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},t=this,e=function(){return g},"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=g:t.elasticlunr=g}(),window.onload=function(){function e(){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")),i='<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=i,n.insertBefore(o,n.firstChild),e.innerHTML=n.outerHTML,t.innerHTML="",document.getElementById("searchinput").value="",document.body.contains(document.closeSearch)&&(document.closeSearch.onsubmit=function(){document.querySelector("main").innerHTML=window.main}),!1}function b(e){return[0,1,2,3,4][Math.ceil(parseInt(e,16).toString(2).length/8)]}var u,r,l,c,h;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},u=document.getElementById("suggestions"),r=document.getElementById("searchinput"),document.addEventListener("keydown",function(t){if(191===t.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(t.preventDefault(),r.focus(),u.classList.remove("d-none")),27===t.keyCode){r.blur(),u.classList.add("d-none");for(var e=document.getElementById("suggestions");e.firstChild;)e.removeChild(e.firstChild)}var n=u.querySelectorAll("a");if(!u.classList.contains("d-none")&&0!==n.length){var o=[...n],i=o.indexOf(document.activeElement);let e=0;38===t.keyCode?(t.preventDefault(),n[e=0<i?i-1:0].focus()):40===t.keyCode&&(t.preventDefault(),n[e=1+i<o.length?1+i:i].focus())}}),document.addEventListener("click",function(e){u.contains(e.target)||u.classList.add("d-none")}),c=document.documentElement.getAttribute("lang").substring(0,2),"/"==(h=document.querySelector("meta[name='base']").getAttribute("content")).slice(-1)&&(h=h.slice(0,-1)),r.addEventListener("input",async function(){var n,e=this.value.trim(),o=(await(l=void 0===l?fetch(h+"/search_index."+c+".json").then(async function(e){return elasticlunr.Index.load(await e.json())}):l)).search(e,{bool:"OR",fields:{title:{boost:2},body:{boost:1}}}),i=u.childNodes,r=o.length,s=e.split(/\s+/);for(u.classList.remove("d-none"),o.forEach(function(e){""!==e.doc.body&&((n=document.createElement("div")).innerHTML="<a href><span></span><span></span></a>",a=n.querySelector("a"),t=n.querySelector("span:first-child"),d=n.querySelector("span:nth-child(2)"),a.href=e.ref,t.textContent=e.doc.title,d.innerHTML=((e,t)=>{var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())}),o=!1,i=0,r=[],s=e.toLowerCase().split(". ");for(p in s){var u,l=s[p].split(/[\s\n]/),a=8;for(u in l){if(0<(v=l[u]).length){for(var c in n)elasticlunr.stemmer(v).startsWith(n[c])&&(a=40,o=!0);r.push([v,a,i]),a=2}i=i+v.length+1}i+=1}if(0===r.length)return void 0!==e.length&&300<e.length?e.substring(0,300)+"...":e;for(var d=[],h=Math.min(r.length,30),f=0,p=0;p<h;p++)f+=r[p][1];for(d.push(f),p=0;p<r.length-h;p++)f=(f-=r[p][1])+r[p+h][1],d.push(f);var m=0;if(o)for(var g=0,p=d.length-1;0<=p;p--)g<d[p]&&(g=d[p],m=p);for(var v,y,S=[],x=r[m][2],p=m;p<m+h;p++){x<(v=r[p])[2]&&(S.push(e.substring(x,v[2])),x=v[2]),40===v[1]&&S.push("<mark>"),x=v[2]+v[0].length;40===v[1]||v[0].length<12||/^[\x00-\xff]+$/.test(v[0])?S.push(e.substring(v[2],x)):(y=((e,t)=>{for(var n="",o=!1,i=0,r=0,s=0,u=0;u<e.length;u++){var l=e.codePointAt(u).toString(16);if(o=4<l.length&&++u+1<e.length?"200d"==e.codePointAt(u+1).toString(16):o){if(i+=b(l),u==e.length-1){if(t<(r+=i))break;n+=e.substr(s,u-s+1)}}else if(0!=i){if(r=(r+=i)+b(l),t<r)break;n+=e.substr(s,u-s+1),s=u+1,i=0}else{if(r+=b(l),t<r)break;4<l.length?n+=e[u-1]+e[u]:n+=e[u],s=u+1}}return n})(e.substring(v[2],x),12),S.push(y)),40===v[1]&&S.push("</mark>")}return S.push("…"),S.join("")})(e.doc.body,s),u.appendChild(n))});i.length>r;)u.removeChild(i[0])},!0),u.addEventListener("click",function(){for(;u.lastChild;)u.removeChild(u.lastChild);return!1},!0),document.goSearch.onsubmit=e)};
\ No newline at end of file diff --git a/static/js/abridge_nosearch.min.js b/static/js/abridge_nosearch.min.js index 30ef94e..5945e39 100644 --- a/static/js/abridge_nosearch.min.js +++ b/static/js/abridge_nosearch.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var o=e[t].getAttribute("href"),o=atob(o.substring(1));e[t].href="mailto:"+o}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.12.1",{scope:"/"}).then(()=>{},e=>{}),navigator.serviceWorker.ready.then(()=>{}));
\ No newline at end of file +let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=getCodeContent(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getCodeContent=e=>[...e.querySelectorAll(".giallo-l")].map(e=>{var e=e.cloneNode(!0),t=e.querySelector(".giallo-ln");return t&&t.remove(),e.textContent}).join("\n");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}),"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.12.1",{scope:"/"}).then(()=>{},e=>{}),navigator.serviceWorker.ready.then(()=>{}));
\ No newline at end of file diff --git a/static/js/abridge_nosearch_nopwa.min.js b/static/js/abridge_nosearch_nopwa.min.js index 914a0e9..301d197 100644 --- a/static/js/abridge_nosearch_nopwa.min.js +++ b/static/js/abridge_nosearch_nopwa.min.js @@ -1 +1 @@ -let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var c=e[t].getAttribute("href"),c=atob(c.substring(1));e[t].href="mailto:"+c}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))});
\ No newline at end of file +let items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),(()=>{for(var e=document.getElementsByClassName("m-protected"),t=0;t<e.length;t++){var n=e[t].getAttribute("href"),n=atob(n.substring(1));e[t].href="mailto:"+n}})(),(e,t)=>{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=getCodeContent(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getCodeContent=e=>[...e.querySelectorAll(".giallo-l")].map(e=>{var e=e.cloneNode(!0),t=e.querySelector(".giallo-ln");return t&&t.remove(),e.textContent}).join("\n");document.querySelectorAll("pre").forEach(e=>{let t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))});
\ No newline at end of file diff --git a/static/js/codecopy.js b/static/js/codecopy.js index 9e00c79..11d28e2 100644 --- a/static/js/codecopy.js +++ b/static/js/codecopy.js @@ -4,7 +4,7 @@ const changeIcon = (copyDiv, className) => { }; const copyCodeAndChangeIcon = async (copyDiv, block) => { - const code = block.querySelector('table') ? getTableCode(block) : getNonTableCode(block); + const code = getCodeContent(block); try { await navigator.clipboard.writeText(code); changeIcon(copyDiv, "yes"); @@ -13,16 +13,15 @@ const copyCodeAndChangeIcon = async (copyDiv, block) => { } }; -const getNonTableCode = (block) => { - return [...block.querySelectorAll('code')] - .map(code => code.textContent) - .join(''); -}; - -const getTableCode = (block) => { - return [...block.querySelectorAll('tr')] - .map(row => row.querySelector('td:last-child')?.innerText ?? '') - .join(''); +const getCodeContent = (block) => { + return [...block.querySelectorAll('.giallo-l')] + .map(line => { + const clone = line.cloneNode(true); + const ln = clone.querySelector('.giallo-ln'); + if (ln) ln.remove(); + return clone.textContent; + }) + .join('\n'); }; document.querySelectorAll("pre").forEach((block) => { @@ -30,5 +29,5 @@ document.querySelectorAll("pre").forEach((block) => { copyDiv.className = "cc svgs svgh copy"; copyDiv.innerHTML = " "; block.prepend(copyDiv); - copyDiv.addEventListener("click", () => copyCodeAndChangeIcon(copyDiv, block));; + copyDiv.addEventListener("click", () => copyCodeAndChangeIcon(copyDiv, block)); }); diff --git a/static/js/search_tinysearch.min.js b/static/js/search_tinysearch.min.js index 3ed4113..5abb86a 100644 --- a/static/js/search_tinysearch.min.js +++ b/static/js/search_tinysearch.min.js @@ -1 +1 @@ -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(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 a=document.getElementById("searchinput"),r=(document.addEventListener("keydown",function(n){191===n.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(n.preventDefault(),a.focus(),suggestions.classList.remove("d-none")),27===n.keyCode&&(a.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()=>{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,a=document.getElementById("suggestions"),i=(o=99,t=((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,a=o(r),i=w(),s=0;for(;s<r;s++){let e=t.charCodeAt(s);if(127<e)break;i[a+s]=e}if(s!==r){0!==s&&(t=t.slice(s)),a=n(a,r,r=s+3*t.length);let e=w().subarray(a+s,a+r);s+=p(t,e).written}return y=s,a})(t=n,f.__wbindgen_malloc,f.__wbindgen_realloc),r=y,(e=>{var n=(e=>g[e])(e);return e<36||(g[e]=h,h=e),n})(f.search(t,r,o))),s=0;s<i.length;s++){var c,u,l,d,m=i[s];(d=document.createElement("DIV")).innerHTML="<a href><span></span><span></span></a>",c=d.querySelector("a"),u=d.querySelector("span:first-child"),l=d.querySelector("span:nth-child(2)"),c.href=m[1]+"?q="+encodeURIComponent(n),u.innerHTML=m[0],l.innerHTML=m[2].replace(RegExp("(^|)("+n+")(|$)","ig"),"$1<mark>$2</mark>$3"),a.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 +window.onload=function(){function m(){var e=document.querySelector("meta[name='base']").getAttribute("content");return(e=e&&"/"==e.slice(-1)?e.slice(0,-1):e)||""}async function e(){var e=m()+"/tinysearch_engine.wasm",n=await fetch(e);if(!n.ok)throw Error("Failed to fetch WASM: "+n.status+" "+n.statusText+" ("+e+")");if(e=await n.arrayBuffer(),n=await WebAssembly.instantiate(e),y=n.instance,g=y.exports.memory,p=y.exports.search,v=y.exports.free_search_result,!p||!v||!g)throw Error("Required WASM exports not found (need search, free_search_result, memory)");w=!0}function n(){var e=document.querySelector("main"),n=(window.main||(window.main=e.innerHTML),document.getElementById("suggestions")),t=n.cloneNode(!0),r=(t.id="results",document.createElement("div")),o='<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 r.innerHTML=o,t.insertBefore(r,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 f(){for(;h.firstChild;)h.removeChild(h.firstChild)}var a,h,t,y,g,p,v,w,b,E;document.body.contains(document.goSearch)&&(document.goSearch.onsubmit=function(){return goSearchNow()},a=document.getElementById("searchinput"),h=document.getElementById("suggestions"),document.addEventListener("keydown",function(n){191===n.keyCode&&"INPUT"!==document.activeElement.tagName&&"TEXTAREA"!==document.activeElement.tagName&&(n.preventDefault(),a.focus(),h.classList.remove("d-none")),27===n.keyCode&&(a.blur(),h.classList.add("d-none"),f());var t=h.querySelectorAll("a");if(!h.classList.contains("d-none")&&0!==t.length){var r=[...t],o=r.indexOf(document.activeElement);let e=0;38===n.keyCode?(n.preventDefault(),t[e=0<o?o-1:0].focus()):40===n.keyCode&&(n.preventDefault(),t[e=1+o<r.length?1+o:o].focus())}}),t=!1,document.getElementById("searchinput").onfocus=function(){t||(e(),t=!0),document.getElementById("searchinput").onfocus=""},v=p=g=y=null,w=!1,b=new TextEncoder,E=new TextDecoder("utf-8"),document.getElementById("searchinput").addEventListener("input",function(e){var n=this.value;if(f(),!n)return!1;if(!w)return!1;for(var t=((e,n)=>{if(!w||!e)return[];n=n||10;try{var t,r,o=(e=>{var e=b.encode(e+"\0"),n=0;return n=(n=y.exports.__wbindgen_malloc?y.exports.__wbindgen_malloc(e.length):n)||1024,new Uint8Array(g.buffer,n,e.length).set(e),n})(e),a=p(o,n);return(y.exports.__wbindgen_free&&1024<o&&y.exports.__wbindgen_free(o,e.length+1),a)?(t=(e=>{if(!e)return null;for(var n=new Uint8Array(g.buffer),t=0;0!==n[e+t]&&++t<=10485760;);return E.decode(n.subarray(e,e+t))})(a),v(a),t&&Array.isArray(r=JSON.parse(t))?r:[]):[]}catch(e){return[]}})(n,99),r=0;r<t.length;r++){var o,a,i,c=t[r],c=Array.isArray(c)?(o=c[0],a=c[1],c[2]):(o=c.title,a=c.url,(e=>{if(!e)return"";if("string"==typeof e&&"{"==(e[0]||""))try{var n=JSON.parse(e);return n.meta||n.description||Object.values(n)[0]||""}catch(e){}return e})(c.meta||c.description||"")),u=((i=document.createElement("DIV")).innerHTML="<a href><span></span><span></span></a>",i.querySelector("a")),s=i.querySelector("span:first-child"),d=i.querySelector("span:nth-child(2)"),l=(n=>{if(!n)return n;var e,t=m();if(!t)return n;try{return"/"==(n[0]||"")?t+n:(e=new URL(n,t),new URL(t).origin+e.pathname+e.search+e.hash)}catch(e){return n}})(a);u.href=l+(~l.indexOf("?")?"&":"?")+"q="+encodeURIComponent(n),s.innerHTML=o||"",d.innerHTML=(u=n,(l=c||"")?(""+l).replace(RegExp("(^|)("+u+")(|$)","ig"),"$1<mark>$2</mark>$3"):""),h.appendChild(i)}}),document.goSearch.onsubmit=n)};
\ No newline at end of file diff --git a/static/js/tinysearch.js b/static/js/tinysearch.js index 183eb05..0a93d8f 100644 --- a/static/js/tinysearch.js +++ b/static/js/tinysearch.js @@ -2,252 +2,258 @@ window.onload = function () { if (document.body.contains(document.goSearch)) { document.goSearch.onsubmit = function () { return goSearchNow() }; - (function () {//anonymous function to keep from defining global variables. - + (function () { var searchinput = document.getElementById("searchinput"); - function suggestionFocus(e) { - if (e.keyCode === 191//forward slash - && document.activeElement.tagName !== "INPUT" - && document.activeElement.tagName !== "TEXTAREA") { - e.preventDefault(); - searchinput.focus(); - suggestions.classList.remove('d-none'); - } + var suggestions = document.getElementById("suggestions"); - if (e.keyCode === 27 ) {//escape - searchinput.blur(); - suggestions.classList.add('d-none'); - closeAllLists(); + function getBaseUrl() { + var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); + if (baseUrl && baseUrl.slice(-1) == "/") { + baseUrl = baseUrl.slice(0, -1); + } + return baseUrl || ""; } - const focusableSuggestions= suggestions.querySelectorAll('a'); - if (suggestions.classList.contains('d-none') - || focusableSuggestions.length === 0) { - return; + // Permalinks in the WASM index were baked at build time (zola base_url). + // Rewrite to the live site from <meta name="base"> so links match the current host. + function resolveResultUrl(url) { + if (!url) return url; + var baseUrl = getBaseUrl(); + if (!baseUrl) return url; + try { + if (url.charAt(0) === "/") { + return baseUrl + url; + } + var parsed = new URL(url, baseUrl); + var base = new URL(baseUrl); + return base.origin + parsed.pathname + parsed.search + parsed.hash; + } catch (e) { + return url; + } } - const focusable= [...focusableSuggestions]; - const index = focusable.indexOf(document.activeElement); - let nextIndex = 0; + function suggestionFocus(e) { + if (e.keyCode === 191 + && document.activeElement.tagName !== "INPUT" + && document.activeElement.tagName !== "TEXTAREA") { + e.preventDefault(); + searchinput.focus(); + suggestions.classList.remove('d-none'); + } - if (e.keyCode === 38) {//up arrow - e.preventDefault(); - nextIndex= index > 0 ? index-1 : 0; - focusableSuggestions[nextIndex].focus(); - } - else if (e.keyCode === 40) {//down arrow - e.preventDefault(); - nextIndex= index+1 < focusable.length ? index+1 : index; - focusableSuggestions[nextIndex].focus(); - } + if (e.keyCode === 27) { + searchinput.blur(); + suggestions.classList.add('d-none'); + closeAllLists(); + } + + const focusableSuggestions = suggestions.querySelectorAll('a'); + if (suggestions.classList.contains('d-none') + || focusableSuggestions.length === 0) { + return; + } + const focusable = [...focusableSuggestions]; + const index = focusable.indexOf(document.activeElement); + + let nextIndex = 0; + if (e.keyCode === 38) { + e.preventDefault(); + nextIndex = index > 0 ? index - 1 : 0; + focusableSuggestions[nextIndex].focus(); + } + else if (e.keyCode === 40) { + e.preventDefault(); + nextIndex = index + 1 < focusable.length ? index + 1 : index; + focusableSuggestions[nextIndex].focus(); + } } document.addEventListener("keydown", suggestionFocus); var loaded = false; - document.getElementById('searchinput').onfocus = function() { + document.getElementById('searchinput').onfocus = function () { if (!loaded) { lazyLoad(); loaded = true; } document.getElementById('searchinput').onfocus = ''; - } + }; + async function lazyLoad() { - var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); - if (baseUrl.slice(-1) == "/") { - baseUrl = baseUrl.slice(0, -1); - } - await init(baseUrl + "/tinysearch_engine_bg.wasm"); + // Post-0.9 tinysearch (no wasm-pack): tinysearch_engine.wasm + await initWasm(getBaseUrl() + "/tinysearch_engine.wasm"); } - // in page results when press enter or click search icon from search box function closeSearchNow() { const main = document.querySelector("main"); - main.innerHTML = window.main + main.innerHTML = window.main; } + function goSearchNow() { const main = document.querySelector("main"); if (!window.main) { - window.main = main.innerHTML - }; - var results = document.getElementById("suggestions");// suggestions div generated by search box - - var ResultsClone = results.cloneNode(true);// make a clone of the results, so that we can alter it - ResultsClone.id = "results";// alter the id of our clone, so that we can apply different css style - - var headerDiv = document.createElement("div");// create a div element - - var headerContent = '<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>");// header to use at top of results page + window.main = main.innerHTML; + } + var results = document.getElementById("suggestions"); - headerDiv.innerHTML = headerContent;// document element div (headerDiv), set the inner contents to our header html (headerContent) + var ResultsClone = results.cloneNode(true); + ResultsClone.id = "results"; - ResultsClone.insertBefore(headerDiv, ResultsClone.firstChild);//insert our header div at the top of the page + var headerDiv = document.createElement("div"); + var headerContent = '<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>"); + headerDiv.innerHTML = headerContent; + ResultsClone.insertBefore(headerDiv, ResultsClone.firstChild); - main.innerHTML = ResultsClone.outerHTML;//display ResultsClone.outerHTML as the page - results.innerHTML = "";// clear the suggestions div popup - document.getElementById("searchinput").value = "";// clear the search input box - document.body.contains(document.closeSearch) && (document.closeSearch.onsubmit = function() { closeSearchNow() }) - return false + main.innerHTML = ResultsClone.outerHTML; + results.innerHTML = ""; + document.getElementById("searchinput").value = ""; + document.body.contains(document.closeSearch) && (document.closeSearch.onsubmit = function () { closeSearchNow() }); + return false; } - /* Close search suggestion popup list */ function closeAllLists(elmnt) { - var suggestions = document.getElementById("suggestions"); while (suggestions.firstChild) { suggestions.removeChild(suggestions.firstChild); } } function markTerm(input, term) { - return input.replace(new RegExp('(^|)(' + term + ')(|$)','ig'), '$1<mark>$2</mark>$3'); + if (!input) return ""; + return String(input).replace(new RegExp('(^|)(' + term + ')(|$)', 'ig'), '$1<mark>$2</mark>$3'); } - function autocomplete(inp) { + function unwrapMeta(meta) { + if (!meta) return ""; + if (typeof meta === "string" && meta.charAt(0) === "{") { + try { + var m = JSON.parse(meta); + return m.meta || m.description || Object.values(m)[0] || ""; + } catch (e) { + return meta; + } + } + return meta; + } + function autocomplete(inp) { inp.addEventListener("input", function (e) { - var suggestions, entry, i, val = this.value; + var entry, i, val = this.value; - /*close any already open lists of autocompleted values*/ closeAllLists(); if (!val) { return false; } + if (!wasmReady) { + return false; + } - suggestions = document.getElementById("suggestions");// suggestions div, generated by search box - - let arr = search(val, 99);//limit results + let arr = doSearch(val, 99); for (i = 0; i < arr.length; i++) { let elem = arr[i]; + var title, url, meta; + if (Array.isArray(elem)) { + title = elem[0]; + url = elem[1]; + meta = elem[2]; + } else { + title = elem.title; + url = elem.url; + meta = unwrapMeta(elem.meta || elem.description || ""); + } entry = document.createElement("DIV"); entry.innerHTML = '<a href><span></span><span></span></a>'; - var a, t, d; - a = entry.querySelector('a'), - t = entry.querySelector('span:first-child'), - d = entry.querySelector('span:nth-child(2)'); - a.href = `${elem[1]}?q=${encodeURIComponent(val)}`;//a link - //t.innerHTML = markTerm(elem[0], val);//title - t.innerHTML = elem[0];//title - d.innerHTML = markTerm(elem[2], val);//description + var a = entry.querySelector('a'), + t = entry.querySelector('span:first-child'), + d = entry.querySelector('span:nth-child(2)'); + var resolved = resolveResultUrl(url); + a.href = resolved + (resolved.indexOf('?') >= 0 ? '&' : '?') + 'q=' + encodeURIComponent(val); + t.innerHTML = title || ""; + d.innerHTML = markTerm(meta || "", val); suggestions.appendChild(entry); } - }) + }); } + // ---- New tinysearch WASM API (vanilla cargo build, no wasm-pack) ---- + var wasmModule = null; + var memory = null; + var searchFunction = null; + var freeFunction = null; + var wasmReady = false; + var textEncoder = new TextEncoder(); + var textDecoder = new TextDecoder("utf-8"); - let wasm, cachedTextDecoder = (autocomplete(document.getElementById("searchinput")), new TextDecoder("utf-8", { - ignoreBOM: !0, - fatal: !0 - })), - cachegetUint8Memory0 = (cachedTextDecoder.decode(), null); - - function getUint8Memory0() { - return cachegetUint8Memory0 = null !== cachegetUint8Memory0 && cachegetUint8Memory0.buffer === wasm.memory.buffer ? cachegetUint8Memory0 : new Uint8Array(wasm.memory.buffer) + function stringToWasmPtr(str) { + var bytes = textEncoder.encode(str + "\0"); + var ptr = 0; + if (wasmModule.exports.__wbindgen_malloc) { + ptr = wasmModule.exports.__wbindgen_malloc(bytes.length); + } + if (!ptr) { + ptr = 1024; + } + new Uint8Array(memory.buffer, ptr, bytes.length).set(bytes); + return ptr; } - function getStringFromWasm0(e, t) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(e, e + t)) + function wasmPtrToString(ptr) { + if (!ptr) return null; + var memoryArray = new Uint8Array(memory.buffer); + var length = 0; + while (memoryArray[ptr + length] !== 0) { + length++; + if (length > 10 * 1024 * 1024) break; + } + return textDecoder.decode(memoryArray.subarray(ptr, ptr + length)); } - const heap = new Array(32).fill(void 0); - heap.push(void 0, null, !0, !1); - let heap_next = heap.length; - 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 - } - let WASM_VECTOR_LEN = 0, - cachedTextEncoder = new TextEncoder("utf-8"); - const 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 - } - }; + function doSearch(query, limit) { + if (!wasmReady || !query) return []; + limit = limit || 10; + try { + var queryPtr = stringToWasmPtr(query); + var resultPtr = searchFunction(queryPtr, limit); - function passStringToWasm0(e, t, n) { - if (void 0 === n) { - const n = cachedTextEncoder.encode(e), - a = t(n.length); - return getUint8Memory0().subarray(a, a + n.length).set(n), WASM_VECTOR_LEN = n.length, a - } - let a = e.length, - o = t(a); - const i = getUint8Memory0(); - let r = 0; - for (; r < a; r++) { - const t = e.charCodeAt(r); - if (127 < t) break; - i[o + r] = t - } - if (r !== a) { - 0 !== r && (e = e.slice(r)), o = n(o, a, a = r + 3 * e.length); - const t = getUint8Memory0().subarray(o + r, o + a); - r += encodeString(e, t).written - } - return WASM_VECTOR_LEN = r, o - } + if (wasmModule.exports.__wbindgen_free && queryPtr > 1024) { + wasmModule.exports.__wbindgen_free(queryPtr, query.length + 1); + } - function getObject(e) { - return heap[e] - } + if (!resultPtr) return []; - function dropObject(e) { - e < 36 || (heap[e] = heap_next, heap_next = e) - } + var resultString = wasmPtrToString(resultPtr); + freeFunction(resultPtr); - function takeObject(e) { - var t = getObject(e); - return dropObject(e), t + if (!resultString) return []; + var results = JSON.parse(resultString); + return Array.isArray(results) ? results : []; + } catch (err) { + console.error("tinysearch error:", err); + return []; + } } - 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; - console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t) - } - var n = await e.arrayBuffer(); - return WebAssembly.instantiate(n, t) + async function initWasm(url) { + var response = await fetch(url); + if (!response.ok) { + throw new Error("Failed to fetch WASM: " + response.status + " " + response.statusText + " (" + url + ")"); } - n = await WebAssembly.instantiate(e, t); - return n instanceof WebAssembly.Instance ? { - instance: n, - module: e - } : n - } - async function init(e) { - var baseUrl = document.querySelector("meta[name='base']").getAttribute("content"); - if (baseUrl.slice(-1) == "/") { - baseUrl = baseUrl.slice(0, -1); + var wasmBytes = await response.arrayBuffer(); + var module = await WebAssembly.instantiate(wasmBytes); + wasmModule = module.instance; + memory = wasmModule.exports.memory; + searchFunction = wasmModule.exports.search; + freeFunction = wasmModule.exports.free_search_result; + + if (!searchFunction || !freeFunction || !memory) { + throw new Error("Required WASM exports not found (need search, free_search_result, memory)"); } - void 0 === e && (e = new URL(baseUrl + "/tinysearch_engine_bg.wasm")); - const t = { - wbg: {} - }; - t.wbg.__wbindgen_json_parse = function(e, t) { - return addHeapObject(JSON.parse(getStringFromWasm0(e, t))) - }; - var { - instance: e, - module: n - } = 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 = n, wasm + wasmReady = true; } + autocomplete(document.getElementById("searchinput")); document.goSearch.onsubmit = function () { return goSearchNow() }; }()); } diff --git a/static/sw.js b/static/sw.js index d9cb4c7..b87f7ff 100644 --- a/static/sw.js +++ b/static/sw.js @@ -1,191 +1,191 @@ -class Pwa {
-
- constructor(self) {
- this.scope = self;
- const Version = new URL(location).searchParams.get("v");
- this.CACHE_VERSION = Version;
- //this.BASE_CACHE_FILES=['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json'];
- this.BASE_CACHE_FILES = ['/','/404.html','/about/','/abridge.css','/android-chrome-192x192.png','/android-chrome-512x512.png','/apple-touch-icon.png','/archive/','/atom.xml','/banner.png','/blog/','/blog/page/1/','/browserconfig.xml','/contact/','/elasticlunr.min.js','/es/','/es/about/','/es/archive/','/es/atom.xml','/es/blog/','/es/blog/page/1/','/es/contact/','/es/page/1/','/es/privacy/','/es/tags/','/es/tags/features/','/es/tags/features/atom.xml','/es/tags/shortcodes/','/es/tags/shortcodes/atom.xml','/es/tags/video/','/es/tags/video/atom.xml','/es/video-streaming-sites/overview-embed-streamable/','/favicon-16x16.png','/favicon-32x32.png','/favicon.ico','/favicon.svg','/fonts/KaTeX_AMS-Regular.woff2','/fonts/KaTeX_Caligraphic-Bold.woff2','/fonts/KaTeX_Caligraphic-Regular.woff2','/fonts/KaTeX_Fraktur-Bold.woff2','/fonts/KaTeX_Fraktur-Regular.woff2','/fonts/KaTeX_Main-Bold.woff2','/fonts/KaTeX_Main-BoldItalic.woff2','/fonts/KaTeX_Main-Italic.woff2','/fonts/KaTeX_Main-Regular.woff2','/fonts/KaTeX_Math-BoldItalic.woff2','/fonts/KaTeX_Math-Italic.woff2','/fonts/KaTeX_SansSerif-Bold.woff2','/fonts/KaTeX_SansSerif-Italic.woff2','/fonts/KaTeX_SansSerif-Regular.woff2','/fonts/KaTeX_Script-Regular.woff2','/fonts/KaTeX_Size1-Regular.woff2','/fonts/KaTeX_Size2-Regular.woff2','/fonts/KaTeX_Size3-Regular.woff2','/fonts/KaTeX_Size4-Regular.woff2','/fonts/KaTeX_Typewriter-Regular.woff2','/fonts/Roboto-Bold.woff2','/fonts/Roboto-Italic.woff2','/fonts/Roboto-Mono-Italic.woff2','/fonts/Roboto-Mono.woff2','/fonts/Roboto.woff2','/fr/','/fr/about/','/fr/archive/','/fr/atom.xml','/fr/blog/','/fr/blog/page/1/','/fr/contact/','/fr/offline/','/fr/overview-code-blocks/','/fr/overview-images/','/fr/overview-images/corro.svg','/fr/overview-images/ferris-gesture.png','/fr/overview-images/ferris-gesture.svg','/fr/overview-images/ferris-happy.svg','/fr/overview-images/ferris.svg','/fr/overview-images/img/ferris-gesture.svg','/fr/overview-images/img/ferris.svg','/fr/overview-markdown-and-style/','/fr/overview-math/','/fr/overview-rich-content/','/fr/overview-rich-content/over9000-400.avif','/fr/overview-rich-content/over9000-640.avif','/fr/overview-rich-content/over9000-640.webp','/fr/overview-rich-content/over9000-960.avif','/fr/overview-rich-content/over9000.mp3','/fr/overview-rich-content/over9000.ogg','/fr/overview-rich-content/over9000_av1.mp4','/fr/overview-rich-content/over9000_vp9.webm','/fr/overview-showdata/','/fr/page/1/','/fr/page/2/','/fr/page/3/','/fr/privacy/','/fr/tags/','/fr/tags/audio/','/fr/tags/audio/atom.xml','/fr/tags/data/','/fr/tags/data/atom.xml','/fr/tags/features/','/fr/tags/features/atom.xml','/fr/tags/images/','/fr/tags/images/atom.xml','/fr/tags/markdown/','/fr/tags/markdown/atom.xml','/fr/tags/mathematics/','/fr/tags/mathematics/atom.xml','/fr/tags/shortcodes/','/fr/tags/shortcodes/atom.xml','/fr/tags/video/','/fr/tags/video/atom.xml','/fr/video-streaming-sites/overview-embed-streamable/','/fr/video-streaming-sites/overview-embed-vimeo/','/fr/video-streaming-sites/overview-embed-youtube/','/images/ferris-gesture.svg','/images/ferris.svg','/js/abridge.min.js','/js/abridge_nopwa.min.js','/js/abridge_nosearch.min.js','/js/abridge_nosearch_nopwa.min.js','/js/codecopy.js','/js/elasticlunr.min.js','/js/email.js','/js/katex-auto-render.min.js','/js/katex.min.js','/js/katexbundle.min.js','/js/katexoptions.js','/js/lunr.da.js','/js/lunr.da.min.js','/js/lunr.de.js','/js/lunr.de.min.js','/js/lunr.du.js','/js/lunr.du.min.js','/js/lunr.es.js','/js/lunr.es.min.js','/js/lunr.fi.js','/js/lunr.fi.min.js','/js/lunr.fr.js','/js/lunr.fr.min.js','/js/lunr.hu.js','/js/lunr.hu.min.js','/js/lunr.it.js','/js/lunr.it.min.js','/js/lunr.jp.js','/js/lunr.jp.min.js','/js/lunr.no.js','/js/lunr.no.min.js','/js/lunr.pt.js','/js/lunr.pt.min.js','/js/lunr.ro.js','/js/lunr.ro.min.js','/js/lunr.ru.js','/js/lunr.ru.min.js','/js/lunr.stemmer.support.js','/js/lunr.stemmer.support.min.js','/js/lunr.sv.js','/js/lunr.sv.min.js','/js/lunr.tr.js','/js/lunr.tr.min.js','/js/lunr.zh.js','/js/lunr.zh.min.js','/js/mathtex-script-type.min.js','/js/pagefind.search.js','/js/prestyle.js','/js/search.js','/js/search_elasticlunr.min.js','/js/search_tinysearch.min.js','/js/searchjava.js','/js/searchjavaugly.js','/js/sw_load.js','/js/sw_load.min.js','/js/theme.js','/js/theme.min.js','/js/theme_button.js','/js/theme_light.js','/js/theme_light.min.js','/js/tinysearch.js','/katex.min.css','/m1024.png','/m128.png','/m192.png','/m384.png','/m48.png','/m512.png','/m72.png','/m96.png','/manifest.json','/manifest.min.json','/mstile-150x150.png','/nojs.css','/offline/','/overview-abridge/','/overview-abridge/lighthouse.png','/overview-code-blocks/','/overview-images/','/overview-images/corro.svg','/overview-images/ferris-gesture.png','/overview-images/ferris-gesture.svg','/overview-images/ferris-happy.svg','/overview-images/ferris.svg','/overview-images/img/ferris-gesture.svg','/overview-images/img/ferris.svg','/overview-markdown-and-style/','/overview-math/','/overview-rich-content/','/overview-rich-content/over9000-400.avif','/overview-rich-content/over9000-640.avif','/overview-rich-content/over9000-640.webp','/overview-rich-content/over9000-960.avif','/overview-rich-content/over9000.mp3','/overview-rich-content/over9000.ogg','/overview-rich-content/over9000_av1.mp4','/overview-rich-content/over9000_vp9.webm','/overview-showdata/','/page/1/','/page/2/','/page/3/','/page/4/','/privacy/','/pt/','/pt/about/','/pt/contact/','/pt/page/1/','/pt/privacy/','/robots.txt','/safari-pinned-tab.svg','/search_index.en.json','/search_index.es.json','/search_index.fr.json','/search_index.pt.json','/sitemap.xml','/tags/','/tags/audio/','/tags/audio/atom.xml','/tags/config/','/tags/config/atom.xml','/tags/data/','/tags/data/atom.xml','/tags/features/','/tags/features/atom.xml','/tags/images/','/tags/images/atom.xml','/tags/markdown/','/tags/markdown/atom.xml','/tags/mathematics/','/tags/mathematics/atom.xml','/tags/shortcodes/','/tags/shortcodes/atom.xml','/tags/video/','/tags/video/atom.xml','/tinysearch_engine_bg.wasm','/video-streaming-sites/overview-embed-streamable/','/video-streaming-sites/overview-embed-vimeo/','/video-streaming-sites/overview-embed-youtube/'];
- this.host = `${self.location.protocol}//${self.location.host}`;
- console.info(`Host: ${this.host}`);
- this.OFFLINE_PAGE = '/offline/';
- this.NOT_FOUND_PAGE = '/404.html';
- this.CACHE_NAME = `content-v${this.CACHE_VERSION}`;
- // 3600=1hour, 28800=8hours, 86400=1day, 604800=1week, 1209600=2weeks
- this.NORM_TTL = 0;
- this.LONG_TTL = 0;
- // keep the ttl on these lower:
- this.TTL_NORM = ["sw.min.js", "sw_load.min.js"];
- // rarely change, may be a good idea to periodically refresh, incase I change these and forget to increment service worker version:
- this.TTL_LONG = ["jpg", "jpeg", "png", "gif", "webp", "avif", "ico", "svg", "xsl", "txt"];
- // never change, cache forever unless service worker version is incremented:
- this.TTL_EXEMPT = ["js", "css", "otf", "eot", "ttf", "woff", "woff2", "mp4", "webm", "mp3", "ogg"];
- // skip these extensions so they expire same time as html: st,wasm,json(search), xml(sitemap,atom,rss)
- }
-
- canCache(url) {
- if (url.startsWith("http://localhost")) {
- return false;
- }
- const result = url.toString().startsWith(this.host);
- return result;
- }
-
- getFileExtension(url) {
- const extension = url.split('.').reverse()[0].split('?')[0];
- return (extension.endsWith('/')) ? '/' : extension;
- }
- getFileName(url) {
- const filename = url.substring(url.lastIndexOf('/') + 1).split('?')[0];
- return (filename.endsWith('/')) ? '/' : filename;
- }
-
- getTTL(url) {
- if (typeof url === 'string') {
- const extension = this.getFileExtension(url);
- const filename = this.getFileName(url);
-
- if (this.TTL_NORM.indexOf(filename) > -1) {
- console.info(url + ' contains a TTL_NORM filename');
- return this.NORM_TTL;
- }
- if (this.TTL_LONG.indexOf(extension) > -1) {
- console.info(url + ' contains a TTL_LONG extension');
- return this.LONG_TTL;
- }
- if (this.TTL_EXEMPT.indexOf(extension) > -1) {
- console.info(url + ' contains a TTL_EXEMPT extension');
- return null;
- }
- console.info(url + ' TTL_NORM');
- return this.NORM_TTL;
- }
- return null;
- }
-
- async installServiceWorker() {
- try {
- await caches.open(this.CACHE_NAME).then((cache) => {
- return cache.addAll(this.BASE_CACHE_FILES);
- }, err => console.error(`Error with ${this.CACHE_NAME}`, err));
- return this.scope.skipWaiting();
- }
- catch (err) {
- return console.error("Error with installation: ", err);
- }
- }
-
- cleanupLegacyCache() {
-
- const currentCaches = [this.CACHE_NAME];
-
- return new Promise(
- (resolve, reject) => {
- caches.keys()
- .then((keys) => keys.filter((key) => !~currentCaches.indexOf(key)))
- .then((legacy) => {
- if (legacy.length) {
- Promise.all(legacy.map((legacyKey) => caches.delete(legacyKey))
- ).then(() => resolve()).catch((err) => {
- console.error("Error in legacy cleanup: ", err);
- reject(err);
- });
- } else {
- resolve();
- }
- }).catch((err) => {
- console.error("Error in legacy cleanup: ", err);
- reject(err);
- });
- });
- }
-
- async preCacheUrl(url) {
- const cache = await caches.open(this.CACHE_NAME);
- const response = await cache.match(url);
- if (!response) {
- return fetch(url).then(resp => cache.put(url, resp.clone()));
- }
- return null;
- }
-
- register() {
- this.scope.addEventListener('install', event => {
- event.waitUntil(
- Promise.all([
- this.installServiceWorker(),
- this.scope.skipWaiting(),
- ]));
- console.info('SW Installed');
- });
-
- this.scope.addEventListener('activate', event => {
- event.waitUntil(Promise.all(
- [this.cleanupLegacyCache(),
- this.scope.clients.claim(),
- this.scope.skipWaiting()]).catch((err) => {
- console.error("Activation error: ", err);
- event.skipWaiting();
- }));
- });
-
- this.scope.addEventListener('fetch', event => {
- event.respondWith(
- caches.open(this.CACHE_NAME).then(async cache => {
- // check if this is NOT a resource we allow cacheing (some other domain), if so fetch it instead of cache.
- if (!this.canCache(event.request.url)) {
- return fetch(event.request);
- }
- // check the cache for the requested resource
- const response = await cache.match(event.request);
- if (response) {
- const headers = response.headers.entries();
- let date = null;
- for (let pair of headers) {
- if (pair[0] === 'date') {
- date = new Date(pair[1]);
- break;
- }
- }
- // date is not working, so ignore TTL and just serve the cached resource.
- if (!date) {
- return response;
- }
- const age = parseInt(((new Date().getTime() - date.getTime()) / 1000).toString());
- const ttl = this.getTTL(event.request.url);
- if (ttl === null || (ttl && age < ttl)) {
- // return the resource if it is not beyond the TTL
- return response;
- }
- }
- // if we made it here then we either did not have the cache, or the TTL was expired.
- return fetch(event.request.clone()).then(resp => {
- if (resp.status < 400) {
- if (this.canCache(event.request.url)) {
- cache.put(event.request, resp.clone());
- }
- return resp;
- }
- else {
- return cache.match(this.NOT_FOUND_PAGE);
- }
- }).catch(err => {
- // if we made it here then we were unable to fetch the resource.
- // maybe we were only fetching because of expired TTL, so use the cache regardless of TTL:
- if (typeof event.request.url === 'string') {
- console.info("url: "+event.request.url)
- }
- if (response) {
- return response;
- }
- // if we made it here then we were unable to fetch the resource and do not have it cached.
- console.error(`Error fetching ${event.request.url} resulted in offline`, err);
- return cache.match(this.OFFLINE_PAGE);
- })
- }));
- });
- }
-}
-
-const pwa = new Pwa(self);
-pwa.register();
+class Pwa { + + constructor(self) { + this.scope = self; + const Version = new URL(location).searchParams.get("v"); + this.CACHE_VERSION = Version; + //this.BASE_CACHE_FILES=['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json']; + this.BASE_CACHE_FILES = ['/','/404.html','/about/','/abridge.css','/android-chrome-192x192.png','/android-chrome-512x512.png','/apple-touch-icon.png','/archive/','/atom.xml','/banner.png','/blog/','/blog/page/1/','/browserconfig.xml','/contact/','/elasticlunr.min.js','/es/','/es/about/','/es/archive/','/es/atom.xml','/es/blog/','/es/blog/page/1/','/es/contact/','/es/offline/','/es/overview-abridge/','/es/overview-abridge/lighthouse.png','/es/overview-code-blocks/','/es/overview-images/','/es/overview-images/corro.svg','/es/overview-images/ferris-gesture.png','/es/overview-images/ferris-gesture.svg','/es/overview-images/ferris-happy.svg','/es/overview-images/ferris.svg','/es/overview-images/img/ferris-gesture.svg','/es/overview-images/img/ferris.svg','/es/overview-markdown-and-style/','/es/overview-math/','/es/overview-rich-content/','/es/overview-rich-content/over9000-400.avif','/es/overview-rich-content/over9000-640.avif','/es/overview-rich-content/over9000-640.webp','/es/overview-rich-content/over9000-960.avif','/es/overview-rich-content/over9000.mp3','/es/overview-rich-content/over9000.ogg','/es/overview-rich-content/over9000_av1.mp4','/es/overview-rich-content/over9000_vp9.webm','/es/overview-showdata/','/es/page/1/','/es/page/2/','/es/page/3/','/es/page/4/','/es/privacy/','/es/tags/','/es/tags/audio/','/es/tags/audio/atom.xml','/es/tags/config/','/es/tags/config/atom.xml','/es/tags/data/','/es/tags/data/atom.xml','/es/tags/features/','/es/tags/features/atom.xml','/es/tags/images/','/es/tags/images/atom.xml','/es/tags/markdown/','/es/tags/markdown/atom.xml','/es/tags/mathematics/','/es/tags/mathematics/atom.xml','/es/tags/shortcodes/','/es/tags/shortcodes/atom.xml','/es/tags/video/','/es/tags/video/atom.xml','/es/video-streaming-sites/overview-embed-streamable/','/es/video-streaming-sites/overview-embed-vimeo/','/es/video-streaming-sites/overview-embed-youtube/','/favicon-16x16.png','/favicon-32x32.png','/favicon.ico','/favicon.svg','/fonts/KaTeX_AMS-Regular.woff2','/fonts/KaTeX_Caligraphic-Bold.woff2','/fonts/KaTeX_Caligraphic-Regular.woff2','/fonts/KaTeX_Fraktur-Bold.woff2','/fonts/KaTeX_Fraktur-Regular.woff2','/fonts/KaTeX_Main-Bold.woff2','/fonts/KaTeX_Main-BoldItalic.woff2','/fonts/KaTeX_Main-Italic.woff2','/fonts/KaTeX_Main-Regular.woff2','/fonts/KaTeX_Math-BoldItalic.woff2','/fonts/KaTeX_Math-Italic.woff2','/fonts/KaTeX_SansSerif-Bold.woff2','/fonts/KaTeX_SansSerif-Italic.woff2','/fonts/KaTeX_SansSerif-Regular.woff2','/fonts/KaTeX_Script-Regular.woff2','/fonts/KaTeX_Size1-Regular.woff2','/fonts/KaTeX_Size2-Regular.woff2','/fonts/KaTeX_Size3-Regular.woff2','/fonts/KaTeX_Size4-Regular.woff2','/fonts/KaTeX_Typewriter-Regular.woff2','/fonts/Roboto-Bold.woff2','/fonts/Roboto-Italic.woff2','/fonts/Roboto-Mono-Italic.woff2','/fonts/Roboto-Mono.woff2','/fonts/Roboto.woff2','/fr/','/fr/about/','/fr/archive/','/fr/atom.xml','/fr/blog/','/fr/blog/page/1/','/fr/contact/','/fr/offline/','/fr/overview-abridge/','/fr/overview-abridge/lighthouse.png','/fr/overview-code-blocks/','/fr/overview-images/','/fr/overview-images/corro.svg','/fr/overview-images/ferris-gesture.png','/fr/overview-images/ferris-gesture.svg','/fr/overview-images/ferris-happy.svg','/fr/overview-images/ferris.svg','/fr/overview-images/img/ferris-gesture.svg','/fr/overview-images/img/ferris.svg','/fr/overview-markdown-and-style/','/fr/overview-math/','/fr/overview-rich-content/','/fr/overview-rich-content/over9000-400.avif','/fr/overview-rich-content/over9000-640.avif','/fr/overview-rich-content/over9000-640.webp','/fr/overview-rich-content/over9000-960.avif','/fr/overview-rich-content/over9000.mp3','/fr/overview-rich-content/over9000.ogg','/fr/overview-rich-content/over9000_av1.mp4','/fr/overview-rich-content/over9000_vp9.webm','/fr/overview-showdata/','/fr/page/1/','/fr/page/2/','/fr/page/3/','/fr/page/4/','/fr/privacy/','/fr/tags/','/fr/tags/audio/','/fr/tags/audio/atom.xml','/fr/tags/config/','/fr/tags/config/atom.xml','/fr/tags/data/','/fr/tags/data/atom.xml','/fr/tags/features/','/fr/tags/features/atom.xml','/fr/tags/images/','/fr/tags/images/atom.xml','/fr/tags/markdown/','/fr/tags/markdown/atom.xml','/fr/tags/mathematics/','/fr/tags/mathematics/atom.xml','/fr/tags/shortcodes/','/fr/tags/shortcodes/atom.xml','/fr/tags/video/','/fr/tags/video/atom.xml','/fr/video-streaming-sites/overview-embed-streamable/','/fr/video-streaming-sites/overview-embed-vimeo/','/fr/video-streaming-sites/overview-embed-youtube/','/giallo.css','/images/ferris-gesture.svg','/images/ferris.svg','/js/abridge.min.js','/js/abridge_nopwa.min.js','/js/abridge_nosearch.min.js','/js/abridge_nosearch_nopwa.min.js','/js/codecopy.js','/js/elasticlunr.min.js','/js/email.js','/js/katex-auto-render.min.js','/js/katex.min.js','/js/katexbundle.min.js','/js/katexoptions.js','/js/lunr.da.js','/js/lunr.da.min.js','/js/lunr.de.js','/js/lunr.de.min.js','/js/lunr.du.js','/js/lunr.du.min.js','/js/lunr.es.js','/js/lunr.es.min.js','/js/lunr.fi.js','/js/lunr.fi.min.js','/js/lunr.fr.js','/js/lunr.fr.min.js','/js/lunr.hu.js','/js/lunr.hu.min.js','/js/lunr.it.js','/js/lunr.it.min.js','/js/lunr.jp.js','/js/lunr.jp.min.js','/js/lunr.no.js','/js/lunr.no.min.js','/js/lunr.pt.js','/js/lunr.pt.min.js','/js/lunr.ro.js','/js/lunr.ro.min.js','/js/lunr.ru.js','/js/lunr.ru.min.js','/js/lunr.stemmer.support.js','/js/lunr.stemmer.support.min.js','/js/lunr.sv.js','/js/lunr.sv.min.js','/js/lunr.tr.js','/js/lunr.tr.min.js','/js/lunr.zh.js','/js/lunr.zh.min.js','/js/mathtex-script-type.min.js','/js/pagefind.search.js','/js/prestyle.js','/js/search.js','/js/search_elasticlunr.min.js','/js/search_tinysearch.min.js','/js/searchjava.js','/js/searchjavaugly.js','/js/sw_load.js','/js/sw_load.min.js','/js/theme.js','/js/theme.min.js','/js/theme_button.js','/js/theme_light.js','/js/theme_light.min.js','/js/tinysearch.js','/katex.min.css','/m1024.png','/m128.png','/m192.png','/m384.png','/m48.png','/m512.png','/m72.png','/m96.png','/manifest.json','/manifest.min.json','/mstile-150x150.png','/nojs.css','/offline/','/overview-abridge/','/overview-abridge/lighthouse.png','/overview-code-blocks/','/overview-images/','/overview-images/corro.svg','/overview-images/ferris-gesture.png','/overview-images/ferris-gesture.svg','/overview-images/ferris-happy.svg','/overview-images/ferris.svg','/overview-images/img/ferris-gesture.svg','/overview-images/img/ferris.svg','/overview-markdown-and-style/','/overview-math/','/overview-rich-content/','/overview-rich-content/over9000-400.avif','/overview-rich-content/over9000-640.avif','/overview-rich-content/over9000-640.webp','/overview-rich-content/over9000-960.avif','/overview-rich-content/over9000.mp3','/overview-rich-content/over9000.ogg','/overview-rich-content/over9000_av1.mp4','/overview-rich-content/over9000_vp9.webm','/overview-showdata/','/page/1/','/page/2/','/page/3/','/page/4/','/privacy/','/pt/','/pt/about/','/pt/atom.xml','/pt/contact/','/pt/offline/','/pt/page/1/','/pt/privacy/','/robots.txt','/safari-pinned-tab.svg','/search_index.en.json','/search_index.es.json','/search_index.fr.json','/search_index.pt.json','/sitemap.xml','/tags/','/tags/audio/','/tags/audio/atom.xml','/tags/config/','/tags/config/atom.xml','/tags/data/','/tags/data/atom.xml','/tags/features/','/tags/features/atom.xml','/tags/images/','/tags/images/atom.xml','/tags/markdown/','/tags/markdown/atom.xml','/tags/mathematics/','/tags/mathematics/atom.xml','/tags/shortcodes/','/tags/shortcodes/atom.xml','/tags/video/','/tags/video/atom.xml','/tinysearch.toml','/tinysearch_engine.wasm','/video-streaming-sites/overview-embed-streamable/','/video-streaming-sites/overview-embed-vimeo/','/video-streaming-sites/overview-embed-youtube/']; + this.host = `${self.location.protocol}//${self.location.host}`; + console.info(`Host: ${this.host}`); + this.OFFLINE_PAGE = '/offline/'; + this.NOT_FOUND_PAGE = '/404.html'; + this.CACHE_NAME = `content-v${this.CACHE_VERSION}`; + // 3600=1hour, 28800=8hours, 86400=1day, 604800=1week, 1209600=2weeks + this.NORM_TTL = 0; + this.LONG_TTL = 0; + // keep the ttl on these lower: + this.TTL_NORM = ["sw.min.js", "sw_load.min.js"]; + // rarely change, may be a good idea to periodically refresh, incase I change these and forget to increment service worker version: + this.TTL_LONG = ["jpg", "jpeg", "png", "gif", "webp", "avif", "ico", "svg", "xsl", "txt"]; + // never change, cache forever unless service worker version is incremented: + this.TTL_EXEMPT = ["js", "css", "otf", "eot", "ttf", "woff", "woff2", "mp4", "webm", "mp3", "ogg"]; + // skip these extensions so they expire same time as html: st,wasm,json(search), xml(sitemap,atom,rss) + } + + canCache(url) { + if (url.startsWith("http://localhost")) { + return false; + } + const result = url.toString().startsWith(this.host); + return result; + } + + getFileExtension(url) { + const extension = url.split('.').reverse()[0].split('?')[0]; + return (extension.endsWith('/')) ? '/' : extension; + } + getFileName(url) { + const filename = url.substring(url.lastIndexOf('/') + 1).split('?')[0]; + return (filename.endsWith('/')) ? '/' : filename; + } + + getTTL(url) { + if (typeof url === 'string') { + const extension = this.getFileExtension(url); + const filename = this.getFileName(url); + + if (this.TTL_NORM.indexOf(filename) > -1) { + console.info(url + ' contains a TTL_NORM filename'); + return this.NORM_TTL; + } + if (this.TTL_LONG.indexOf(extension) > -1) { + console.info(url + ' contains a TTL_LONG extension'); + return this.LONG_TTL; + } + if (this.TTL_EXEMPT.indexOf(extension) > -1) { + console.info(url + ' contains a TTL_EXEMPT extension'); + return null; + } + console.info(url + ' TTL_NORM'); + return this.NORM_TTL; + } + return null; + } + + async installServiceWorker() { + try { + await caches.open(this.CACHE_NAME).then((cache) => { + return cache.addAll(this.BASE_CACHE_FILES); + }, err => console.error(`Error with ${this.CACHE_NAME}`, err)); + return this.scope.skipWaiting(); + } + catch (err) { + return console.error("Error with installation: ", err); + } + } + + cleanupLegacyCache() { + + const currentCaches = [this.CACHE_NAME]; + + return new Promise( + (resolve, reject) => { + caches.keys() + .then((keys) => keys.filter((key) => !~currentCaches.indexOf(key))) + .then((legacy) => { + if (legacy.length) { + Promise.all(legacy.map((legacyKey) => caches.delete(legacyKey)) + ).then(() => resolve()).catch((err) => { + console.error("Error in legacy cleanup: ", err); + reject(err); + }); + } else { + resolve(); + } + }).catch((err) => { + console.error("Error in legacy cleanup: ", err); + reject(err); + }); + }); + } + + async preCacheUrl(url) { + const cache = await caches.open(this.CACHE_NAME); + const response = await cache.match(url); + if (!response) { + return fetch(url).then(resp => cache.put(url, resp.clone())); + } + return null; + } + + register() { + this.scope.addEventListener('install', event => { + event.waitUntil( + Promise.all([ + this.installServiceWorker(), + this.scope.skipWaiting(), + ])); + console.info('SW Installed'); + }); + + this.scope.addEventListener('activate', event => { + event.waitUntil(Promise.all( + [this.cleanupLegacyCache(), + this.scope.clients.claim(), + this.scope.skipWaiting()]).catch((err) => { + console.error("Activation error: ", err); + event.skipWaiting(); + })); + }); + + this.scope.addEventListener('fetch', event => { + event.respondWith( + caches.open(this.CACHE_NAME).then(async cache => { + // check if this is NOT a resource we allow cacheing (some other domain), if so fetch it instead of cache. + if (!this.canCache(event.request.url)) { + return fetch(event.request); + } + // check the cache for the requested resource + const response = await cache.match(event.request); + if (response) { + const headers = response.headers.entries(); + let date = null; + for (let pair of headers) { + if (pair[0] === 'date') { + date = new Date(pair[1]); + break; + } + } + // date is not working, so ignore TTL and just serve the cached resource. + if (!date) { + return response; + } + const age = parseInt(((new Date().getTime() - date.getTime()) / 1000).toString()); + const ttl = this.getTTL(event.request.url); + if (ttl === null || (ttl && age < ttl)) { + // return the resource if it is not beyond the TTL + return response; + } + } + // if we made it here then we either did not have the cache, or the TTL was expired. + return fetch(event.request.clone()).then(resp => { + if (resp.status < 400) { + if (this.canCache(event.request.url)) { + cache.put(event.request, resp.clone()); + } + return resp; + } + else { + return cache.match(this.NOT_FOUND_PAGE); + } + }).catch(err => { + // if we made it here then we were unable to fetch the resource. + // maybe we were only fetching because of expired TTL, so use the cache regardless of TTL: + if (typeof event.request.url === 'string') { + console.info("url: "+event.request.url) + } + if (response) { + return response; + } + // if we made it here then we were unable to fetch the resource and do not have it cached. + console.error(`Error fetching ${event.request.url} resulted in offline`, err); + return cache.match(this.OFFLINE_PAGE); + }) + })); + }); + } +} + +const pwa = new Pwa(self); +pwa.register(); diff --git a/static/sw.min.js b/static/sw.min.js index 16b26b9..a0bb209 100644 --- a/static/sw.min.js +++ b/static/sw.min.js @@ -1 +1 @@ -class Pwa{constructor(e){this.scope=e;var s=new URL(location).searchParams.get("v");this.CACHE_VERSION=s,this.BASE_CACHE_FILES=["/","/404.html","/about/","/abridge.css","/android-chrome-192x192.png","/android-chrome-512x512.png","/apple-touch-icon.png","/archive/","/atom.xml","/banner.png","/blog/","/blog/page/1/","/browserconfig.xml","/contact/","/elasticlunr.min.js","/es/","/es/about/","/es/archive/","/es/atom.xml","/es/blog/","/es/blog/page/1/","/es/contact/","/es/page/1/","/es/privacy/","/es/tags/","/es/tags/features/","/es/tags/features/atom.xml","/es/tags/shortcodes/","/es/tags/shortcodes/atom.xml","/es/tags/video/","/es/tags/video/atom.xml","/es/video-streaming-sites/overview-embed-streamable/","/favicon-16x16.png","/favicon-32x32.png","/favicon.ico","/favicon.svg","/fonts/KaTeX_AMS-Regular.woff2","/fonts/KaTeX_Caligraphic-Bold.woff2","/fonts/KaTeX_Caligraphic-Regular.woff2","/fonts/KaTeX_Fraktur-Bold.woff2","/fonts/KaTeX_Fraktur-Regular.woff2","/fonts/KaTeX_Main-Bold.woff2","/fonts/KaTeX_Main-BoldItalic.woff2","/fonts/KaTeX_Main-Italic.woff2","/fonts/KaTeX_Main-Regular.woff2","/fonts/KaTeX_Math-BoldItalic.woff2","/fonts/KaTeX_Math-Italic.woff2","/fonts/KaTeX_SansSerif-Bold.woff2","/fonts/KaTeX_SansSerif-Italic.woff2","/fonts/KaTeX_SansSerif-Regular.woff2","/fonts/KaTeX_Script-Regular.woff2","/fonts/KaTeX_Size1-Regular.woff2","/fonts/KaTeX_Size2-Regular.woff2","/fonts/KaTeX_Size3-Regular.woff2","/fonts/KaTeX_Size4-Regular.woff2","/fonts/KaTeX_Typewriter-Regular.woff2","/fonts/Roboto-Bold.woff2","/fonts/Roboto-Italic.woff2","/fonts/Roboto-Mono-Italic.woff2","/fonts/Roboto-Mono.woff2","/fonts/Roboto.woff2","/fr/","/fr/about/","/fr/archive/","/fr/atom.xml","/fr/blog/","/fr/blog/page/1/","/fr/contact/","/fr/offline/","/fr/overview-code-blocks/","/fr/overview-images/","/fr/overview-images/corro.svg","/fr/overview-images/ferris-gesture.png","/fr/overview-images/ferris-gesture.svg","/fr/overview-images/ferris-happy.svg","/fr/overview-images/ferris.svg","/fr/overview-images/img/ferris-gesture.svg","/fr/overview-images/img/ferris.svg","/fr/overview-markdown-and-style/","/fr/overview-math/","/fr/overview-rich-content/","/fr/overview-rich-content/over9000-400.avif","/fr/overview-rich-content/over9000-640.avif","/fr/overview-rich-content/over9000-640.webp","/fr/overview-rich-content/over9000-960.avif","/fr/overview-rich-content/over9000.mp3","/fr/overview-rich-content/over9000.ogg","/fr/overview-rich-content/over9000_av1.mp4","/fr/overview-rich-content/over9000_vp9.webm","/fr/overview-showdata/","/fr/page/1/","/fr/page/2/","/fr/page/3/","/fr/privacy/","/fr/tags/","/fr/tags/audio/","/fr/tags/audio/atom.xml","/fr/tags/data/","/fr/tags/data/atom.xml","/fr/tags/features/","/fr/tags/features/atom.xml","/fr/tags/images/","/fr/tags/images/atom.xml","/fr/tags/markdown/","/fr/tags/markdown/atom.xml","/fr/tags/mathematics/","/fr/tags/mathematics/atom.xml","/fr/tags/shortcodes/","/fr/tags/shortcodes/atom.xml","/fr/tags/video/","/fr/tags/video/atom.xml","/fr/video-streaming-sites/overview-embed-streamable/","/fr/video-streaming-sites/overview-embed-vimeo/","/fr/video-streaming-sites/overview-embed-youtube/","/images/ferris-gesture.svg","/images/ferris.svg","/js/abridge.min.js","/js/abridge_nopwa.min.js","/js/abridge_nosearch.min.js","/js/abridge_nosearch_nopwa.min.js","/js/codecopy.js","/js/elasticlunr.min.js","/js/email.js","/js/katex-auto-render.min.js","/js/katex.min.js","/js/katexbundle.min.js","/js/katexoptions.js","/js/lunr.da.js","/js/lunr.da.min.js","/js/lunr.de.js","/js/lunr.de.min.js","/js/lunr.du.js","/js/lunr.du.min.js","/js/lunr.es.js","/js/lunr.es.min.js","/js/lunr.fi.js","/js/lunr.fi.min.js","/js/lunr.fr.js","/js/lunr.fr.min.js","/js/lunr.hu.js","/js/lunr.hu.min.js","/js/lunr.it.js","/js/lunr.it.min.js","/js/lunr.jp.js","/js/lunr.jp.min.js","/js/lunr.no.js","/js/lunr.no.min.js","/js/lunr.pt.js","/js/lunr.pt.min.js","/js/lunr.ro.js","/js/lunr.ro.min.js","/js/lunr.ru.js","/js/lunr.ru.min.js","/js/lunr.stemmer.support.js","/js/lunr.stemmer.support.min.js","/js/lunr.sv.js","/js/lunr.sv.min.js","/js/lunr.tr.js","/js/lunr.tr.min.js","/js/lunr.zh.js","/js/lunr.zh.min.js","/js/mathtex-script-type.min.js","/js/pagefind.search.js","/js/prestyle.js","/js/search.js","/js/search_elasticlunr.min.js","/js/search_tinysearch.min.js","/js/searchjava.js","/js/searchjavaugly.js","/js/sw_load.js","/js/sw_load.min.js","/js/theme.js","/js/theme.min.js","/js/theme_button.js","/js/theme_light.js","/js/theme_light.min.js","/js/tinysearch.js","/katex.min.css","/m1024.png","/m128.png","/m192.png","/m384.png","/m48.png","/m512.png","/m72.png","/m96.png","/manifest.json","/manifest.min.json","/mstile-150x150.png","/nojs.css","/offline/","/overview-abridge/","/overview-abridge/lighthouse.png","/overview-code-blocks/","/overview-images/","/overview-images/corro.svg","/overview-images/ferris-gesture.png","/overview-images/ferris-gesture.svg","/overview-images/ferris-happy.svg","/overview-images/ferris.svg","/overview-images/img/ferris-gesture.svg","/overview-images/img/ferris.svg","/overview-markdown-and-style/","/overview-math/","/overview-rich-content/","/overview-rich-content/over9000-400.avif","/overview-rich-content/over9000-640.avif","/overview-rich-content/over9000-640.webp","/overview-rich-content/over9000-960.avif","/overview-rich-content/over9000.mp3","/overview-rich-content/over9000.ogg","/overview-rich-content/over9000_av1.mp4","/overview-rich-content/over9000_vp9.webm","/overview-showdata/","/page/1/","/page/2/","/page/3/","/page/4/","/privacy/","/pt/","/pt/about/","/pt/contact/","/pt/page/1/","/pt/privacy/","/robots.txt","/safari-pinned-tab.svg","/search_index.en.json","/search_index.es.json","/search_index.fr.json","/search_index.pt.json","/sitemap.xml","/tags/","/tags/audio/","/tags/audio/atom.xml","/tags/config/","/tags/config/atom.xml","/tags/data/","/tags/data/atom.xml","/tags/features/","/tags/features/atom.xml","/tags/images/","/tags/images/atom.xml","/tags/markdown/","/tags/markdown/atom.xml","/tags/mathematics/","/tags/mathematics/atom.xml","/tags/shortcodes/","/tags/shortcodes/atom.xml","/tags/video/","/tags/video/atom.xml","/tinysearch_engine_bg.wasm","/video-streaming-sites/overview-embed-streamable/","/video-streaming-sites/overview-embed-vimeo/","/video-streaming-sites/overview-embed-youtube/"],this.host=e.location.protocol+"//"+e.location.host,this.OFFLINE_PAGE="/offline/",this.NOT_FOUND_PAGE="/404.html",this.CACHE_NAME="content-v"+this.CACHE_VERSION,this.NORM_TTL=0,this.LONG_TTL=0,this.TTL_NORM=["sw.min.js","sw_load.min.js"],this.TTL_LONG=["jpg","jpeg","png","gif","webp","avif","ico","svg","xsl","txt"],this.TTL_EXEMPT=["js","css","otf","eot","ttf","woff","woff2","mp4","webm","mp3","ogg"]}canCache(e){return!e.startsWith("http://localhost")&&e.toString().startsWith(this.host)}getFileExtension(e){e=e.split(".").reverse()[0].split("?")[0];return e.endsWith("/")?"/":e}getFileName(e){e=e.substring(1+e.lastIndexOf("/")).split("?")[0];return e.endsWith("/")?"/":e}getTTL(e){var s;return"string"==typeof e?(s=this.getFileExtension(e),e=this.getFileName(e),~this.TTL_NORM.indexOf(e)?this.NORM_TTL:~this.TTL_LONG.indexOf(s)?this.LONG_TTL:~this.TTL_EXEMPT.indexOf(s)?null:this.NORM_TTL):null}async installServiceWorker(){try{return await caches.open(this.CACHE_NAME).then(e=>e.addAll(this.BASE_CACHE_FILES),e=>{}),this.scope.skipWaiting()}catch(e){}}cleanupLegacyCache(){let r=[this.CACHE_NAME];return new Promise((s,t)=>{caches.keys().then(e=>e.filter(e=>!~r.indexOf(e))).then(e=>{e.length?Promise.all(e.map(e=>caches.delete(e))).then(()=>s()).catch(e=>{t(e)}):s()}).catch(e=>{t(e)})})}async preCacheUrl(s){let t=await caches.open(this.CACHE_NAME);return await t.match(s)?null:fetch(s).then(e=>t.put(s,e.clone()))}register(){this.scope.addEventListener("install",e=>{e.waitUntil(Promise.all([this.installServiceWorker(),this.scope.skipWaiting()]))}),this.scope.addEventListener("activate",s=>{s.waitUntil(Promise.all([this.cleanupLegacyCache(),this.scope.clients.claim(),this.scope.skipWaiting()]).catch(e=>{s.skipWaiting()}))}),this.scope.addEventListener("fetch",o=>{o.respondWith(caches.open(this.CACHE_NAME).then(async s=>{if(!this.canCache(o.request.url))return fetch(o.request);let t=await s.match(o.request);if(t){var r;let e=null;for(r of t.headers.entries())if("date"===r[0]){e=new Date(r[1]);break}if(!e)return t;var i=parseInt(""+((new Date).getTime()-e.getTime())/1e3),a=this.getTTL(o.request.url);if(null===a||a&&i<a)return t}return fetch(o.request.clone()).then(e=>e.status<400?(this.canCache(o.request.url)&&s.put(o.request,e.clone()),e):s.match(this.NOT_FOUND_PAGE)).catch(e=>(o.request.url,t||s.match(this.OFFLINE_PAGE)))}))})}}let pwa=new Pwa(self);pwa.register();
\ No newline at end of file +class Pwa{constructor(e){this.scope=e;var s=new URL(location).searchParams.get("v");this.CACHE_VERSION=s,this.BASE_CACHE_FILES=["/","/404.html","/about/","/abridge.css","/android-chrome-192x192.png","/android-chrome-512x512.png","/apple-touch-icon.png","/archive/","/atom.xml","/banner.png","/blog/","/blog/page/1/","/browserconfig.xml","/contact/","/elasticlunr.min.js","/es/","/es/about/","/es/archive/","/es/atom.xml","/es/blog/","/es/blog/page/1/","/es/contact/","/es/offline/","/es/overview-abridge/","/es/overview-abridge/lighthouse.png","/es/overview-code-blocks/","/es/overview-images/","/es/overview-images/corro.svg","/es/overview-images/ferris-gesture.png","/es/overview-images/ferris-gesture.svg","/es/overview-images/ferris-happy.svg","/es/overview-images/ferris.svg","/es/overview-images/img/ferris-gesture.svg","/es/overview-images/img/ferris.svg","/es/overview-markdown-and-style/","/es/overview-math/","/es/overview-rich-content/","/es/overview-rich-content/over9000-400.avif","/es/overview-rich-content/over9000-640.avif","/es/overview-rich-content/over9000-640.webp","/es/overview-rich-content/over9000-960.avif","/es/overview-rich-content/over9000.mp3","/es/overview-rich-content/over9000.ogg","/es/overview-rich-content/over9000_av1.mp4","/es/overview-rich-content/over9000_vp9.webm","/es/overview-showdata/","/es/page/1/","/es/page/2/","/es/page/3/","/es/page/4/","/es/privacy/","/es/tags/","/es/tags/audio/","/es/tags/audio/atom.xml","/es/tags/config/","/es/tags/config/atom.xml","/es/tags/data/","/es/tags/data/atom.xml","/es/tags/features/","/es/tags/features/atom.xml","/es/tags/images/","/es/tags/images/atom.xml","/es/tags/markdown/","/es/tags/markdown/atom.xml","/es/tags/mathematics/","/es/tags/mathematics/atom.xml","/es/tags/shortcodes/","/es/tags/shortcodes/atom.xml","/es/tags/video/","/es/tags/video/atom.xml","/es/video-streaming-sites/overview-embed-streamable/","/es/video-streaming-sites/overview-embed-vimeo/","/es/video-streaming-sites/overview-embed-youtube/","/favicon-16x16.png","/favicon-32x32.png","/favicon.ico","/favicon.svg","/fonts/KaTeX_AMS-Regular.woff2","/fonts/KaTeX_Caligraphic-Bold.woff2","/fonts/KaTeX_Caligraphic-Regular.woff2","/fonts/KaTeX_Fraktur-Bold.woff2","/fonts/KaTeX_Fraktur-Regular.woff2","/fonts/KaTeX_Main-Bold.woff2","/fonts/KaTeX_Main-BoldItalic.woff2","/fonts/KaTeX_Main-Italic.woff2","/fonts/KaTeX_Main-Regular.woff2","/fonts/KaTeX_Math-BoldItalic.woff2","/fonts/KaTeX_Math-Italic.woff2","/fonts/KaTeX_SansSerif-Bold.woff2","/fonts/KaTeX_SansSerif-Italic.woff2","/fonts/KaTeX_SansSerif-Regular.woff2","/fonts/KaTeX_Script-Regular.woff2","/fonts/KaTeX_Size1-Regular.woff2","/fonts/KaTeX_Size2-Regular.woff2","/fonts/KaTeX_Size3-Regular.woff2","/fonts/KaTeX_Size4-Regular.woff2","/fonts/KaTeX_Typewriter-Regular.woff2","/fonts/Roboto-Bold.woff2","/fonts/Roboto-Italic.woff2","/fonts/Roboto-Mono-Italic.woff2","/fonts/Roboto-Mono.woff2","/fonts/Roboto.woff2","/fr/","/fr/about/","/fr/archive/","/fr/atom.xml","/fr/blog/","/fr/blog/page/1/","/fr/contact/","/fr/offline/","/fr/overview-abridge/","/fr/overview-abridge/lighthouse.png","/fr/overview-code-blocks/","/fr/overview-images/","/fr/overview-images/corro.svg","/fr/overview-images/ferris-gesture.png","/fr/overview-images/ferris-gesture.svg","/fr/overview-images/ferris-happy.svg","/fr/overview-images/ferris.svg","/fr/overview-images/img/ferris-gesture.svg","/fr/overview-images/img/ferris.svg","/fr/overview-markdown-and-style/","/fr/overview-math/","/fr/overview-rich-content/","/fr/overview-rich-content/over9000-400.avif","/fr/overview-rich-content/over9000-640.avif","/fr/overview-rich-content/over9000-640.webp","/fr/overview-rich-content/over9000-960.avif","/fr/overview-rich-content/over9000.mp3","/fr/overview-rich-content/over9000.ogg","/fr/overview-rich-content/over9000_av1.mp4","/fr/overview-rich-content/over9000_vp9.webm","/fr/overview-showdata/","/fr/page/1/","/fr/page/2/","/fr/page/3/","/fr/page/4/","/fr/privacy/","/fr/tags/","/fr/tags/audio/","/fr/tags/audio/atom.xml","/fr/tags/config/","/fr/tags/config/atom.xml","/fr/tags/data/","/fr/tags/data/atom.xml","/fr/tags/features/","/fr/tags/features/atom.xml","/fr/tags/images/","/fr/tags/images/atom.xml","/fr/tags/markdown/","/fr/tags/markdown/atom.xml","/fr/tags/mathematics/","/fr/tags/mathematics/atom.xml","/fr/tags/shortcodes/","/fr/tags/shortcodes/atom.xml","/fr/tags/video/","/fr/tags/video/atom.xml","/fr/video-streaming-sites/overview-embed-streamable/","/fr/video-streaming-sites/overview-embed-vimeo/","/fr/video-streaming-sites/overview-embed-youtube/","/giallo.css","/images/ferris-gesture.svg","/images/ferris.svg","/js/abridge.min.js","/js/abridge_nopwa.min.js","/js/abridge_nosearch.min.js","/js/abridge_nosearch_nopwa.min.js","/js/codecopy.js","/js/elasticlunr.min.js","/js/email.js","/js/katex-auto-render.min.js","/js/katex.min.js","/js/katexbundle.min.js","/js/katexoptions.js","/js/lunr.da.js","/js/lunr.da.min.js","/js/lunr.de.js","/js/lunr.de.min.js","/js/lunr.du.js","/js/lunr.du.min.js","/js/lunr.es.js","/js/lunr.es.min.js","/js/lunr.fi.js","/js/lunr.fi.min.js","/js/lunr.fr.js","/js/lunr.fr.min.js","/js/lunr.hu.js","/js/lunr.hu.min.js","/js/lunr.it.js","/js/lunr.it.min.js","/js/lunr.jp.js","/js/lunr.jp.min.js","/js/lunr.no.js","/js/lunr.no.min.js","/js/lunr.pt.js","/js/lunr.pt.min.js","/js/lunr.ro.js","/js/lunr.ro.min.js","/js/lunr.ru.js","/js/lunr.ru.min.js","/js/lunr.stemmer.support.js","/js/lunr.stemmer.support.min.js","/js/lunr.sv.js","/js/lunr.sv.min.js","/js/lunr.tr.js","/js/lunr.tr.min.js","/js/lunr.zh.js","/js/lunr.zh.min.js","/js/mathtex-script-type.min.js","/js/pagefind.search.js","/js/prestyle.js","/js/search.js","/js/search_elasticlunr.min.js","/js/search_tinysearch.min.js","/js/searchjava.js","/js/searchjavaugly.js","/js/sw_load.js","/js/sw_load.min.js","/js/theme.js","/js/theme.min.js","/js/theme_button.js","/js/theme_light.js","/js/theme_light.min.js","/js/tinysearch.js","/katex.min.css","/m1024.png","/m128.png","/m192.png","/m384.png","/m48.png","/m512.png","/m72.png","/m96.png","/manifest.json","/manifest.min.json","/mstile-150x150.png","/nojs.css","/offline/","/overview-abridge/","/overview-abridge/lighthouse.png","/overview-code-blocks/","/overview-images/","/overview-images/corro.svg","/overview-images/ferris-gesture.png","/overview-images/ferris-gesture.svg","/overview-images/ferris-happy.svg","/overview-images/ferris.svg","/overview-images/img/ferris-gesture.svg","/overview-images/img/ferris.svg","/overview-markdown-and-style/","/overview-math/","/overview-rich-content/","/overview-rich-content/over9000-400.avif","/overview-rich-content/over9000-640.avif","/overview-rich-content/over9000-640.webp","/overview-rich-content/over9000-960.avif","/overview-rich-content/over9000.mp3","/overview-rich-content/over9000.ogg","/overview-rich-content/over9000_av1.mp4","/overview-rich-content/over9000_vp9.webm","/overview-showdata/","/page/1/","/page/2/","/page/3/","/page/4/","/privacy/","/pt/","/pt/about/","/pt/atom.xml","/pt/contact/","/pt/offline/","/pt/page/1/","/pt/privacy/","/robots.txt","/safari-pinned-tab.svg","/search_index.en.json","/search_index.es.json","/search_index.fr.json","/search_index.pt.json","/sitemap.xml","/tags/","/tags/audio/","/tags/audio/atom.xml","/tags/config/","/tags/config/atom.xml","/tags/data/","/tags/data/atom.xml","/tags/features/","/tags/features/atom.xml","/tags/images/","/tags/images/atom.xml","/tags/markdown/","/tags/markdown/atom.xml","/tags/mathematics/","/tags/mathematics/atom.xml","/tags/shortcodes/","/tags/shortcodes/atom.xml","/tags/video/","/tags/video/atom.xml","/tinysearch.toml","/tinysearch_engine.wasm","/video-streaming-sites/overview-embed-streamable/","/video-streaming-sites/overview-embed-vimeo/","/video-streaming-sites/overview-embed-youtube/"],this.host=e.location.protocol+"//"+e.location.host,this.OFFLINE_PAGE="/offline/",this.NOT_FOUND_PAGE="/404.html",this.CACHE_NAME="content-v"+this.CACHE_VERSION,this.NORM_TTL=0,this.LONG_TTL=0,this.TTL_NORM=["sw.min.js","sw_load.min.js"],this.TTL_LONG=["jpg","jpeg","png","gif","webp","avif","ico","svg","xsl","txt"],this.TTL_EXEMPT=["js","css","otf","eot","ttf","woff","woff2","mp4","webm","mp3","ogg"]}canCache(e){return!e.startsWith("http://localhost")&&e.toString().startsWith(this.host)}getFileExtension(e){e=e.split(".").reverse()[0].split("?")[0];return e.endsWith("/")?"/":e}getFileName(e){e=e.substring(1+e.lastIndexOf("/")).split("?")[0];return e.endsWith("/")?"/":e}getTTL(e){var s;return"string"==typeof e?(s=this.getFileExtension(e),e=this.getFileName(e),~this.TTL_NORM.indexOf(e)?this.NORM_TTL:~this.TTL_LONG.indexOf(s)?this.LONG_TTL:~this.TTL_EXEMPT.indexOf(s)?null:this.NORM_TTL):null}async installServiceWorker(){try{return await caches.open(this.CACHE_NAME).then(e=>e.addAll(this.BASE_CACHE_FILES),e=>{}),this.scope.skipWaiting()}catch(e){}}cleanupLegacyCache(){let r=[this.CACHE_NAME];return new Promise((s,t)=>{caches.keys().then(e=>e.filter(e=>!~r.indexOf(e))).then(e=>{e.length?Promise.all(e.map(e=>caches.delete(e))).then(()=>s()).catch(e=>{t(e)}):s()}).catch(e=>{t(e)})})}async preCacheUrl(s){let t=await caches.open(this.CACHE_NAME);return await t.match(s)?null:fetch(s).then(e=>t.put(s,e.clone()))}register(){this.scope.addEventListener("install",e=>{e.waitUntil(Promise.all([this.installServiceWorker(),this.scope.skipWaiting()]))}),this.scope.addEventListener("activate",s=>{s.waitUntil(Promise.all([this.cleanupLegacyCache(),this.scope.clients.claim(),this.scope.skipWaiting()]).catch(e=>{s.skipWaiting()}))}),this.scope.addEventListener("fetch",o=>{o.respondWith(caches.open(this.CACHE_NAME).then(async s=>{if(!this.canCache(o.request.url))return fetch(o.request);let t=await s.match(o.request);if(t){var r;let e=null;for(r of t.headers.entries())if("date"===r[0]){e=new Date(r[1]);break}if(!e)return t;var i=parseInt(""+((new Date).getTime()-e.getTime())/1e3),a=this.getTTL(o.request.url);if(null===a||a&&i<a)return t}return fetch(o.request.clone()).then(e=>e.status<400?(this.canCache(o.request.url)&&s.put(o.request,e.clone()),e):s.match(this.NOT_FOUND_PAGE)).catch(e=>(o.request.url,t||s.match(this.OFFLINE_PAGE)))}))})}}let pwa=new Pwa(self);pwa.register();
\ No newline at end of file diff --git a/static/tinysearch.toml b/static/tinysearch.toml new file mode 100644 index 0000000..2a3196b --- /dev/null +++ b/static/tinysearch.toml @@ -0,0 +1,4 @@ +[schema] +indexed_fields = ["title", "body"] +metadata_fields = ["description"] +url_field = "url" diff --git a/static/tinysearch_engine.wasm b/static/tinysearch_engine.wasm Binary files differnew file mode 100755 index 0000000..7dd234e --- /dev/null +++ b/static/tinysearch_engine.wasm diff --git a/static/tinysearch_engine_bg.wasm b/static/tinysearch_engine_bg.wasm Binary files differdeleted file mode 100644 index 6524c13..0000000 --- a/static/tinysearch_engine_bg.wasm +++ /dev/null |
