-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
296 lines (261 loc) · 11.4 KB
/
index.html
File metadata and controls
296 lines (261 loc) · 11.4 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Street Art Orlando</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="manifest" href="site.webmanifest">
<link rel="apple-touch-icon" href="icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<div class="modal fade" id="infoModal" tabindex="-1" role="dialog" aria-labelledby="infoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered mw-100 w-75" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">Image Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col">
<div class="img_parent">
<img id="art_img" src="https://via.placeholder.com/500" />
</div>
</div>
<div class="col">
<div id="mapdiv" style="width:300px;height:300px;z-index:9999"></div>
<hr />
<h2 id="art_title"></h2>
<h2 id="art_artist"></h2>
<h2 id="art_submitted_by"></h2>
<h2 id="art_location_note"></h2>
</div>
</div>
</div>
</div>
</div>
</div>
<header class="header_bar">
<div class="container">
<div class="nav_wrapper">
<nav class="navbar navbar-expand-sm">
<ul class="navbar-nav mr-auto">
<li class="navbar-brand mt-1">Street Art Orlando</li>
</ul>
<a id="navbar_menu" data-toggle="collapse" href="#appLinkBannerWrapper" role="button" aria-expanded="true" aria-controls="appLinkBannerWrapper">
<i class="fas fa-bars"></i>
</a>
</nav>
</div>
</div>
</div>
<div id="appLinkBannerWrapper" class="text-center collapse">
<div id="appLinkBanner" class="row">
<a class="btn-primary btn btn-lg align-self-center mx-auto" href="https://itunes.apple.com/app/id1422535206?mt=8&at=11l7ss">
<i class="fa fa-apple fa-lg"></i> App Store
</a>
</div>
</header>
<!-- temp; this section will be part of an infinite lazy loader -->
<section id="gallery">
<div class="grid_container container" style="width:914px">
<div class="row text-center" id="gallery_page_1">
</div>
</div>
</section>
<!-- popper.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- bootstrap.js -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- modernizr -->
<script src="js/vendor/modernizr-3.6.0.min.js"></script>
<!-- axios -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!-- lazyload-->
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@11.0.2/dist/lazyload.min.js"></script>
<!-- lodash.js -->
<script src="./js/lodash.js"></script>
<!-- OpenLayers API -->
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>
let photoInfo = {};
let map = new ol.Map();
let mapSource = new ol.source.OSM();
let currPage = 1;
let imgsPerPage = 12;
let lazyLoadInstance = new LazyLoad({
elements_selector: ".lazy"
});
$(document).ready(() => {
appendImages(currPage);
$(document).on('scroll', _.throttle(checkToLoadAjax, 300));
});
function checkToLoadAjax() {
if($(window).scrollTop() + $(window).height() >= $(document).height()) {
currPage++;
appendImages(currPage);
}
}
function updateLazyLoad() {
if(lazyLoadInstance) {
lazyLoadInstance.update();
}
}
function retrieveImageInfo(currPage) {
return axios.get(`https://sao-api.herokuapp.com/api/submissions?page=${currPage}&per_page=${imgsPerPage}`, {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
}
async function appendImages() {
let res = await retrieveImageInfo(currPage);
for(let i = 0; i < res.data.submissions.length; i++) {
photoInfo[i + (currPage-1)*imgsPerPage] = {
'artist': res.data.submissions[i].artist,
'created_at': res.data.submissions[i].created_at,
'description': res.data.submissions[i].description,
'latitude': res.data.submissions[i].latitude,
'location_note': res.data.submissions[i].location_note,
'longitude': res.data.submissions[i].longitude,
'nickname': res.data.submissions[i].nickname,
'photo_url': res.data.submissions[i].photo_url,
'status': res.data.submissions[i].status,
'thumb_url': res.data.submissions[i].thumb_url,
'tiny_url': res.data.submissions[i].tiny_url,
'title': res.data.submissions[i].title,
'id': res.data.submissions[i].id
}
}
if(res.data.submissions.length > 0) {
// insert new gallery page div
$(".grid_container").append(`
<div class="row text-center" id="gallery_page_${currPage}">
</div>
`
);
}
let limit = imgsPerPage - res.data.submissions.length;
for(let i = (currPage-1)*imgsPerPage; i < (currPage*imgsPerPage - limit); i++) {
$(`#gallery_page_${currPage}`).last().append(`
<div class="col-lg-4 col-md-6">
<img class="gallery_img mt-2 lazy"
data-src="${photoInfo[i].thumb_url}"
src="./img/loadingSpinner.gif"
data-idnum="${i}"
/>
</div>
`);
}
updateLazyLoad();
setModalInfo();
}
function setModalInfo() {
// set click event listener on every element with a gallery_img tag
$(".gallery_img").click((ev) => {
// snag the idnum from the gallery img and use it to populate
// the info in the modal
let idNum = $(ev.target).data('idnum');
photoInfo[idNum].thumb_url
? $("#art_img").attr("src", photoInfo[idNum].thumb_url)
: $("#art_img").attr("src", "https://via.placeholder.com/200"); // will eventually be error img
photoInfo[idNum].title
? $("#art_title").html(`<span>Title </span><span class="font-italic">${photoInfo[idNum].title}</span>`)
: $("#art_title").html("");
photoInfo[idNum].nickname
? $("#art_submitted_by").html(`<span>Submitted by </span><span class="font-weight-bold">${photoInfo[idNum].nickname}</span>`)
: $("#art_submitted_by").html("");
photoInfo[idNum].artist
? $("#art_artist").html(`<span>Artist </span><span class="font-weight-bold">${photoInfo[idNum.artist]}</span>`)
: $("#art_artist").html("");
photoInfo[idNum].location_note
? $("#art_location_note").html(`<span>Location Note </span><span class="font-weight-bold">${photoInfo[idNum].location_note}</span>`)
: $("#art_location_note").html("");
$("#infoModal").modal('show', idNum);
});
}
$("#infoModal").on("shown.bs.modal", (e) => {
// This works to pass the idNum into the modal. I don't know why.
// It's very hackish and I'll likely replace it with something better
// later. For now, it works.
map.setTarget(null);
initMap();
updateMap(e.relatedTarget);
});
function updateMap(idNum) {
map.set("target", "mapdiv");
map.set("layers", [ new ol.layer.Tile({ source: mapSource }) ]);
map.set("view", new ol.View({
center: ol.proj.fromLonLat(
[parseFloat(photoInfo[idNum].longitude), parseFloat(photoInfo[idNum].latitude)]
),
zoom: 16}
));
let markerSVG = `<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" id="marker-15" xmlns="http://www.w3.org/2000/svg" width="15px" height="15px" viewBox="0 0 15 15">
<path id="path4133" d="M7.5,0C5.0676,0,2.2297,1.4865,2.2297,5.2703
	C2.2297,7.8378,6.2838,13.5135,7.5,15c1.0811-1.4865,5.2703-7.027,5.2703-9.7297C12.7703,1.4865,9.9324,0,7.5,0z"/>
</svg>`;
let markerStyle = new ol.style.Style({
image: new ol.style.Icon(/** @type {module:ol/style/Icon~Options} */ ({
anchor: [0.5, 0.5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
src: 'data:image/svg+xml;base64,' + btoa(markerSVG)
}))
});
let vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform(
[parseFloat(photoInfo[idNum].longitude), parseFloat(photoInfo[idNum].latitude)],
'EPSG:4326',
'EPSG:3857'))
})]
}),
style: markerStyle
});
map.addLayer(vectorLayer);
}
function initMap() {
map = new ol.Map({
target: 'mapdiv',
layers: [
new ol.layer.Tile({
source: mapSource
})
],
view: new ol.View({
center: ol.proj.fromLonLat([0, 0]),
zoom: 4
})
});
}
</script>
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
</body>
</html>