|
|
@ -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,38 +27,53 @@
|
|
|
|
$(".spinner").show();
|
|
|
|
$(".spinner").show();
|
|
|
|
var query = $("input#query").val();
|
|
|
|
var query = $("input#query").val();
|
|
|
|
|
|
|
|
|
|
|
|
$.post("/api/search", {q: query}, function(response){
|
|
|
|
if(query.length >= 3)
|
|
|
|
$(".spinner").hide();
|
|
|
|
{
|
|
|
|
$(".results").html("");
|
|
|
|
$.post("/api/search", {q: query}, function(response){
|
|
|
|
|
|
|
|
$(".spinner").hide();
|
|
|
|
|
|
|
|
$(".results").html("");
|
|
|
|
|
|
|
|
|
|
|
|
for(i in response)
|
|
|
|
if(typeof response.error == "undefined")
|
|
|
|
{
|
|
|
|
|
|
|
|
if(response[i].items.length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result_wrapper = instantiateTemplate("result_wrapper");
|
|
|
|
for(i in response)
|
|
|
|
|
|
|
|
|
|
|
|
var result_block = instantiateTemplate("result_topic");
|
|
|
|
|
|
|
|
result_block.children(".title").html(response[i].title);
|
|
|
|
|
|
|
|
result_block.children(".providername").html(response[i].provider);
|
|
|
|
|
|
|
|
result_block.appendTo(result_wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(x in response[i].items)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item = response[i].items[x];
|
|
|
|
if(response[i].items.length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
var item_block = instantiateTemplate("result_item");
|
|
|
|
var result_wrapper = instantiateTemplate("result_wrapper");
|
|
|
|
item_block.children(".title").html(item.title);
|
|
|
|
|
|
|
|
item_block.children(".title").attr("href", item.url);
|
|
|
|
var result_block = instantiateTemplate("result_topic");
|
|
|
|
item_block.children(".type").html(item.type);
|
|
|
|
result_block.children(".title").html(response[i].title);
|
|
|
|
item_block.insertAfter(result_block);
|
|
|
|
result_block.children(".providername").html(response[i].provider);
|
|
|
|
|
|
|
|
result_block.appendTo(result_wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(x in response[i].items)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item = response[i].items[x];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var item_block = instantiateTemplate("result_item");
|
|
|
|
|
|
|
|
item_block.children(".title").html(item.title);
|
|
|
|
|
|
|
|
item_block.children(".title").attr("href", item.url);
|
|
|
|
|
|
|
|
item_block.children(".type").html(item.type);
|
|
|
|
|
|
|
|
item_block.insertAfter(result_block);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|