-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
147 lines (138 loc) · 6.1 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
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
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/misc.css">
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css">
<title>NRV Park Search</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div data-role="page" id="page1">
<div class="jumbotron header-bg">
<h1 style="color:white; background-color:black; opacity:0.7;">NRV Park Search</h1>
</div>
<div class="container" id="search">
<div class="row">
<div class="col-md-12">
<form method="get" class="form-horizontal">
<div id="locationArea">
<label for="location"><input type="checkbox" id="location" name="location"> Use my location</label>
</div>
<input type="hidden" name="lat" id="lat" />
<input type="hidden" name="lon" id="lon" />
<label class="address" for="address">Address</label>
<input type="text" class="form-control address" id="address" name="address" placeholder="Your Address">
<input data-theme="c" type="button" id="searchAmenities" class="btn btn-primary" value="Advanced Search by Amentity(ies)" />
<div id="amenities">
</div>
<input data-theme="b" type="submit" id="updateMap" class="btn btn-primary" value="Show Nearest Parks" />
</form>
</div>
</div>
</div>
</div>
<!-- jquery: 1.12.4 -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script src="js/misc.js"></script>
<script type="text/javascript">
$( document ).ajaxStart(function() {
busy(true);
});
$( document ).ajaxComplete(function() {
busy(false);
});
$( document ).ajaxError(function() {
busy(false);
});
function busy(isBusy) {
if(isBusy) {
$.mobile.loading( "show" );
} else {
$.mobile.loading( "hide" );
}
}
function addAmenities(data)
{
data.map(function(amenity) {
addAmenity([amenity.id, amenity.amenity_name])
});
}
function addAmenity(amenity)
{
id = amenity[0];
name = amenity[1];
container = $("#amenities");
$('<label />', {'for': 'cb'+id, id: 'cbl'+id}).appendTo(container);
$('#cbl'+id).html('<input type="checkbox" id="cb'+id+'" name="cb'+id+'" value="t" />'+name);
$('#cbl'+id).trigger('create');
}
$("form").submit(function(event){
if($("#address").val()=='' && !$("#location").is(':checked')) {
alert("Please enter an address or nearby landmark");
}
else {
window.location="parks.html?"+$(this).serialize();
}
return false;
});
$("#searchAmenities").click(function() {
$("#amenities").show();
$(this).hide();
});
$("#location").change(function () {
$("#address").prop( "disabled", this.checked );
if(this.checked) {
$(".address").hide();
busy(true);
geoLocation.getLocation().then(function(position) {
$("#lat").val(position.coords.latitude);
$("#lon").val(position.coords.longitude);
busy(false);
}).fail(function(err) {
$("#location").prop('checked', false);
$("#location").removeAttr('checked').checkboxradio("refresh");
$("#location").trigger("change");
busy(false);
showError(err);
});
} else {
$(".address").show();
}
});
$('#page1').on('pagecreate', function() {
if(getCookie("ack")!=1 || getUrlVars()['dev']==1) {
window.location = "intro.html";
}
$("#address").val("");
getData.getAmenities().then(function(data) {
addAmenities(data);
$("#amenities").hide();
}).fail(function(err) {
alert(err);
});
var latitude = getUrlVars()["lat"];
var longitude = getUrlVars()["lon"];
if(getUrlVars()["location"] == "on" && latitude != "" && longitude != "")
{
$("#locationArea").show();
$("#location").attr('checked','checked');
$("#location").trigger('change');
$("#location").checkboxradio('refresh');
$("#lat").val(latitude);
$("#lon").val(longitude);
}
});
</script>
</body>
</html>