I had the same problem as you, so I created a fiddle to search my list of scripts :)
http://jsfiddle.net/panzerkunst/77fgau53/show/
It uses the JSFiddle API to return a list of scripts
$.ajax(
{
url: "http://jsfiddle.net/api/user/"+this.username+"/demo/list.json",
data: {
limit:this.limit
},
dataType: "JSONP",
jsonp: "jsoncallback",
type: "GET"
}
)
.done(this.dataReceived.bind(this))
.fail(this.errorHappened.bind(this))
.always(this.resetControls.bind(this));
and then the list is filtered based on the keyword that you provide.
dataReceived: function(data){
var query = this.query;
var filtered = _.filter(data.list, function(item){if(item.title.contains(query) || item.description.contains(query)){ return item}});
[...]
}
Hope this helps!
Nicholas
UPDATE : to make it work with your scripts, you need to change the username passed to the .initialize () method. http://jsfiddle.net/panzerkunst/77fgau53/
source
share