forked from ModelEarth/localsite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
334 lines (277 loc) · 12.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
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html;">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<title>LocalSite - Player</title>
<link type="text/css" rel="stylesheet" href="/localsite/css/base.css" id="/localsite/css/base.css" />
<script type="text/javascript" src="/localsite/js/d3.v5.min.js" id="/localsite/js/d3.v5.min.js"></script>
<script type="text/javascript" src="/localsite/js/jquery.min.js" id="/localsite/js/jquery.min.js"></script>
<script type="text/javascript" src="/localsite/js/showdown.min.js" id="/localsite/js/showdown.min.js"></script>
<script type="text/javascript" src="/localsite/js/localsite.js?showheader=true&showsearch=true"></script>
<script>
//param.startTitle = "Neighborhood.org"
//param.titleArray = ["local","site"] // The header title will default to Neighborhood when no titleArray.
param.footer = "footer.html"
</script>
</head>
<body>
<!-- Swiper and Plyr -->
<style>
.optionalText {
display: none;
position:absolute;
bottom:-30px;
}
</style>
<!--
Coolness: Responds to keyboard arrows and swipes.
To DO:
Make buttons visible when rolling over sides, expand click area to entire side.
Sample in a circle
http://localhost:8887/community/tools/
To do: can swiper-lazy be replaced with existing lazy?
Notes:
Width:100% currently has to be included on the a href tag to prevent margins if image width is exceeded.
Set the height:100% on div within swiper-slide
text-align:left; overflow:scroll;
-->
<!-- update
<link rel="stylesheet" href="/localsite/css/swiper/swiper-bundle.min.css" />
-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css">
<link rel='stylesheet' href='/localsite/css/swiper/plyr.css'>
<link rel='stylesheet' href='/localsite/css/swiper/swiper.css'>
<script src='/localsite/js/polyfill.min.js?features=es6,Array.prototype.includes,CustomEvent,Object.entries,Object.values,URL'></script>
<script src='/localsite/js/plyr.min.js'></script>
<!-- data-id="sample1" -->
<div class="swiper-container" style="overflow:hidden;" id="sample1">
<div class="swiper-wrapper">
<!-- Slide 1 -->
<div class="swiper-slide" data-hash="plant">
<img class="swiper-lazy" data-src="/localsite/img/hero/plant.png" style="opacity:0.9;width:100%;max-width:2000px">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
<div class="optionalText content contentpadding" style="displayX:none;position:absolute; bottom:-30px">
Add Optional Text 1
</div>
</div>
<!-- Slide 2 -->
<div class="swiper-slide" data-hash="2to1-ratio">
<img class="swiper-lazy" data-src="/localsite/img/hero/2to1-ratio.png" style="opacity:0.9;width:100%;max-width:2000px">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
<div class="optionalText content contentpadding" style="displayX:none;position:absolute; bottom:-30px">
Add Optional Text 2
</div>
</div>
<!-- Slide 3 -->
<div class="swiper-slide" data-hash="sun">
<!-- Example of smaller: solar-rect-sm.png -->
<img class="swiper-lazy swiper-blur" data-src="/localsite/img/hero/solar-rect.png" style="width:100%;max-width:2000px;"><img class="swiper-lazy" data-src="/localsite/img/hero/solar-rect.png" style="opacity:0.9;max-width:2000px;">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white" style="position: relative; border: 10px solid red;"></div>
<div class="optionalText content contentpadding" style="displayX:none;position:absolute; bottom:-30px">
Add Optional Text 3
</div>
</div>
<!-- Slide 4: A Walkable Street -->
<div class="swiper-slide" data-hash="communities" style="positionX: relative;">
<img class="swiper-lazy swiper-blur" data-src="/localsite/img/hero/sustainable-communities.jpg" style="width:100%;max-width:2000px;">
<img class="swiper-lazy" data-src="/localsite/img/hero/sustainable-communities.jpg" style="opacity:0.9;width:100%;max-width:3000px">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
<div class="box" style="display:none">
<!--div class="title">Title</div-->
<!--
<div class="subtitle" data-swiper-parallax="-200">Graphics project</div>
-->
</div>
</div>
<!-- Slide 5 -->
<div class="swiper-slide" data-hash="explore">
<img class="swiper-lazy" data-src="/localsite/img/hero/future-teepee.png" style="opacity:0.9;width:100%;max-width:2000px;height:740px">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
<div class="optionalText content contentpadding">
Add Optional Text 5
</div>
</div>
</div>
<!-- Swiper Nav -->
<div class="swiper-button-prev swiper-button-prev-sample1">
<!--<div class="swiper-button-white"></div>-->
</div>
<div class="swiper-button-play swiper-button-play-sample1"></div>
<!-- e034 -->
<div class="swiper-button-pause swiper-button-pause-sample1"></div>
<div class="swiper-button-next swiper-button-next-sample1">
<!--<div class="swiper-button-white"></div>-->
</div>
<!-- /Swiper Nav-->
</div>
<!-- Swiper Pagination -->
<div class="swiper-pagination swiper-pagination-sample1" style="margin-top:15px;"></div>
<!-- /Swiper Pagination -->
<!--
To avoid 404 warning in inspector:
Downloaded and renamed swiper.min.js.map to swiper-bundle.min.js.map
Haven't yet confirmed that's the correct file to use, but reolved 404 error.
-->
<script src="/localsite/js/swiper/swiper-bundle.min.js"></script>
<!--
<script src="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.js"></script>
-->
<!-- Initialize Swiper -->
<script>
// Init multiple slider on a single page
// https://stackoverflow.com/questions/32118999/how-can-i-have-multiple-swiper-slideshows-on-a-single-page
// Function that builds the swiper
const buildSwiperSlider = sliderElm => {
const sliderIdentifier = sliderElm.id;
const homeSwiper = new Swiper(`#${sliderElm.id}`, {
slidesPerView: 1,
spaceBetween: 30,
loop: true,
speed: 2500, /* transition */
slidesPerView: 'auto',
lazy: {
loadPrevNext: true,
},
navigation: {
nextEl: '.swiper-button-next-' + sliderIdentifier,
prevEl: '.swiper-button-prev-' + sliderIdentifier
},
pagination: {
el: '.swiper-pagination-' + sliderIdentifier,
clickable: true,
},
effect: 'fade',
/* change hash value (and load based on hash) -- problem: overwrites other hash values */
/*
hashNavigation: {
watchState: true,
},
*/
keyboard: {
enabled: true,
onlyInViewport: false
},
direction: 'horizontal',
/*
history: {
keepQuery: true
},
*/
});
$(".swiper-button-pause-" + sliderIdentifier).click(function(){
$(".swiper-button-pause-" + sliderIdentifier).hide();
$(".swiper-button-play-" + sliderIdentifier).show();
$(".swiper-button-pause-" + sliderIdentifier).addClass("overrideShowPauseQuick");
homeSwiper.autoplay.stop(); // Tiggers icon change below at autoplayStop event
});
$(".swiper-button-play-" + sliderIdentifier).click(function(){
homeSwiper.slideNext(); // Immidiately advance to next on click.
$(".swiper-button-play-" + sliderIdentifier).hide();
$(".swiper-button-pause-" + sliderIdentifier).show();
homeSwiper.autoplay.start();
});
$(".swiper-pagination-" + sliderIdentifier + " .swiper-pagination-bullet").click(function(){
$(".swiper-button-pause-" + sliderIdentifier).hide();
$(".swiper-button-play-" + sliderIdentifier).show();
});
$(".swiper-button-prev-" + sliderIdentifier).click(function(){
$(".swiper-button-pause-" + sliderIdentifier).hide();
$(".swiper-button-play-" + sliderIdentifier).show();
});
$(".swiper-button-next-" + sliderIdentifier).click(function(){
$(".swiper-button-pause-" + sliderIdentifier).hide();
$(".swiper-button-play-" + sliderIdentifier).show();
});
homeSwiper.on('autoplayStart', function () {
//$(".swiper-pagination-bullet-active").css("background","green");
$('head').append('<style id="customCSS">.swiper-pagination-bullet-active { background:green !important }</style>');
});
// Triggered by keyboard arrow keys and pause button:
homeSwiper.on('autoplayStop', function () {
//$(".swiper-pagination-bullet-active").css("background","#888");
$('#customCSS').remove();
// Briefly show the pause button
$(".swiper-button-pause-" + sliderIdentifier).show();
$(".swiper-button-pause-" + sliderIdentifier).addClass("showPauseQuick");
//alert("stop")
setTimeout(() => {
$(".swiper-button-pause-" + sliderIdentifier).hide();
$(".swiper-button-pause-" + sliderIdentifier).removeClass("showPauseQuick"); // to do: figure out why not fading
$(".swiper-button-pause-" + sliderIdentifier).removeClass("overrideShowPauseQuick"); // Allows pause not to be retained briefly when clicking actual pause button.
},1000);
$(".swiper-button-play-" + sliderIdentifier).show();
});
// Play on iniital load
$(".swiper-button-play-" + sliderIdentifier).hide();
$(".swiper-button-pause-" + sliderIdentifier).show();
homeSwiper.autoplay.start();
//return homeSwiper;
}
// Get all of the swipers on the page
const allSliders = document.querySelectorAll('.swiper-container');
// Loop over all of the fetched sliders and apply Swiper on each one.
allSliders.forEach(slider => buildSwiperSlider(slider));
$(".swiper-button-play").show();
//$(".swiper-button-play").css('opacity', '0.8');
</script>
<!-- /Initialize Swiper -->
<!-- /Swiper and Plyr -->
<div class="content contentpadding" style="padding-top: 0px">
<div style="float:right">
<!--
<a href="https://github.com/localsite/planning/blob/main/schema.prisma">Real World 2.0 Data Structure</a> - Common tables for civic tech apps
-->
<!--
<a href="https://nextjs.org">NextJS</a>, <a href="https://www.prisma.io">Prisma</a> and <a href="https://blitzjs.com">BlitzJS</a><br><br>
-->
</div>
<h1 style="padding-top: 0px">LocalSite - Player</h1>
<!--
Swiper demos:
https://swiperjs.com/demos
Also parallax:
https://codesandbox.io/s/empty-feather-sqgrj?file=/src/App.js
-->
Localsite uses <a href="https://swiperjs.com/">SwiperJS</a> with the MapBox <a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/">Layers JSON Format</a> to manage multiple map layers in our <a href="js/map.js">map.js styleObject</a>.
<section id="parameters">
<div id="paramsDiv" style="clear:both"></div>
</section>
<div class="two pageColumns">
<div class="pageColumn">
<div class="pageColumnInside">
<div id="readmeDiv"></div>
</div>
</div>
<div class="pageColumn">
<div class="pageColumnInside">
<div id="featuresDiv"></div>
</div>
</div>
</div>
<h2 style="clear:both">Local Storage</h2>
The following values reside in your browser's localStorage for persistance across site visits:<br><br>
<div id="displayStorage"></div>
<script>
// View localStorage values
for(var i=0, len=localStorage.length; i<len; i++) {
var key = localStorage.key(i);
var value = localStorage[key];
if (value.indexOf("<svg") > 0) {
$("#displayStorage").append("<b>" + key + ":</b> [svg]<br><br>");
} else {
$("#displayStorage").append("<b>" + key + ":</b> " + value + "<br><br>");
}
}
</script>
</div>
<script>
loadMarkdown("README.md", "readmeDiv", "_parent");
loadMarkdown("start/features.md", "featuresDiv", "_parent");
loadMarkdown("start/params.md", "paramsDiv", "_parent");
</script>
<div id="footer"></div>
</body>
</html>