-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathac_search.js
41 lines (37 loc) · 1.25 KB
/
ac_search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Handles AutoComplete Search Input Box
$(function() {
$("#search").autocomplete({
source: "search.php?request=matches",
minLength: 2,
select: function(event, ui) {
$("#tag-name").text(ui.item.value);
$.ajax({
type: "GET",
url: "search.php",
data: "term=" + ui.item.value + "&request=info",
dataType: "json",
success: function(data) {
$("#tag-url").html('<a href="' + data[0] + '">' + data[0] + "</a>");
$("#tag-hits").html("Number Of Hits <span style='color:red;font-size:200%;'>" + data[1] + "</span>");
}
});
$("#search-info").dialog('open');
}
})
.data("autocomplete")._renderItem = function(ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append( "<a>" +
item.value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("
+ $('#search').val() + ")(?![^<>]*>)(?![^&;]+;)", "gi"),
"<u><b>$1</b></u>") + "</a>") . appendTo(ul);
};
$("#search-info").dialog({
modal: true,
autoOpen: false,
draggable: false,
minWidth: 600,
resizable: false,
width: 600
});
});