diff --git a/assets/js/search.min.03b3e4f8627664812eb844ceaead2a122ab3888f83b743bf593fc2ec9722b4f7.js b/assets/js/search.min.a7aeaa5cf0049fa909d697d27b866f2885af48d7568415ef296894a5a2f82e49.js similarity index 96% rename from assets/js/search.min.03b3e4f8627664812eb844ceaead2a122ab3888f83b743bf593fc2ec9722b4f7.js rename to assets/js/search.min.a7aeaa5cf0049fa909d697d27b866f2885af48d7568415ef296894a5a2f82e49.js index 2860ddb1..38e94472 100644 --- a/assets/js/search.min.03b3e4f8627664812eb844ceaead2a122ab3888f83b743bf593fc2ec9722b4f7.js +++ b/assets/js/search.min.a7aeaa5cf0049fa909d697d27b866f2885af48d7568415ef296894a5a2f82e49.js @@ -48,8 +48,8 @@ function createKeyId(key){return isArray(key)?key.join('.'):key;} function get(obj,path){var list=[];var arr=false;var deepGet=function deepGet(obj,path,index){if(!isDefined(obj)){return;} if(!path[index]){list.push(obj);}else{var key=path[index];var value=obj[key];if(!isDefined(value)){return;} if(index===path.length-1&&(isString(value)||isNumber(value)||isBoolean(value))){list.push(toString(value));}else if(isArray(value)){arr=true;for(var i=0,len=value.length;i0&&arguments[0]!==undefined?arguments[0]:3;var cache=new Map();return{get:function get(value){var numTokens=value.match(SPACE).length;if(cache.has(numTokens)){return cache.get(numTokens);} -var n=parseFloat((1/Math.sqrt(numTokens)).toFixed(mantissa));cache.set(numTokens,n);return n;},clear:function clear(){cache.clear();}};} +var MatchOptions={includeMatches:false,findAllMatches:false,minMatchCharLength:1};var BasicOptions={isCaseSensitive:false,includeScore:false,keys:[],shouldSort:true,sortFn:function sortFn(a,b){return a.score===b.score?a.idx0&&arguments[0]!==undefined?arguments[0]:3;var cache=new Map();var m=Math.pow(10,mantissa);return{get:function get(value){var numTokens=value.match(SPACE).length;if(cache.has(numTokens)){return cache.get(numTokens);} +var norm=1/Math.sqrt(numTokens);var n=parseFloat(Math.round(norm*m)/m);cache.set(numTokens,n);return n;},clear:function clear(){cache.clear();}};} var FuseIndex=function(){function FuseIndex(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$getFn=_ref.getFn,getFn=_ref$getFn===void 0?Config.getFn:_ref$getFn;_classCallCheck(this,FuseIndex);this.norm=norm(3);this.getFn=getFn;this.isCreated=false;this.setIndexRecords();} _createClass(FuseIndex,[{key:"setSources",value:function setSources(){var docs=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.docs=docs;}},{key:"setIndexRecords",value:function setIndexRecords(){var records=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.records=records;}},{key:"setKeys",value:function setKeys(){var _this=this;var keys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.keys=keys;this._keysMap={};keys.forEach(function(key,idx){_this._keysMap[key.id]=idx;});}},{key:"create",value:function create(){var _this2=this;if(this.isCreated||!this.docs.length){return;} this.isCreated=true;if(isString(this.docs[0])){this.docs.forEach(function(doc,docIndex){_this2._addString(doc,docIndex);});}else{this.docs.forEach(function(doc,docIndex){_this2._addObject(doc,docIndex);});} @@ -59,12 +59,6 @@ if(isArray(value)){(function(){var subRecords=[];var stack=[{nestedArrIndex:-1,v if(isString(_value)&&!isBlank(_value)){var subRecord={v:_value,i:nestedArrIndex,n:_this3.norm.get(_value)};subRecords.push(subRecord);}else if(isArray(_value)){_value.forEach(function(item,k){stack.push({nestedArrIndex:k,value:item});});}} record.$[keyIndex]=subRecords;})();}else if(!isBlank(value)){var subRecord={v:value,n:_this3.norm.get(value)};record.$[keyIndex]=subRecord;}});this.records.push(record);}},{key:"toJSON",value:function toJSON(){return{keys:this.keys,records:this.records};}}]);return FuseIndex;}();function createIndex(keys,docs){var _ref2=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref2$getFn=_ref2.getFn,getFn=_ref2$getFn===void 0?Config.getFn:_ref2$getFn;var myIndex=new FuseIndex({getFn:getFn});myIndex.setKeys(keys.map(createKey));myIndex.setSources(docs);myIndex.create();return myIndex;} function parseIndex(data){var _ref3=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref3$getFn=_ref3.getFn,getFn=_ref3$getFn===void 0?Config.getFn:_ref3$getFn;var keys=data.keys,records=data.records;var myIndex=new FuseIndex({getFn:getFn});myIndex.setKeys(keys);myIndex.setIndexRecords(records);return myIndex;} -function transformMatches(result,data){var matches=result.matches;data.matches=[];if(!isDefined(matches)){return;} -matches.forEach(function(match){if(!isDefined(match.indices)||!match.indices.length){return;} -var indices=match.indices,value=match.value;var obj={indices:indices,value:value};if(match.key){obj.key=match.key.src;} -if(match.idx>-1){obj.refIndex=match.idx;} -data.matches.push(obj);});} -function transformScore(result,data){data.score=result.score;} function computeScore(pattern){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref$errors=_ref.errors,errors=_ref$errors===void 0?0:_ref$errors,_ref$currentLocation=_ref.currentLocation,currentLocation=_ref$currentLocation===void 0?0:_ref$currentLocation,_ref$expectedLocation=_ref.expectedLocation,expectedLocation=_ref$expectedLocation===void 0?0:_ref$expectedLocation,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;var accuracy=errors/pattern.length;if(ignoreLocation){return accuracy;} var proximity=Math.abs(expectedLocation-currentLocation);if(!distance){return proximity?1.0:accuracy;} return accuracy+proximity/distance;} @@ -106,7 +100,7 @@ _createClass(SuffixExactMatch,[{key:"search",value:function search(text){var isM _createClass(InverseSuffixExactMatch,[{key:"search",value:function search(text){var isMatch=!text.endsWith(this.pattern);return{isMatch:isMatch,score:isMatch?0:1,indices:[0,text.length-1]};}}],[{key:"type",get:function get(){return 'inverse-suffix-exact';}},{key:"multiRegex",get:function get(){return /^!"(.*)"\$$/;}},{key:"singleRegex",get:function get(){return /^!(.*)\$$/;}}]);return InverseSuffixExactMatch;}(BaseMatch);var FuzzyMatch=function(_BaseMatch){_inherits(FuzzyMatch,_BaseMatch);var _super=_createSuper(FuzzyMatch);function FuzzyMatch(pattern){var _this;var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref$location=_ref.location,location=_ref$location===void 0?Config.location:_ref$location,_ref$threshold=_ref.threshold,threshold=_ref$threshold===void 0?Config.threshold:_ref$threshold,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$findAllMatches=_ref.findAllMatches,findAllMatches=_ref$findAllMatches===void 0?Config.findAllMatches:_ref$findAllMatches,_ref$minMatchCharLeng=_ref.minMatchCharLength,minMatchCharLength=_ref$minMatchCharLeng===void 0?Config.minMatchCharLength:_ref$minMatchCharLeng,_ref$isCaseSensitive=_ref.isCaseSensitive,isCaseSensitive=_ref$isCaseSensitive===void 0?Config.isCaseSensitive:_ref$isCaseSensitive,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;_classCallCheck(this,FuzzyMatch);_this=_super.call(this,pattern);_this._bitapSearch=new BitapSearch(pattern,{location:location,threshold:threshold,distance:distance,includeMatches:includeMatches,findAllMatches:findAllMatches,minMatchCharLength:minMatchCharLength,isCaseSensitive:isCaseSensitive,ignoreLocation:ignoreLocation});return _this;} _createClass(FuzzyMatch,[{key:"search",value:function search(text){return this._bitapSearch.searchIn(text);}}],[{key:"type",get:function get(){return 'fuzzy';}},{key:"multiRegex",get:function get(){return /^"(.*)"$/;}},{key:"singleRegex",get:function get(){return /^(.*)$/;}}]);return FuzzyMatch;}(BaseMatch);var IncludeMatch=function(_BaseMatch){_inherits(IncludeMatch,_BaseMatch);var _super=_createSuper(IncludeMatch);function IncludeMatch(pattern){_classCallCheck(this,IncludeMatch);return _super.call(this,pattern);} _createClass(IncludeMatch,[{key:"search",value:function search(text){var location=0;var index;var indices=[];var patternLen=this.pattern.length;while((index=text.indexOf(this.pattern,location))>-1){location=index+patternLen;indices.push([index,location-1]);} -var isMatch=!!indices.length;return{isMatch:isMatch,score:isMatch?1:0,indices:indices};}}],[{key:"type",get:function get(){return 'include';}},{key:"multiRegex",get:function get(){return /^'"(.*)"$/;}},{key:"singleRegex",get:function get(){return /^'(.*)$/;}}]);return IncludeMatch;}(BaseMatch);var searchers=[ExactMatch,IncludeMatch,PrefixExactMatch,InversePrefixExactMatch,InverseSuffixExactMatch,SuffixExactMatch,InverseExactMatch,FuzzyMatch];var searchersLen=searchers.length;var SPACE_RE=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;var OR_TOKEN='|';function parseQuery(pattern){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return pattern.split(OR_TOKEN).map(function(item){var query=item.trim().split(SPACE_RE).filter(function(item){return item&&!!item.trim();});var results=[];for(var i=0,len=query.length;i1&&arguments[1]!==undefined?arguments[1]:{};return pattern.split(OR_TOKEN).map(function(item){var query=item.trim().split(SPACE_RE).filter(function(item){return item&&!!item.trim();});var results=[];for(var i=0,len=query.length;i-1){obj.refIndex=match.idx;} +data.matches.push(obj);});} +function transformScore(result,data){data.score=result.score;} +function format(results,docs){var _ref=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$includeScore=_ref.includeScore,includeScore=_ref$includeScore===void 0?Config.includeScore:_ref$includeScore;var transformers=[];if(includeMatches)transformers.push(transformMatches);if(includeScore)transformers.push(transformScore);return results.map(function(result){var idx=result.idx;var data={item:docs[idx],refIndex:idx};if(transformers.length){transformers.forEach(function(transformer){transformer(result,data);});} +return data;});} var Fuse=function(){function Fuse(docs){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var index=arguments.length>2?arguments[2]:undefined;_classCallCheck(this,Fuse);this.options=_objectSpread2({},Config,{},options);if(this.options.useExtendedSearch&&!true){throw new Error(EXTENDED_SEARCH_UNAVAILABLE);} this._keyStore=new KeyStore(this.options.keys);this.setCollection(docs,index);} _createClass(Fuse,[{key:"setCollection",value:function setCollection(docs,index){this._docs=docs;if(index&&!(index instanceof FuseIndex)){throw new Error(INCORRECT_INDEX_TYPE);} @@ -142,10 +145,7 @@ expResults.forEach(function(_ref4){var _resultMap$idx$matche;var matches=_ref4.m var matches=[];keys.forEach(function(key,keyIndex){matches.push.apply(matches,_toConsumableArray(_this2._findMatches({key:key,value:item[keyIndex],searcher:searcher})));});if(matches.length){results.push({idx:idx,item:item,matches:matches});}});return results;}},{key:"_findMatches",value:function _findMatches(_ref6){var key=_ref6.key,value=_ref6.value,searcher=_ref6.searcher;if(!isDefined(value)){return[];} var matches=[];if(isArray(value)){value.forEach(function(_ref7){var text=_ref7.v,idx=_ref7.i,norm=_ref7.n;if(!isDefined(text)){return;} var _searcher$searchIn2=searcher.searchIn(text),isMatch=_searcher$searchIn2.isMatch,score=_searcher$searchIn2.score,indices=_searcher$searchIn2.indices;if(isMatch){matches.push({score:score,key:key,value:text,idx:idx,norm:norm,indices:indices});}});}else{var text=value.v,norm=value.n;var _searcher$searchIn3=searcher.searchIn(text),isMatch=_searcher$searchIn3.isMatch,score=_searcher$searchIn3.score,indices=_searcher$searchIn3.indices;if(isMatch){matches.push({score:score,key:key,value:text,norm:norm,indices:indices});}} -return matches;}}]);return Fuse;}();function computeScore$1(results,_ref8){var _ref8$ignoreFieldNorm=_ref8.ignoreFieldNorm,ignoreFieldNorm=_ref8$ignoreFieldNorm===void 0?Config.ignoreFieldNorm:_ref8$ignoreFieldNorm;results.forEach(function(result){var totalScore=1;result.matches.forEach(function(_ref9){var key=_ref9.key,norm=_ref9.norm,score=_ref9.score;var weight=key?key.weight:null;totalScore*=Math.pow(score===0&&weight?Number.EPSILON:score,(weight||1)*(ignoreFieldNorm?1:norm));});result.score=totalScore;});} -function format(results,docs){var _ref10=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref10$includeMatches=_ref10.includeMatches,includeMatches=_ref10$includeMatches===void 0?Config.includeMatches:_ref10$includeMatches,_ref10$includeScore=_ref10.includeScore,includeScore=_ref10$includeScore===void 0?Config.includeScore:_ref10$includeScore;var transformers=[];if(includeMatches)transformers.push(transformMatches);if(includeScore)transformers.push(transformScore);return results.map(function(result){var idx=result.idx;var data={item:docs[idx],refIndex:idx};if(transformers.length){transformers.forEach(function(transformer){transformer(result,data);});} -return data;});} -Fuse.version='6.4.3';Fuse.createIndex=createIndex;Fuse.parseIndex=parseIndex;Fuse.config=Config;{Fuse.parseQuery=parse;} +return matches;}}]);return Fuse;}();Fuse.version='6.4.6';Fuse.createIndex=createIndex;Fuse.parseIndex=parseIndex;Fuse.config=Config;{Fuse.parseQuery=parse;} {register(ExtendedSearch);} return Fuse;})));;var fuse;var resList=document.getElementById('searchResults');var sInput=document.getElementById('searchInput');var first,last=null var resultsAvailable=false;function loadSearch(){var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState===4){if(xhr.status===200){var data=JSON.parse(xhr.responseText);if(data){var options={isCaseSensitive:false,shouldSort:true,location:0,distance:100,threshold:0.4,minMatchCharLength:0,keys:['title','permalink','summary','content']};fuse=new Fuse(data,options);}}else{console.log(xhr.responseText);}}};xhr.open('GET',"../index.json");xhr.send();} diff --git a/l2/search/index.html b/l2/search/index.html index 8e92dfb3..fae45c56 100644 --- a/l2/search/index.html +++ b/l2/search/index.html @@ -1,4 +1,4 @@ -SearchL2 | PaperModL2