-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
72 lines (66 loc) · 3.31 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
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<title>OrestarClone</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</script>
</head>
< body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">Orestar</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!-- /.navbar-collapse -->
</div>
</nav>
<div class="container">
<div class="well" style="height:70px;">
<form role="form" style="text-align:center;">
<div class="form-group">
<label for="exampleInputEmail1">From</label>
<input type="text" placeholder="YYYY-MM-DD" name="from_date">
<label for="exampleInputPassword1">To</label>
<input type="text" placeholder="YYYY-MM-DD" name="to_date">
<label for="exampleInputFile">Query</label>
<input type="text" name="query">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>
</div>
<footer>
<hr>
<p>Built by the PNCA Data Viz Workshop. View on <a href="https://github.com/hackoregon/frontend">Github</a>.</p>
</footer>
</div>
<script type="text/javascript">
$("form").submit(function() {
$.ajax({
type: "POST",
url: "http://localhost:5000/search",
data: $("form").serialize(),
crossDomain: true,
success: function(data) {
if ($('table').length == 0) {
$('.well').after("<div class='table-responsive'><table class='table table-striped'><thead><th>Active Election</th><th>Addr Line1</th><th>Amount</th><th>Book Type</th><th>Candidate Name</th><th>City</th><th>Committee Name</th><th>Zip</th></thead></div>")
} else {
$('table').remove();
$('.well').after("<div class='table-responsive'><table class='table table-striped'><thead><th>Active Election</th><th>Addr Line1</th><th>Amount</th><th>Book Type</th><th>Candidate Name</th><th>City</th><th>Committee Name</th><th>Zip</th></thead></div>")
}
var d = JSON.parse(data)
$.each(d, function(i, item) {
$('table').append('<tr>' + '<td>' + item['Active Election'] + '</td>' +'<td>' + item['Addr Line1'] + '</td>' + '<td>$' + item['Amount'] + '</td>' + '<td>' + item['Book Type'] + '</td>' + '<td>' + item['Candidate First Name'] + ' ' + item['Candidate Last Name'] + '</td>' + '<td>' + item['City'] + '</td>' + '<td>' + item['Committee Name'] + '</td>' + '<td>' + item['Zip'] + '</td></tr>')
})
}
});
event.preventDefault();
})
</script>
</body>
</html>