forked from raybesiga/mobilize-our-air
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
255 lines (216 loc) · 11.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
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
250
251
252
253
254
255
<html>
<head>
<title>Mobilizing Our Air</title>
<meta charset='utf-8'>
<script type="text/javascript" src='js/jquery.js '></script>
<script type="text/javascript" src='js/tabletop1.3.4.js'></script>
<script type="text/javascript" src='js/sheetsee.js'></script>
<script type="text/javascript" src='js/leaflet.markercluster.js'></script>
<link rel="shortcut icon" href="https://raw.github.com/jlord/hack-spots/master/favico.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link media="screen" rel="stylesheet" type="text/css" href="css/mobilizingourair.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<!-- <link media="screen" rel="stylesheet" type="text/css" href="css/style.css"> #}
<link media="screen" rel="stylesheet" type="text/css" href="css/site.css"> -->
<link rel="stylesheet" href="css/MarkerCluster.css" />
<link rel="stylesheet" href="css/MarkerCluster.Default.css" />
</head>
<body>
<nav class="db dt-l w-100 border-box pa3 ph5-l">
<a class="db dtc-l v-mid mid-gray link dim w-100 w-25-l tc tl-l mb2 mb0-l" href="#" title="Home">
<h1>Mobilizing Our Air</h1>
</a>
<div class="db dtc-l v-mid w-100 w-75-l tc tr-l">
<a class="link dim dark-gray f6 f5-l dib mr3 mr4-l" href="/" title="Home">Home</a>
<a class="link dim dark-gray f6 f5-l dib mr3 mr4-l" href="/about.html" title="About">About</a>
<!-- <a class="link dim dark-gray f6 f5-l dib" href="#" title="Contact">Contact</a> -->
</div>
</nav>
<article class="cf">
<div class="w-100">x</div>
<div class="w-100">y</div>
</article>
<article class="cf flex flex-wrap">
<div class="fn fl-ns w-100" >
<div id="map"></div>
</div>
<div class="fn fl-ns w-100" style="color:#42465f;background-color:#edeef4">
<div id="rightSide" class="pa3">
<div id="latestSpot"></div>
<div id="selectedSpot"></div>
</div>
</div>
</article>
<article class="cf">
<div class="pa3 ph5-l mv3">
<div id="theNumberofSpots" class="mv3"></div>
<input id="tableFilter" class="ba b--black-20 pa2 mb2 db w-100" type="text" placeholder="Search.."></input>
<a class="f6 link dim ph3 pv2 mb2 dib white bg-black clear" href="#0">Clear Search</a>
<a class="f6 link dim ph3 pv2 mb2 dib white bg-black resetMap" href="#0">Reset Map</a>
<span class="noMatches">no matches</span>
<div class="overflow-auto">
<div id="hackSpotsTable" class="mt3"></div>
</div>
</div>
</article>
<script id="hackSpotsTable" type="text/html">
<table class="f5 w-100 center lh-copy" cellspacing="0>
<thead>
<tr class="stripe-dark">
<th class="fw6 tl pa3 bg-white">Name</th>
<th class="fw6 tl pa3 bg-white">Address</th>
<th class="fw6 tl pa3 bg-white">City</th>
<th class="fw6 tl pa3 bg-white">Country</th>
<th class="fw6 tl pa3 bg-white">On The Web</th>
</tr>
</thead>
<tbody class="lh-copy">
{{#rows}}
<tr id="{{rowNumber}}" class="spotRow stripe-dark lh-title pa2 link">
<td class="pa3">{{name}}</td>
<td class="pa3">{{address}}</td>
<td class="pa3">{{city}}</td>
<td class="pa3">{{country}}</td>
<td class="pa3"><a class="button" href="{{website}}" target="_blank">Website</a> <a class="button" href="{{facebook}}" target="_blank">Facebook</a> <a class="button" href="{{twitter}}" target="_blank">Twitter</a></td>
</tr>
{{/rows}}
</tbody>
</table>
</script>
<script id="latestSpot" type="text/html">
{{#rows}}
<h4 class="fauxButton">RECENTLY ADDED GROUP</h4>
<h2 class="f2-ns f3">{{name}}</h2>
<span class="scenario">{{address}}</span>
<p class="lh-copy">{{description}}</p>
<span class="scenario">{{tag1}}</span> <span class="scenario">{{tag2}}</span> <span class="scenario">{{tag3}}</span>
<div class="mt2">
<a href="{{website}}" title="Group Website" target="_blank" class="f6 dib pr2 mid-gray dim">Website</a>
<a href="{{facebook}}" title="Facebook" target="_blank" class="f6 dib pr2 mid-gray dim">Facebook</a>
<a href="{{twitter}}" title="Twitter" target="_blank" class="f6 dib ph2 mid-gray dim">Twitter</a>
</div>
{{/rows}}
</script>
<script id="theNumberofSpots" type="text/html">
<span class="scenario f3">{{numberOfSpots}} Community Groups Strong!</span>
</script>
<script id="selectedSpot" type="text/html">
{{#rows}}
<h4 class="fauxButton">SELECTED GROUP</h4>
<h2 class="f2-ns f3">{{name}}</h2>
<span class="scenario">{{address}}</span>
<p class="lh-copy">{{description}}</p>
<span class="scenario">{{tag1}}</span> <span class="scenario">{{tag2}}</span> <span class="scenario">{{tag3}}</span>
<div class="mt2">
<a href="{{website}}" title="Group Website" target="_blank" class="f6 dib pr2 mid-gray dim">Website</a>
<a href="{{facebook}}" title="Facebook" target="_blank" class="f6 dib pr2 mid-gray dim">Facebook</a>
<a href="{{twitter}}" title="Twitter" target="_blank" class="f6 dib ph2 mid-gray dim">Twitter</a>
</div>
{{/rows}}
</script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var gData
var URL = "1yT4Kv_BWTH1vuF8Tx1_qFWP-HQ_DCoiF-s_29c6GKE8"
Tabletop.init({ key: URL, callback: showInfo, simpleSheet: true })
})
// so long, so messy
function showInfo(gData) {
tableOptions = {
"data": gData,
"tableDiv": "#hackSpotsTable",
"filterDiv": "#tableFilter"
}
// make the table, and the search bar
Sheetsee.makeTable(tableOptions)
Sheetsee.initiateTableFilter(tableOptions)
// create geoJSON with coordinates and other
// useful bits from the original data
var optionsJSON = ["name", "address", "country", "rowNumber", "website", "facebook", "twitter", "tag1", "tag2", "description"]
var geoJSON = Sheetsee.createGeoJSON(gData, optionsJSON)
// create map, tilelayer (map background), markers and popups
var map = Sheetsee.loadMap("map")
Sheetsee.addTileLayer(map, 'https://api.tiles.mapbox.com/v4/mapbox.streets-basic.json?access_token=pk.eyJ1IjoicmF5YmVzaWdhIiwiYSI6IlZxbVMtR2MifQ.mMZ6_JoSJOVvoAPBdEtVMw')
var markerLayer = Sheetsee.addMarkerLayer(geoJSON, map, "<h2>{{ name }}</h2>", true)
// find the latest spot with the most important
// info filled in (to prevent map breaking if
// someone is currently editing spreadsheet)
var theLatestSpot = findLatestCompleteSpot(gData)
var latestSpot = Sheetsee.ich.latestSpot({
rows: theLatestSpot
})
// set it and pan to it
$('#latestSpot').html(latestSpot)
map.setView([theLatestSpot.lat, theLatestSpot.long], 15)
// when someone clicks on a row, highlight it and
// re-center the map
// TODO show popup, change marker color
$('.spotRow').live("click", function(event) {
$('.spotRow').removeClass("selectedRow")
var rowNumber = $(this).closest("tr").attr("id")
$('#' + rowNumber).addClass("selectedRow")
var dataElement = Sheetsee.getMatches(gData, rowNumber, "rowNumber")
var selectedSpot = Sheetsee.ich.selectedSpot({
rows: dataElement
})
$('#latestSpot').css("display", "none")
$('#selectedSpot').html(selectedSpot).css("display", "inline")
var selectedCoords = [dataElement[0].lat, dataElement[0].long]
map.setView(selectedCoords, 15)
})
// so that the first map and info that loads
// is complete and doesn't show rows that are
// actively being edited by folk
function findLatestCompleteSpot(data) {
var latestCompleteSpot = []
var startWithLatestRow = data.reverse()
startWithLatestRow.forEach(function(row){
if (!row.lat || !row.long || !row.name || !row.address || !row.city ) return
else latestCompleteSpot.push(row)
})
return latestCompleteSpot[0]
}
// Add click listener to the markerLayer
markerLayer.on('click', function(e) {
// clear any selected rows
$('.spotRow').removeClass("selectedRow")
// get row number of selected marker
var rowNumber = e.layer.feature.opts.rowNumber
// find that row in the table and make consider it selected
$('#' + rowNumber).addClass("selectedRow")
// using row number, get the data for the selected spot
var dataElement = Sheetsee.getMatches(gData, rowNumber.toString(), "rowNumber")
// take those details and re-write the selected spot section
var selectedSpot = Sheetsee.ich.selectedSpot({
rows: dataElement
})
// center the map on the selected element
map.panTo([dataElement[0].lat, dataElement[0].long])
// update the spot listing
$('#latestSpot').css("display", "none")
$('#selectedSpot').html(selectedSpot).css("display", "inline")
})
// reset the map, zoom out, and recenter on 0,0
$('.resetMap').click(function() {
$('.spotRow').removeClass("selectedRow")
$('#latestSpot').css("display", "inline")
$('#selectedSpot').css("display", "none")
map.setView([0,0], 1)
})
// find total number of spots added
var theNumberofSpots = Sheetsee.ich.theNumberofSpots({
numberOfSpots: gData.length
})
$('#theNumberofSpots').html(theNumberofSpots)
if(window.location.hash) {
$('#tableFilter').val(window.location.hash.substring(1)).keyup()
$('.spotRow').first().click()
}
}
$(document).on('keyup', '#tableFilter', function() {
window.location.hash = $(this).val()
$('.spotRow').first().click()
})
</script>
</body>
</html>