-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
141 lines (113 loc) · 3.3 KB
/
search.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Solr Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=true"> </script>
<script type="text/javascript">
function check() {
var addform = document.form1;
if (addform.title.value == "") {
alert("Please enter the Title!");
addform.title.focus();
}
else
makeRequest();
}
var req = false;
var json;
var title;
function makeRequest() {
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
} else {
if (window.ActiveXObject) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
}
}
if (req) {
//alert( document.getElementById("title").value );
var url = "http://localhost:12345/solr/select?wt=json&indent=on&q=" + document.getElementById("title").value + "&rows=1000" ;
// alert(url);
req.onreadystatechange = showContents;
req.open("GET", url, true);
req.setRequestHeader("Method", "GET" + url + "HTTP/1.1");
req.send(null);
} else {
document.getElementById("updateArea").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
}
}
function showContents() {
var tableOutput = "";
if (req.readyState == 4) {
if (req.status == 200) {
tableOutput=req.responseText;
json = eval("(" + req.responseText + ")");
list = json.response.docs;
var num=list.length;
//alert(num);
var locations=[];
//['San Diego', 32.7150, -117.1625]
for (var i = 0; i < num; i++) {
var loc=[];
loc.push(list[i].id);
loc.push(list[i].lat);
loc.push(list[i].long);
locations.push(loc);
}
//locations+="]";
//alert(locations);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: new google.maps.LatLng(39.828127, -98.579404),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
// alert(locations[i][1]);
// alert(locations[i][2]);
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
} else {
tableOutput = "<h1>" + document.getElementById("title").value + " does not exist!</h1>";
document.getElementById("updateArea").innerHTML = tableOutput;
}
} else {
}
}
</script>
</head>
<body>
<center>
<h1>Solr Search</h1>
<!-- <form name="form1" id="form1" method="post" action= onsubmit="return check();"> -->
<form name="form1" id="form1" >
<div id=outline>
<table >
<input id="title" type="text" value="" size="65" />
</table>
<input type="button" name="search" value="Submit" onclick="check()" />
</div>
</form>
<div id="map" style="width: 1000px; height: 600px;"></div>
<noscript>
</center>
</body>