You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
33 KiB

  1. (function(){var lunr=function(config){var builder=new lunr.Builder;builder.pipeline.add(lunr.trimmer,lunr.stopWordFilter,lunr.stemmer);builder.searchPipeline.add(lunr.stemmer);config.call(builder,builder);return builder.build()};lunr.version="2.1.2";lunr.utils={};lunr.utils.warn=function(global){return function(message){if(global.console&&console.warn){console.warn(message)}}}(this);lunr.utils.asString=function(obj){if(obj===void 0||obj===null){return""}else{return obj.toString()}};lunr.FieldRef=function(docRef,fieldName){this.docRef=docRef;this.fieldName=fieldName;this._stringValue=fieldName+lunr.FieldRef.joiner+docRef};lunr.FieldRef.joiner="/";lunr.FieldRef.fromString=function(s){var n=s.indexOf(lunr.FieldRef.joiner);if(n===-1){throw"malformed field ref string"}var fieldRef=s.slice(0,n),docRef=s.slice(n+1);return new lunr.FieldRef(docRef,fieldRef)};lunr.FieldRef.prototype.toString=function(){return this._stringValue};lunr.idf=function(posting,documentCount){var documentsWithTerm=0;for(var fieldName in posting){if(fieldName=="_index")continue;documentsWithTerm+=Object.keys(posting[fieldName]).length}var x=(documentCount-documentsWithTerm+.5)/(documentsWithTerm+.5);return Math.log(1+Math.abs(x))};lunr.Token=function(str,metadata){this.str=str||"";this.metadata=metadata||{}};lunr.Token.prototype.toString=function(){return this.str};lunr.Token.prototype.update=function(fn){this.str=fn(this.str,this.metadata);return this};lunr.Token.prototype.clone=function(fn){fn=fn||function(s){return s};return new lunr.Token(fn(this.str,this.metadata),this.metadata)};lunr.tokenizer=function(obj){if(obj==null||obj==undefined){return[]}if(Array.isArray(obj)){return obj.map((function(t){return new lunr.Token(lunr.utils.asString(t).toLowerCase())}))}var str=obj.toString().trim().toLowerCase(),len=str.length,tokens=[];for(var sliceEnd=0,sliceStart=0;sliceEnd<=len;sliceEnd++){var char=str.charAt(sliceEnd),sliceLength=sliceEnd-sliceStart;if(char.match(lunr.tokenizer.separator)||sliceEnd==len){if(sliceLength>0){tokens.push(new lunr.Token(str.slice(sliceStart,sliceEnd),{position:[sliceStart,sliceLength],index:tokens.length}))}sliceStart=sliceEnd+1}}return tokens};lunr.tokenizer.separator=/[\s\-]+/;lunr.Pipeline=function(){this._stack=[]};lunr.Pipeline.registeredFunctions=Object.create(null);lunr.Pipeline.registerFunction=function(fn,label){if(label in this.registeredFunctions){lunr.utils.warn("Overwriting existing registered function: "+label)}fn.label=label;lunr.Pipeline.registeredFunctions[fn.label]=fn};lunr.Pipeline.warnIfFunctionNotRegistered=function(fn){var isRegistered=fn.label&&fn.label in this.registeredFunctions;if(!isRegistered){lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",fn)}};lunr.Pipeline.load=function(serialised){var pipeline=new lunr.Pipeline;serialised.forEach((function(fnName){var fn=lunr.Pipeline.registeredFunctions[fnName];if(fn){pipeline.add(fn)}else{throw new Error("Cannot load unregistered function: "+fnName)}}));return pipeline};lunr.Pipeline.prototype.add=function(){var fns=Array.prototype.slice.call(arguments);fns.forEach((function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn);this._stack.push(fn)}),this)};lunr.Pipeline.prototype.after=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(pos==-1){throw new Error("Cannot find existingFn")}pos=pos+1;this._stack.splice(pos,0,newFn)};lunr.Pipeline.prototype.before=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(pos==-1){throw new Error("Cannot find existingFn")}this._stack.splice(pos,0,newFn)};lunr.Pipeline.prototype.remove=function(fn){var pos=this._stack.indexOf(fn);if(pos==-1){return}this._stack.splice(pos,1)};lunr.Pipeline.prototype.run=function(tokens){var stackLength=this._stack.length;for(var i=0;i<stackLength;i++){var fn=this._stack[i];tokens=tokens.reduce((function(memo,token,j){var result=fn(token,j,tokens);if(result===void 0||result==="")return memo;return