-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimapi.js
More file actions
56 lines (41 loc) · 1.88 KB
/
simapi.js
File metadata and controls
56 lines (41 loc) · 1.88 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var searchRequest = null;
$(function () {
var minlength = 3;
$(".searchBarTxt").keyup(function () {
var that = this,
value = $(this).val();
if (value.length >= minlength) {
if (searchRequest != null)
searchRequest.abort();
$('.searchResults').html('Searching...');
searchRequest = $.ajax({
type: "POST",
url: "#SEARCH",
data: {
'SEARCHTERM': value
},
dataType: "text",
success: function (data) {
$('.searchResults').html('');
//we need to check if the value is the same
console.log(data);
JSON.parse(data).forEach(function (item) {
if (item.typeObject === "scrapedSite") {
$('.searchResults').append('<div>!!<img src=' + item.websiteData.image + ' width=400><br><img src=' + item.websiteData.favicon + ' ><br>' + item.websiteData.title + ' <br> ' + item.websiteData.text + ' <br> <a href=' + item.url + ' target="_new">View Original</a><br><hr> </div>');
} else {
$('.searchResults').append('<div><h3>Incident Report</h3>' + item.description + ' <br> <hr> </div>');
if (typeof item.urls === "object") {
item.urls.forEach(function (aurl) {
console.log(data);
$('.searchResults').append('<div><li><a href=' + aurl + ' target=_NEW> ' + aurl + ' </a> </li> </div>');
});
}
}
});
}
});
} else {
$('.toolbarCanvas').html('');
}
});
});