-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
129 lines (122 loc) · 5.15 KB
/
index.php
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
<!-- <!DOCTYPE html> -->
<html>
<head>
<style>
body {padding-top: 50px;}
.day {padding-left: 100px;}
.hours {padding-left: 100px;}
.title {font-style: bold;}
.hide {visibility: hidden;}
</style>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
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
}
// REsponse to clicking the submit button
$(document).ready(function(){
$("#submit").click(function(event){
//Cohere address
var address = document.getElementById("address").value;
var jurisdictionString = "Court with jurisdiction over violations at: ";
document.getElementById('violationAddress').innerHTML = jurisdictionString.concat(address);
// Cohere API call
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 = 'http://www.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']));
// $.get(sendXYUrl);
var data2;
$.ajax({
url: sendXYUrl,
dataType:"json",
json:"mycallback",
success:function(data2)
{
document.getElementById('temp').innerHTML = JSON.stringify(data2);
// Put JSON data into divs
// Court
document.getElementById('courtName').innerHTML = JSON.stringify(data2['municipality']['name']);
document.getElementById('siteLink').setAttribute('href', JSON.stringify(data2['municipality']['municipal_court_website']));
var courtAddress = "Address: ";
document.getElementById('courtAddress').innerHTML = courtInfo.concat(JSON.stringify(data2['address']), ", \n", 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('courtInfo').innerHTML = courtInfo.concat(JSON.stringify(data2['municipality']['court_docket_listed']), ", ", );
}
});
// document.getElementById('temp').innerHTML = sendXYUrl;
// var xmlHttp = new XMLHttpRequest();
// xmlHttp.onreadystatechange = function() {
// if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
// var temp = callback(xmlHttp.responseText);
// document.getElementById('temp').innerHTML = temp;
// // Put the JSON data into the page
// }
// }
// xmlHttp.open("GET", sendXYUrl, true); // true for asynchronous
// console.log();
// xmlHttp.send(null);
});
// Display the located court
document.getElementById('popup').style.visibility = 'visible';
event.preventDefault();
});
});
</script>
Live in Saint Louis County? Find where to challenge a ticket
<!-- Input Form -->
<form method="POST">
Where did you get your ticket? <br>
<input type="text" name="address" id="address">
<br>
<input type="submit" id="submit" value="Submit">
</form>
<!-- Popup that shows processed data -->
<div class="hide" id="popup">
<b id="violationAddress"></b>
<br>
<div id="courtName"></div>
<br>
<div id="courtAddress"></div>
<br>
<div id="courtPhone"></div>
<br>
<b>Directions</b>
<br>
<div id="directionsText"></div>
<div id="directionsMap"></div>
<br>
<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 id="temp"></div>
<script src="index.js"></script>
</body>
</html>