-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.html
249 lines (211 loc) · 12.6 KB
/
main2.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>
That ain't my ticket!
</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Raleway:200">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css">
<!--<![endif]-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="/home/kivy/react-tutorial/move.js/move.js"></script>
<script src="printDirections.js"></script>
<head>
<body>
<div class="pure-g">
<h1 class="pure-u-1-3 pure-u-md-1-3" id="web_name"> Tick2Court </h1>
<p class="pure-u-2-3 pure-u-md-2-3" id="top_text">
Type in the address of where you got pulled over, and we will find the locations of its corresponding court
</p>
<br />
<br />
<hr>
<div id="address_box_buffer" class="pure-u-1-6">
</div id="displaybox"> <!-- sketchy code. DONOT FIX! BREAKS EVERYTHING! -->
<div id="address_box" class="pure-u-2-3">
<p id="form_text" class="pure-u-1">
Type in the address where you got the ticket
</p>
<form class="pure-form pure-g" method="post">
<input id="address" class="pure-input-2-3" type="text" placeholder="Street Address" required>
<button class="pure-button pure-input-1-3" onclick="changeDisplay()" id="submit">
<i class="fa fa-gavel"></i>
</button>
</form>
</div>
<hr>
<div class="hide" id="popup">
<div class="pure-u-1">
<h3> Court in charge of inputted address <h3>
</div>
<div id="courts" class="pure-u-1-2">
<div id="courtInfo" class="pure-u-1">
<div id="courtName"> City of Clayton Municipal Court </div>
<div id="courtAddress">S Brentwood Blvd </div>
<div id="courtPhone">314-290-8441</div>
<a id="siteLink" href="">
<div>Visit Website</div>
</a>
</div>
<div id="directions" class="">
<br />
<button id="printDirections" class="pure-button"> Get Directions </button>
<br>
<div id="actualDirect"></div>
</div>
<br />
</div>
<div id="map" class="pure-u-1-2">
<!--
<div id='Lat0' value="" hidden></div>
<div id='Lng0' value="" hidden></div>
<div id='Lat1' value="" hidden></div>
<div id='Lng1' value="" hidden></div>
-->
</div>
<div>
<!-- <b>Legal Services</b>
<br />
We recommend <a href="http://www.lsem.org/">Legal Services of Eastern Missouri</a>
<br />
If you cannot afford a lawyer, they may be able to find a volunteer
<br />
<a href="tel:+1-800-444-0514">1-800-444-0514</a>
<br />
Hours: Monday-Thursday 8:30 AM-3:30 PM
<br />
Fridays 1:30 PM-3:30 PM
<br>
Please note if emergency
</div> -->
</div>
</div>
</div>
</div>
<div id="box" class="pure-u-1"> df</div>
<script src="/home/kivy/react-tutorial/move.js/move.js">
move('#box')
.y(200)
.duration('3s')
.end();
</script>
<script>
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see the error "The Geolocation service
// failed.", it means you probably did not give permission for the browser to
// locate you.
// Copy here
var myX;
var myY;
// Copy here
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
// center: {lat: 38.627003, lng: -90.199404},
center: {lat: 38.627003, lng: -90.199404},
zoom: 15
});
var infoWindow = new google.maps.InfoWindow({map: map});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
// lat: position.coords.latitude,
// lng: position.coords.longitude
lat: Number(myX),
lng: Number(myY)
// document.getElementById('temp').innerHTML = myX.concat(", ", myY);
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
// Copy here
// Response to clicking the submit button
$(document).ready(function(){
$("#submit").click(function(event){
//Cohere address
var address = document.getElementById("address").value;
var apiKey = 'AIzaSyC0GUd7gFoVVt03p9-hR1dLfsjmrUm9pTM';
var apiBase = 'https://maps.googleapis.com/maps/api/geocode/json?address=';
var baseAddress = apiBase.concat(slugify(address));
var baseKey = baseAddress.concat("&key=").concat(apiKey);
var data;
$.getJSON(baseKey, function(data) {
var xy = {"x": JSON.stringify(data['results'][0]['geometry']['location']['lat']), "y":JSON.stringify(data['results'][0]['geometry']['location']['lng'])};
var destUrl = 'ayeke.me:3000/municipal/';
var sendXYUrl = destUrl.concat(JSON.stringify(data['results'][0]['geometry']['location']['lat'])).concat("/").concat(JSON.stringify(data['results'][0]['geometry']['location']['lng']));
// document.getElementById('temp').innerHTML = sendXYUrl;
var data2;
// myX = JSON.stringify(data['results'][0]['geometry']['location']['lat']);
// myY = JSON.stringify(data['results'][0]['geometry']['location']['lng']);
// initMap();
// document.getElementById('temp').innerHTML = myX.concat(", ", myY);
$.ajax({
url: sendXYUrl,
dataType:"json",
json:"mycallback",
success:function(data2)
{
if(data2['id'] != 0){
console.log()
// Put JSON data into divs
// Court
document.getElementById('courtName').innerHTML = JSON.stringify(data2['city']);
document.getElementById('courtName').setAttribute('href', JSON.stringify(data2['web']));
}else{
//FILLME!!!
// Maybe leave how I have eat. Have default case take care of this case
document.getElementById('courtName').innerHTML = "The violation occurred outside of Saint Louis County, or in unincorporated area outside the jurisdiction of any municipal court. Please contact the Saint Louis County Court for details. ";
}
document.getElementById('courtAddress').innerHTML = courtInfo.concat(JSON.stringify(data2['address']), ", ", JSON.stringify(data2['city']), ", ", JSON.stringify(data2['state']), ", ", JSON.stringify(data2['zip_code']));
var plus = "+";
var courtAddress = "Address: "
document.getElementById('courtPhone').innerHTML = courtAddress.concat(JSON.stringify(data2['phone']));
document.getElementById('courtPhone').setAttribute('href', plus.concat(slugify(JSON.stringify(data2['phone']))));
// document.getElementById('temp').innerHTML = JSON.stringify(data2);
myX = slugify(JSON.stringify(data2['x']));
myY = slugify(JSON.stringify(data2['y']));
initMap();
}
});
});
document.getElementById('popup').style.visibility = 'visible';
event.preventDefault();
});
});
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=&signed_in=true&callback=initMap" async defer>
</script>
<div id="temp"></div>
</body>
</html>