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