2014-12-03 19:52:03 +08:00
|
|
|
|
var bfsAjax;
|
|
|
|
|
var bfsTimeout;
|
|
|
|
|
|
|
|
|
|
$(function () {
|
2014-12-03 18:54:14 +08:00
|
|
|
|
$("#search-input").keyup(function () {
|
2014-11-28 03:34:20 +08:00
|
|
|
|
var search = $(this);
|
|
|
|
|
$(this).parent().find(".list-group").remove();
|
|
|
|
|
|
2014-12-03 19:52:03 +08:00
|
|
|
|
if (typeof bfsTimeout != 'undefined')
|
|
|
|
|
{
|
|
|
|
|
clearTimeout(bfsTimeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof bfsAjax != 'undefined' && bfsAjax.readyState != 4)
|
|
|
|
|
{
|
|
|
|
|
bfsAjax.abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bfsTimeout = setTimeout(function (object) {
|
|
|
|
|
bfsAjax = $.ajax("/api/GetSearchResult/?query=" + $("#search-input").val()).done(function (data) {
|
|
|
|
|
var template = $.templates("#result-template");
|
|
|
|
|
var content = $("<div class='list-group'></div>");
|
|
|
|
|
|
|
|
|
|
var item = template.render(data);
|
|
|
|
|
content.append(item);
|
2014-11-28 03:34:20 +08:00
|
|
|
|
|
2014-12-03 19:52:03 +08:00
|
|
|
|
search.after(content);
|
2015-02-21 05:50:40 +08:00
|
|
|
|
|
|
|
|
|
$(".panel-search a.list-group-item").click(function () {
|
|
|
|
|
ga('send', 'pageview', '/api/GetSearchResult/?query=' + $("#search-input").val());
|
|
|
|
|
});
|
2014-12-03 19:52:03 +08:00
|
|
|
|
});
|
|
|
|
|
}, 200);
|
2014-11-28 03:34:20 +08:00
|
|
|
|
});
|
|
|
|
|
});
|