made with requirebin
Last active
August 29, 2015 14:25
-
-
Save timaschew/3d288ca9baf13c849e0f to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var lunr = require('lunr'); | |
var idx = lunr(function () { | |
this.field('title', { boost: 10 }) | |
this.field('body') | |
}) | |
var doc = { | |
"title": "Twelfth-Night", | |
"body": "If music be the food of love, play on: Give me excess of it…", | |
"author": "William Shakespeare", | |
"id": 1 | |
} | |
idx.add(doc); | |
var result = idx.search("mu"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({lunr:[function(require,module,exports){(function(){var lunr=function(config){var idx=new lunr.Index;idx.pipeline.add(lunr.trimmer,lunr.stopWordFilter,lunr.stemmer);if(config)config.call(idx,idx);return idx};lunr.version="0.5.11";lunr.utils={};lunr.utils.warn=function(global){return function(message){if(global.console&&console.warn){console.warn(message)}}}(this);lunr.EventEmitter=function(){this.events={}};lunr.EventEmitter.prototype.addListener=function(){var args=Array.prototype.slice.call(arguments),fn=args.pop(),names=args;if(typeof fn!=="function")throw new TypeError("last argument must be a function");names.forEach(function(name){if(!this.hasHandler(name))this.events[name]=[];this.events[name].push(fn)},this)};lunr.EventEmitter.prototype.removeListener=function(name,fn){if(!this.hasHandler(name))return;var fnIndex=this.events[name].indexOf(fn);this.events[name].splice(fnIndex,1);if(!this.events[name].length)delete this.events[name]};lunr.EventEmitter.prototype.emit=function(name){if(!this.hasHandler(name))return;var args=Array.prototype.slice.call(arguments,1);this.events[name].forEach(function(fn){fn.apply(undefined,args)})};lunr.EventEmitter.prototype.hasHandler=function(name){return name in this.events};lunr.tokenizer=function(obj){if(!arguments.length||obj==null||obj==undefined)return[];if(Array.isArray(obj))return obj.map(function(t){return t.toLowerCase()});return obj.toString().trim().toLowerCase().split(/[\s\-]+/)};lunr.Pipeline=function(){this._stack=[]};lunr.Pipeline.registeredFunctions={};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 un-registered 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 out=[],tokenLength=tokens.length,stackLength=this._stack.length;for(var i=0;i<tokenLength;i++){var token=tokens[i];for(var j=0;j<stackLength;j++){token=this._stack[j](token,i,tokens);if(token===void 0)break}if(token!==void 0)out.push(token)}return out};lunr.Pipeline.prototype.reset=function(){this._stack=[]};lunr.Pipeline.prototype.toJSON=function(){return this._stack.map(function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn);return fn.label})};lunr.Vector=function(){this._magnitude=null;this.list=undefined;this.length=0};lunr.Vector.Node=function(idx,val,next){this.idx=idx;this.val=val;this.next=next};lunr.Vector.prototype.insert=function(idx,val){this._magnitude=undefined;var list=this.list;if(!list){this.list=new lunr.Vector.Node(idx,val,list);return this.length++}if(idx<list.idx){this.list=new lunr.Vector.Node(idx,val,list);return this.length++}var prev=list,next=list.next;while(next!=undefined){if(idx<next.idx){prev.next=new lunr.Vector.Node(idx,val,next);return this.length++}prev=next,next=next.next}prev.next=new lunr.Vector.Node(idx,val,next);return this.length++};lunr.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;var node=this.list,sumOfSquares=0,val;while(node){val=node.val;sumOfSquares+=val*val;node=node.next}return this._magnitude=Math.sqrt(sumOfSquares)};lunr.Vector.prototype.dot=function(otherVector){var node=this.list,otherNode=otherVector.list,dotProduct=0;while(node&&otherNode){if(node.idx<otherNode.idx){node=node.next}else if(node.idx>otherNode.idx){otherNode=otherNode.next}else{dotProduct+=node.val*otherNode.val;node=node.next;otherNode=otherNode.next}}return dotProduct};lunr.Vector.prototype.similarity=function(otherVector){return this.dot(otherVector)/(this.magnitude()*otherVector.magnitude())};lunr.SortedSet=function(){this.length=0;this.elements=[]};lunr.SortedSet.load=function(serialisedData){var set=new this;set.elements=serialisedData;set.length=serialisedData.length;return set};lunr.SortedSet.prototype.add=function(){var i,element;for(i=0;i<arguments.length;i++){element=arguments[i];if(~this.indexOf(element))continue;this.elements.splice(this.locationFor(element),0,element)}this.length=this.elements.length};lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()};lunr.SortedSet.prototype.map=function(fn,ctx){return this.elements.map(fn,ctx)};lunr.SortedSet.prototype.forEach=function(fn,ctx){return this.elements.forEach(fn,ctx)};lunr.SortedSet.prototype.indexOf=function(elem){var start=0,end=this.elements.length,sectionLength=end-start,pivot=start+Math.floor(sectionLength/2),pivotElem=this.elements[pivot];while(sectionLength>1){if(pivotElem===elem)return pivot;if(pivotElem<elem)start=pivot;if(pivotElem>elem)end=pivot;sectionLength=end-start;pivot=start+Math.floor(sectionLength/2);pivotElem=this.elements[pivot]}if(pivotElem===elem)return pivot;return-1};lunr.SortedSet.prototype.locationFor=function(elem){var start=0,end=this.elements.length,sectionLength=end-start,pivot=start+Math.floor(sectionLength/2),pivotElem=this.elements[pivot];while(sectionLength>1){if(pivotElem<elem)start=pivot;if(pivotElem>elem)end=pivot;sectionLength=end-start;pivot=start+Math.floor(sectionLength/2);pivotElem=this.elements[pivot]}if(pivotElem>elem)return pivot;if(pivotElem<elem)return pivot+1};lunr.SortedSet.prototype.intersect=function(otherSet){var intersectSet=new lunr.SortedSet,i=0,j=0,a_len=this.length,b_len=otherSet.length,a=this.elements,b=otherSet.elements;while(true){if(i>a_len-1||j>b_len-1)break;if(a[i]===b[j]){intersectSet.add(a[i]);i++,j++;continue}if(a[i]<b[j]){i++;continue}if(a[i]>b[j]){j++;continue}}return intersectSet};lunr.SortedSet.prototype.clone=function(){var clone=new lunr.SortedSet;clone.elements=this.toArray();clone.length=clone.elements.length;return clone};lunr.SortedSet.prototype.union=function(otherSet){var longSet,shortSet,unionSet;if(this.length>=otherSet.length){longSet=this,shortSet=otherSet}else{longSet=otherSet,shortSet=this}unionSet=longSet.clone();unionSet.add.apply(unionSet,shortSet.toArray());return unionSet};lunr.SortedSet.prototype.toJSON=function(){return this.toArray()};lunr.Index=function(){this._fields=[];this._ref="id";this.pipeline=new lunr.Pipeline;this.documentStore=new lunr.Store;this.tokenStore=new lunr.TokenStore;this.corpusTokens=new lunr.SortedSet;this.eventEmitter=new lunr.EventEmitter;this._idfCache={};this.on("add","remove","update",function(){this._idfCache={}}.bind(this))};lunr.Index.prototype.on=function(){var args=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,args)};lunr.Index.prototype.off=function(name,fn){return this.eventEmitter.removeListener(name,fn)};lunr.Index.load=function(serialisedData){if(serialisedData.version!==lunr.version){lunr.utils.warn("version mismatch: current "+lunr.version+" importing "+serialisedData.version)}var idx=new this;idx._fields=serialisedData.fields;idx._ref=serialisedData.ref;idx.documentStore=lunr.Store.load(serialisedData.documentStore);idx.tokenStore=lunr.TokenStore.load(serialisedData.tokenStore);idx.corpusTokens=lunr.SortedSet.load(serialisedData.corpusTokens);idx.pipeline=lunr.Pipeline.load(serialisedData.pipeline);return idx};lunr.Index.prototype.field=function(fieldName,opts){var opts=opts||{},field={name:fieldName,boost:opts.boost||1};this._fields.push(field);return this};lunr.Index.prototype.ref=function(refName){this._ref=refName;return this};lunr.Index.prototype.add=function(doc,emitEvent){var docTokens={},allDocumentTokens=new lunr.SortedSet,docRef=doc[this._ref],emitEvent=emitEvent===undefined?true:emitEvent;this._fields.forEach(function(field){var fieldTokens=this.pipeline.run(lunr.tokenizer(doc[field.name]));docTokens[field.name]=fieldTokens;lunr.SortedSet.prototype.add.apply(allDocumentTokens,fieldTokens)},this);this.documentStore.set(docRef,allDocumentTokens);lunr.SortedSet.prototype.add.apply(this.corpusTokens,allDocumentTokens.toArray());for(var i=0;i<allDocumentTokens.length;i++){var token=allDocumentTokens.elements[i];var tf=this._fields.reduce(function(memo,field){var fieldLength=docTokens[field.name].length;if(!fieldLength)return memo;var tokenCount=docTokens[field.name].filter(function(t){return t===token}).length;return memo+tokenCount/fieldLength*field.boost},0);this.tokenStore.add(token,{ref:docRef,tf:tf})}if(emitEvent)this.eventEmitter.emit("add",doc,this)};lunr.Index.prototype.remove=function(doc,emitEvent){var docRef=doc[this._ref],emitEvent=emitEvent===undefined?true:emitEvent;if(!this.documentStore.has(docRef))return;var docTokens=this.documentStore.get(docRef);this.documentStore.remove(docRef);docTokens.forEach(function(token){this.tokenStore.remove(token,docRef)},this);if(emitEvent)this.eventEmitter.emit("remove",doc,this)};lunr.Index.prototype.update=function(doc,emitEvent){var emitEvent=emitEvent===undefined?true:emitEvent;this.remove(doc,false);this.add(doc,false);if(emitEvent)this.eventEmitter.emit("update",doc,this)};lunr.Index.prototype.idf=function(term){var cacheKey="@"+term;if(Object.prototype.hasOwnProperty.call(this._idfCache,cacheKey))return this._idfCache[cacheKey];var documentFrequency=this.tokenStore.count(term),idf=1;if(documentFrequency>0){idf=1+Math.log(this.documentStore.length/documentFrequency)}return this._idfCache[cacheKey]=idf};lunr.Index.prototype.search=function(query){var queryTokens=this.pipeline.run(lunr.tokenizer(query)),queryVector=new lunr.Vector,documentSets=[],fieldBoosts=this._fields.reduce(function(memo,f){return memo+f.boost},0);var hasSomeToken=queryTokens.some(function(token){return this.tokenStore.has(token)},this);if(!hasSomeToken)return[];queryTokens.forEach(function(token,i,tokens){var tf=1/tokens.length*this._fields.length*fieldBoosts,self=this;var set=this.tokenStore.expand(token).reduce(function(memo,key){var pos=self.corpusTokens.indexOf(key),idf=self.idf(key),similarityBoost=1,set=new lunr.SortedSet;if(key!==token){var diff=Math.max(3,key.length-token.length);similarityBoost=1/Math.log(diff)}if(pos>-1)queryVector.insert(pos,tf*idf*similarityBoost);Object.keys(self.tokenStore.get(key)).forEach(function(ref){set.add(ref)});return memo.union(set)},new lunr.SortedSet);documentSets.push(set)},this);var documentSet=documentSets.reduce(function(memo,set){return memo.intersect(set)});return documentSet.map(function(ref){return{ref:ref,score:queryVector.similarity(this.documentVector(ref))}},this).sort(function(a,b){return b.score-a.score})};lunr.Index.prototype.documentVector=function(documentRef){var documentTokens=this.documentStore.get(documentRef),documentTokensLength=documentTokens.length,documentVector=new lunr.Vector;for(var i=0;i<documentTokensLength;i++){var token=documentTokens.elements[i],tf=this.tokenStore.get(token)[documentRef].tf,idf=this.idf(token);documentVector.insert(this.corpusTokens.indexOf(token),tf*idf)}return documentVector};lunr.Index.prototype.toJSON=function(){return{version:lunr.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}};lunr.Index.prototype.use=function(plugin){var args=Array.prototype.slice.call(arguments,1);args.unshift(this);plugin.apply(this,args)};lunr.Store=function(){this.store={};this.length=0};lunr.Store.load=function(serialisedData){var store=new this;store.length=serialisedData.length;store.store=Object.keys(serialisedData.store).reduce(function(memo,key){memo[key]=lunr.SortedSet.load(serialisedData.store[key]);return memo},{});return store};lunr.Store.prototype.set=function(id,tokens){if(!this.has(id))this.length++;this.store[id]=tokens};lunr.Store.prototype.get=function(id){return this.store[id]};lunr.Store.prototype.has=function(id){return id in this.store};lunr.Store.prototype.remove=function(id){if(!this.has(id))return;delete this.store[id];this.length--};lunr.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}};lunr.stemmer=function(){var step2list={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"},step3list={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},c="[^aeiou]",v="[aeiouy]",C=c+"[^aeiouy]*",V=v+"[aeiou]*",mgr0="^("+C+")?"+V+C,meq1="^("+C+")?"+V+C+"("+V+")?$",mgr1="^("+C+")?"+V+C+V+C,s_v="^("+C+")?"+v;var re_mgr0=new RegExp(mgr0);var re_mgr1=new RegExp(mgr1);var re_meq1=new RegExp(meq1);var re_s_v=new RegExp(s_v);var re_1a=/^(.+?)(ss|i)es$/;var re2_1a=/^(.+?)([^s])s$/;var re_1b=/^(.+?)eed$/;var re2_1b=/^(.+?)(ed|ing)$/;var re_1b_2=/.$/;var re2_1b_2=/(at|bl|iz)$/;var re3_1b_2=new RegExp("([^aeiouylsz])\\1$");var re4_1b_2=new RegExp("^"+C+v+"[^aeiouwxy]$");var re_1c=/^(.+?[^aeiou])y$/;var re_2=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;var re_3=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;var re_4=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;var re2_4=/^(.+?)(s|t)(ion)$/;var re_5=/^(.+?)e$/;var re_5_1=/ll$/;var re3_5=new RegExp("^"+C+v+"[^aeiouwxy]$");var porterStemmer=function porterStemmer(w){var stem,suffix,firstch,re,re2,re3,re4;if(w.length<3){return w}firstch=w.substr(0,1);if(firstch=="y"){w=firstch.toUpperCase()+w.substr(1)}re=re_1a;re2=re2_1a;if(re.test(w)){w=w.replace(re,"$1$2")}else if(re2.test(w)){w=w.replace(re2,"$1$2")}re=re_1b;re2=re2_1b;if(re.test(w)){var fp=re.exec(w);re=re_mgr0;if(re.test(fp[1])){re=re_1b_2;w=w.replace(re,"")}}else if(re2.test(w)){var fp=re2.exec(w);stem=fp[1];re2=re_s_v;if(re2.test(stem)){w=stem;re2=re2_1b_2;re3=re3_1b_2;re4=re4_1b_2;if(re2.test(w)){w=w+"e"}else if(re3.test(w)){re=re_1b_2;w=w.replace(re,"")}else if(re4.test(w)){w=w+"e"}}}re=re_1c;if(re.test(w)){var fp=re.exec(w);stem=fp[1];w=stem+"i"}re=re_2;if(re.test(w)){var fp=re.exec(w);stem=fp[1];suffix=fp[2];re=re_mgr0;if(re.test(stem)){w=stem+step2list[suffix]}}re=re_3;if(re.test(w)){var fp=re.exec(w);stem=fp[1];suffix=fp[2];re=re_mgr0;if(re.test(stem)){w=stem+step3list[suffix]}}re=re_4;re2=re2_4;if(re.test(w)){var fp=re.exec(w);stem=fp[1];re=re_mgr1;if(re.test(stem)){w=stem}}else if(re2.test(w)){var fp=re2.exec(w);stem=fp[1]+fp[2];re2=re_mgr1;if(re2.test(stem)){w=stem}}re=re_5;if(re.test(w)){var fp=re.exec(w);stem=fp[1];re=re_mgr1;re2=re_meq1;re3=re3_5;if(re.test(stem)||re2.test(stem)&&!re3.test(stem)){w=stem}}re=re_5_1;re2=re_mgr1;if(re.test(w)&&re2.test(w)){re=re_1b_2;w=w.replace(re,"")}if(firstch=="y"){w=firstch.toLowerCase()+w.substr(1)}return w};return porterStemmer}();lunr.Pipeline.registerFunction(lunr.stemmer,"stemmer");lunr.stopWordFilter=function(token){if(lunr.stopWordFilter.stopWords.indexOf(token)===-1)return token};lunr.stopWordFilter.stopWords=new lunr.SortedSet;lunr.stopWordFilter.stopWords.length=119;lunr.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"];lunr.Pipeline.registerFunction(lunr.stopWordFilter,"stopWordFilter");lunr.trimmer=function(token){return token.replace(/^\W+/,"").replace(/\W+$/,"")};lunr.Pipeline.registerFunction(lunr.trimmer,"trimmer");lunr.TokenStore=function(){this.root={docs:{}};this.length=0};lunr.TokenStore.load=function(serialisedData){var store=new this;store.root=serialisedData.root;store.length=serialisedData.length;return store};lunr.TokenStore.prototype.add=function(token,doc,root){var root=root||this.root,key=token[0],rest=token.slice(1);if(!(key in root))root[key]={docs:{}};if(rest.length===0){root[key].docs[doc.ref]=doc;this.length+=1;return}else{return this.add(rest,doc,root[key])}};lunr.TokenStore.prototype.has=function(token){if(!token)return false;var node=this.root;for(var i=0;i<token.length;i++){if(!node[token[i]])return false;node=node[token[i]]}return true};lunr.TokenStore.prototype.getNode=function(token){if(!token)return{};var node=this.root;for(var i=0;i<token.length;i++){if(!node[token[i]])return{};node=node[token[i]]}return node};lunr.TokenStore.prototype.get=function(token,root){return this.getNode(token,root).docs||{}};lunr.TokenStore.prototype.count=function(token,root){return Object.keys(this.get(token,root)).length};lunr.TokenStore.prototype.remove=function(token,ref){if(!token)return;var node=this.root;for(var i=0;i<token.length;i++){if(!(token[i]in node))return;node=node[token[i]]}delete node.docs[ref]};lunr.TokenStore.prototype.expand=function(token,memo){var root=this.getNode(token),docs=root.docs||{},memo=memo||[];if(Object.keys(docs).length)memo.push(token);Object.keys(root).forEach(function(key){if(key==="docs")return;memo.concat(this.expand(token+key,memo))},this);return memo};lunr.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}};(function(root,factory){if(typeof define==="function"&&define.amd){define(factory)}else if(typeof exports==="object"){module.exports=factory()}else{root.lunr=factory()}})(this,function(){return lunr})})()},{}]},{},[]);var lunr=require("lunr");var idx=lunr(function(){this.field("title",{boost:10});this.field("body")});var doc={title:"Twelfth-Night",body:"If music be the food of love, play on: Give me excess of it…",author:"William Shakespeare",id:1};idx.add(doc);var result=idx.search("mu"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"lunr": "0.5.11" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input id="faq-search" placeholder="search"> | |
<script> | |
var DOMAIN = 'http://relaunch.rplan.com'; | |
$(function() { | |
var faqItems = rplan__faq.de.map(function(i) {return {value: i.meta.headline, url: i.url}}) | |
$( "#faq-search" ).autocomplete({ | |
minLength: 0, | |
source: faqItems, | |
focus: function( event, ui ) { | |
$( "#faq-search" ).val( ui.item.value ); | |
return true; | |
}, | |
select: function( event, ui ) { | |
$( "#faq-search" ).val( ui.item.value ); | |
return true; | |
} | |
}) | |
.autocomplete( "instance" )._renderItem = function( ul, item ) { | |
return $( "<li>" ) | |
.append( "<a target='_blank' href='" + DOMAIN + item.url + "'>" + item.value + "</a>" ) | |
.appendTo( ul ); | |
}; | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> | |
<script src="http://code.jquery.com/jquery-1.10.2.js"></script> | |
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> | |
<script src="http://relaunch.rplan.com/faq-json.js"></script> | |
<style> | |
<style> | |
</style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment