-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
213 lines (183 loc) · 6.48 KB
/
Copy pathindex.html
File metadata and controls
213 lines (183 loc) · 6.48 KB
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Add Points to Map</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"
integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
crossorigin=""></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.3.5/papaparse.min.js"></script>
<!-- style sheet for mapzen.js -->
<link rel="stylesheet" href="https://mapzen.com/js/mapzen.css">
<!-- latest minified version of mapzen.js -->
<script src="https://mapzen.com/js/mapzen.min.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
font-family: Arial;
}
#map {
width: 100vw;
height: 100vh;
visibility: hidden;
}
#gform {
position: absolute;
width: 400px;
top: 0;
left: calc(50% - 200px);
z-index: 999;
display: block;
}
#gform label, #gform input {
font-size: 1.1em;
line-height: 1.2em;
}
#gform input[type="submit"] {
font-size: 35px;
background: blue;
border: 0;
color: white;
padding: 10px;
cursor: pointer;
border-radius: 5px;
z-index: 999;
visibility: hidden;
width: 200px;
margin-left: 100px;
}
#page1 {
margin-top: 40px;
left: calc(50% + 200px);
}
.leaflet-popup-content {
font-size: 1.3em;
}
.leaflet-popup {
width: 300px;
}
@media screen and (max-device-width: 480px) and (orientation: portrait) {
#gform {
width: 90vw;
left: 5vw;
}
#gform input[type="submit"] {
width: 100%;
margin-left: 0;
}
#page1 {
width: 100%;
}
}
</style>
</head>
<body>
<div id="map"></div>
<form id="gform" method="POST" action="https://script.google.com/macros/s/AKfycbwJV4fQJ6Z5hxjT9p6tZscaEUIAoCbqp4Puirc-aTDA60BqANr4/exec" target="hidden-form">
<div id="page1">
<p>
Are you willing to be interviewed for 20-30 minutes to learn
more about your perceptions and experiences of Trinity
and Hartford? (We’ll buy you a beverage or pastry to compensate
you for your time.)
</p>
<p>
The entire process is voluntary and
confidential, and you can stop at any time. If you agree to
participate, enter your information below so that
one of our student researchers can contact you
to set up a mutually convenient time and place for an interview:
</p>
<label>First name: <input type="text" name="name"></label>
<br>
<label>Phone #: <input type="text" name="phone"></label>
<br><br><br>
<input type="button" id="agree" name="agree" value="I agree to participate. Go to map.">
</div>
<input type="submit" value="Submit">
</form>
<iframe style="display:none" name="hidden-form"></iframe>
<script>
$('input[name="agree"]').click(function() {
var name = $('input[name="name"]').val();
var phone = $('input[name="phone"]').val();
if (phone.length < 10 || name.length < 2) {
this.checked = false;
alert('Please insert your name and a 10-digit phone number');
} else {
$('#gform').submit();
$('#gform').attr('target', '');
$('#page1').css('display', 'none');
$('#map').css('visibility', 'visible');
$('#gform').css({
top: '100vh',
marginTop: '-80px',
height: 0
});
$('input[type="submit"]').css({
visibility: 'visible',
});
}
});
$.urlParam = function(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
var trinCoords = [41.7479, -72.6903];
var map = L.map('map', {zoomControl: false}).setView(trinCoords, 14);
var baseLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
baseLayer.addTo(map);
var popup = L.popup()
.setLatLng([41.7439, -72.6903]) // slightly below Trinity
.setContent("<p>Click on the map to show up to 5 places you have visited in the Hartford area since arriving at Trinity.</p>\
Explore the map or use search box.</p>\
Only blue markers count!</p>")
.openOn(map);
var trinity = L.marker(trinCoords, {
icon: L.icon({
iconUrl: 'trinity.png',
iconSize: [48, 48]
})
}).addTo(map);
var geocoder = L.Mapzen.geocoder('search-jBPBt5y', {
position: 'topleft',
expanded: true,
fullWidth: false,
markers: {icon: L.icon({iconUrl: 'marker.png', iconSize: [45,45], iconAnchor: [22, 45], popupAnchor: [0, -40]}) },
}).addTo(map);
L.control.zoom({position: 'topleft'}).addTo(map);
var markers = [];
map.on('click', function(e) {
if (markers.length == 5) return;
markers.push(
L.marker(e.latlng)
.on('click', function() {
for (i in markers) {
if (e.latlng.lat == markers[i]._latlng.lat && e.latlng.lng == markers[i]._latlng.lng) {
markers.splice(i, 1);
map.removeLayer(this);
}
}
})
.addTo(map)
);
});
$('#gform').submit(function() {
$(this).append('<input type="hidden" name="id" value="' + $.urlParam('id') + '">');
for (i = 0; i < markers.length; i++) {
$(this).append('<input type="hidden" name="place' + i + '" value="' + markers[i]._latlng.lat + ',' + markers[i]._latlng.lng + '">');
}
return true;
});
</script>
</body>
</html>