|
|
|
@ -11,7 +11,7 @@
|
|
|
|
|
/*$("input").val("data");
|
|
|
|
|
runSearch();*/
|
|
|
|
|
|
|
|
|
|
$("input").keypress(function(){
|
|
|
|
|
$("input").keyup(function(){
|
|
|
|
|
if(typeof search_timeout !== "null")
|
|
|
|
|
{
|
|
|
|
|
clearTimeout(search_timeout);
|
|
|
|
@ -27,10 +27,14 @@
|
|
|
|
|
$(".spinner").show();
|
|
|
|
|
var query = $("input#query").val();
|
|
|
|
|
|
|
|
|
|
if(query.length >= 3)
|
|
|
|
|
{
|
|
|
|
|
$.post("/api/search", {q: query}, function(response){
|
|
|
|
|
$(".spinner").hide();
|
|
|
|
|
$(".results").html("");
|
|
|
|
|
|
|
|
|
|
if(typeof response.error == "undefined")
|
|
|
|
|
{
|
|
|
|
|
for(i in response)
|
|
|
|
|
{
|
|
|
|
|
if(response[i].items.length > 0)
|
|
|
|
@ -56,10 +60,21 @@
|
|
|
|
|
result_wrapper.appendTo(".results");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$(".results").html("<div class='error'>No results.</div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setHandlers();
|
|
|
|
|
}, "json");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$(".spinner").hide();
|
|
|
|
|
$(".results").html("<div class='error'>Enter at least 3 characters.</div>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setHandlers()
|
|
|
|
|
{
|
|
|
|
|