forked from Lips/nyc-fca-dir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
191 lines (177 loc) · 8.89 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
<!DOCTYPE html>
<html>
<head>
<title>St. Louis Area Solidarity Economy</title>
<script type="text/javascript" src="js/ICanHaz.js"></script>
<script type="text/javascript" src='http://api.tiles.mapbox.com/mapbox.js/v1.5.1/mapbox.js'></script>
<script type="text/javascript" src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js'></script>
<script type="text/javascript" src='js/tabletop.js'></script>
<script type="text/javascript" src='js/sheetsee.js'></script>
<script type="text/javascript" src='//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/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 href='http://api.tiles.mapbox.com/mapbox.js/v1.5.1/mapbox.css' rel='stylesheet' />
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic'>
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Amatic+SC:400,700'>
<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>
<div id="wrapper">
<h1>St. Louis Area Solidarity Economy</h1>
<div>
<ul class="nav">
<li><a href="#info">INFO</a> -</li>
</ul>
</div>
<div class="container">
<div id="rightSide">
<div id="latestSpot"></div>
<div id="selectedSpot"></div>
</div>
<div id="map"></div>
</div>
<div class="container">
<input id="tableFilter" type="text" placeholder="filter by.."></input>
<span class="clear button">Clear</span> <span class="resetMap button">Reset Map</span>
<span class="noMatches">no matches</span>
<div id="hackSpotsTable"></div>
</div>
<div id="info" class="container">
<h3>Contribute!</h3>
<p>The information in this list is automagically pulled from <a
href="https://docs.google.com/spreadsheet/ccc?key=18JejBSFDPSMxlbmzvp1_NjfIk-CMzxSEy7-PBle6qGc#gid=0" target="_blank">this Google Spreadsheet</a>, which I've shared, so feel free to add/update the spreadsheet where appropriate. For the map you'll need to <strong>get the lat and long</strong> of the spot, you can get that <a href="http://www.latlong.net/" target="_blank">here</a>.</p>
<h3>About the tech</h3>
<p>This site exists as it is because of several open-source projects, most notably <a href="http://jlord.github.io/sheetsee.js" target="_blank">sheetsee.js</a> and <a href="http://jlord.us/fork-n-go/">over here</a>. If you want to make a similar site, see: <a href="https://github.com/Lips/nyc-fca-dir">Lips' map</a> or the code for this site <a href="https://github.com/schimmy/stl-coop-dir">here</a>. Participation is welcome!</p>
</div>
</div><!-- end wrapper -->
<script id="hackSpotsTable" type="text/html">
<table>
<tr><th class="tHeader">Name</th><th class="tHeader">Neighborhood</th><th class="tHeader">City</th><th class="tHeader">Type</th><th class="tHeader">Open to</th><th class="">Links</th></tr>
{{#rows}}
<tr id="{{rowNumber}}" class="spotRow"><td>{{name}}</td><td>{{neighborhood}}</td><td>{{city}}</td><td>{{type}}</td><td>{{whocanshop}}</td><td><a class="button" href="https://maps.google.com/maps?q={{name}},{{city}},{{state}}" target="_blank">G Map</a> <a class="button" href="http://www.yelp.com/search?find_desc={{name}}&find_loc={{city}},{{state}}" target="_blank">Yelp</a></td></tr>
<tr class="hideRow"><td>Open to: {{whocanshop}}</td></tr>
{{/rows}}
</table>
</script>
<script id="latestSpot" type="text/html">
{{#rows}}
<h4 class="fauxButton">MOST RECENT SPOT</h4>
<h2>{{name}}</h2>
<p class="colorText">{{address}}<p>
<p class="colorText">{{city}}, {{state}}</p>
<ul>
<li><span class="category">Open to:</span> {{whocanshop}}</li>
<li><span class="category">Last Edited by:</span> {{lasteditedby}}</li>
</ul>
<ul>
<li><a href="https://maps.google.com/maps?q={{name}},{{city}},{{state}}" target="_blank">View in Google Maps</a></li>
<li><a href="http://www.yelp.com/search?find_desc={{name}}&find_loc={{city}},{{state}}" target="_blank">Find on Yelp</a></li>
</ul>
{{/rows}}
</script>
<script id="selectedSpot" type="text/html">
{{#rows}}
<h4 class="fauxButton">SELECTED SPOT</h4>
<h2>{{name}}</h2>
<p class="colorText">{{address}}<p>
<p class="colorText">{{city}}, {{state}}</p>
<ul>
<li><span class="category">Open to:</span> {{whocanshop}}</li>
<li><span class="category">Last Edited by:</span> {{lasteditedby}}</li>
</ul>
<ul>
<li><a href="https://maps.google.com/maps?q={{name}},{{city}},{{state}}" target="_blank">View in Google Maps</a></li>
<li><a href="http://www.yelp.com/search?find_desc={{name}}&find_loc={{city}},{{state}}" target="_blank">Find on Yelp</a></li>
</ul>
{{/rows}}
</script>
<script type="text/javascript">
// TODO: why is this not immediate and blocking?
document.addEventListener('DOMContentLoaded', function() {
var gData
var URL = "18JejBSFDPSMxlbmzvp1_NjfIk-CMzxSEy7-PBle6qGc"
Tabletop.init( { key: URL, callback: showInfo, simpleSheet: true } )
})
function showInfo(data) {
gData = data
// make the table, and the search bar
Sheetsee.makeTable(gData, "#hackSpotsTable")
Sheetsee.initiateTableFilter(gData, "#tableFilter", "#hackSpotsTable")
// when someone clicks on a row, re-center the map
$('.spotRow').on("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 = ich.selectedSpot({
rows: dataElement
})
$('#latestSpot').css("display", "none")
$('#selectedSpot').html(selectedSpot).css("display", "inline")
var selectedCoords = [dataElement[0].lat, dataElement[0].long]
map.panTo(selectedCoords, 11)
})
// 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 || !row.state ) return
else latestCompleteSpot.push(row)
})
return latestCompleteSpot[0]
}
// 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 = ich.latestSpot({
rows: theLatestSpot
})
$('#latestSpot').html(latestSpot)
// create geoJSON with coordinates and other
// useful bits from the original data
var optionsJSON = ["name", "address", "city", "rowNumber"]
var geoJSON = Sheetsee.createGeoJSON(gData, optionsJSON)
// create map, tilelayer (map background), markers and popups
var map = Sheetsee.loadMap("map")
Sheetsee.addTileLayer(map, 'schimmy.gg480cl6')
var markerLayer = Sheetsee.addMarkerLayer(geoJSON, map, 13)
setupMap(map, markerLayer)
// design the popups to have the content and
// interactions that we want
function setupMap(map, markerLayer) {
markerLayer.on('click', function(e) {
// get row number of selected marker
var rowNumber = e.layer.feature.opts.rowNumber.toString()
// remove old selected row
$('.spotRow').removeClass("selectedRow")
// 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, "rowNumber")
// take those details and re-write the selected spot section
var selectedSpot = ich.selectedSpot({
rows: dataElement
})
$('#latestSpot').css("display", "none")
$('#selectedSpot').html(selectedSpot).css("display", "inline")
var feature = e.layer.feature
var popupContent = '<h2>' + feature.opts.name + '</h2>'
e.layer.bindPopup(popupContent, {closeButton: false,}).openPopup();
})
}
$('.resetMap').click(function() {
setupMap(map, markerLayer)
$('#latestSpot').css("display", "inline")
$('#selectedSpot').css("display", "none")
})
}
</script>
</body>
</html>