-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
61 lines (61 loc) · 1.92 KB
/
index.html
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
55
56
57
58
59
60
61
<html>
<meta charset="utf-8"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#go").click(function() {
var choice;
var selectedValue;
if($("input[name=choice]").is(":checked")&&$.trim($("#search").val()).length>0)
{
selectedValue=$("input[name=choice]:checked").val();
if(selectedValue.match("lucene"))
choice="lucene";
else if(selectedValue.match("pagerank"))
choice="pagerank";
$.ajax({
type: 'GET',
dataType:'json',
url: 'http://localhost:1337/Go?search='+$.trim($("#search").val())+'&choice='+choice,
success:function(data) {
$("#results").html("");
$("#count").html("");
if(data.length==0)
$("#results").append("<p>Sorry no results were found, try another query term</p>");
else
{
var number=data[0];
$("#count").html("<div>Results 1 - 10 of "+number+":<div>");
var docs=data[1];
docs.forEach(function(x){
var url=x.site_url;
var description=x.description;
if (typeof description=== "undefined") {
description="N/A";
}
$("#results").append("<br>");
$("#results").append("<div><a style='text-decoration:none' href='"+url+"' target='_blank'>"+x.title+"</a><br><a style='color:green' href='"+url+"' target='_blank'>"+url+"</a><br>"+description+"<br><font size='2'>"+x.id+"</font></div>");
});
}
},
error:function(jqXHR, textStatus, errorThrown){
}
});
}
else{
alert("Please fill all the details");
}
});
});
</script>
<body>
<div align="center">
<input type="text" id="search" required/>
<input type="radio" name="choice" value="lucene"/>Lucene
<input type="radio" name="choice" value="pagerank"/>PageRank
<input type="submit" value="Search" id="go"/>
</div>
<div id="count"></div>
<div id="results"></div>
</body>
</html>