forked from lynxlynxlynx/a-day-in-the-life
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
525 lines (498 loc) · 16.3 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<html lang="en">
<head>
<title>Going back to a green future: Good practices contributing to SDGs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="description" content="Going back to a green future: Good practices contributing to SDGs">
<meta name="author" content="Jaka Kranjc">
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="product" />
<meta property="og:title" content="Going back to a green future: Good practices contributing to SDGs" />
<meta property="og:description" content="Going back to a green future is a project about learning and showcasing good practices contributing to SDGs, hereby presented on a map." />
<!-- TODO -->
<meta property="og:url" content="https://ebm.si/p/gb2gf-sdgs/" />
<!-- <meta property="og:image" content="https://lynxlynx.info/aditl/screenshot.jpg" />
<meta property="og:image:width" content="713" />
<meta property="og:image:height" content="375" /> -->
<meta property="og:site_name" content="Going back to a green future: SDG cases" />
<link href="https://fonts.googleapis.com/css?family=Chewy|Lato" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<link rel="stylesheet" href="L.Control.Window.css" />
<link href="https://unpkg.com/[email protected]/dist/MarkerCluster.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.png" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
<script src="L.Control.Window.js"></script>
<style>
body {
padding: 0;
margin: 0;
background-color: #FFE071;
font-family: 'Lato', sans-serif;
display: flex;
flex-flow: column;
}
html, body {
height: 100%;
width: 100%;
}
section {
padding: 2em;
overflow: hidden;
}
h1, nav {
font-size: 2em;
margin: 0.8em 0;
}
h1, nav a, .list-picker button {
font-family: 'Chewy', cursive;
font-weight: 100;
color: #0180FB;
/* color: HSLA(207.3, 99.8%, 68.4%, 0.8);
text-shadow: 2px 4px 6px #ffe071, 0 0 0 #000, 1px 4px 6px #ffe071;*/
text-decoration: none;
outline: none;
}
h1::selection, nav a::selection {
text-shadow: none;
background: #0180FB; /* can't only override the shadow */
color: #FFE071;
}
/* can't chain with above block — neither would work */
h1::-moz-selection, nav a::-moz-selection {
text-shadow: none;
background: #0180FB; /* can't only override the shadow */
color: #FFE071;
}
nav {
margin-left: 1em;
}
nav a:visited {
color: #0180FB;
}
nav a:hover, .list-picker button:hover {
color: #FF8871;
}
nav ul, nav li {
display: inline;
padding: 0;
}
nav ul {
display: inline-flex;
margin: 0;
justify-content: center;
flex-wrap: wrap;
}
nav li:nth-of-type(2) {
margin: 0 0.75em;
}
input {
font-size: 0.9em;
}
#introdiv {
padding: 0 2em;
overflow: hidden;
flex: 0 1 auto; /* for itself */
display: flex; /* for the kids */
justify-content: space-between;
align-items: center;
}
#maps {
padding: 0em;
flex: 1 1 auto;
}
#map1 {
height: 100%;
}
.leaflet-container {
background: #73b6e6 !important; /* fake map extension */
font-family: 'Lato', sans-serif;
}
.popup-date {
font-size: 0.8em;
margin: 0.2em 0 1em 0;
}
.popup-desc {
font-size: 0.8em;
margin: 0.2em 0 1em 0;
display: -webkit-box;
-webkit-line-clamp: 6;
-webkit-box-orient: vertical;
overflow: hidden;
}
.leaflet-popup-content-wrapper {
background-color: beige;
text-align: center;
}
.leaflet-popup-content {
font-size: 1.5em;
margin-left: auto;
margin-right: auto;
padding: 0 0.6em;
}
.leaflet-popup-content > span {
margin-bottom: 0;
display: block;
font-size: 1.17em;
font-weight: bold;
}
.control-window {
background-color: beige;
border-radius: 15px;
font-size: 1.5em;
font-family: 'Lato', sans-serif;
text-align: center;
min-width: 20em;
}
.control-window .content {
font-size: 1.2em;
padding: 0 1em 1em 1em;
}
.control-window .titlebar {
padding: 10px 45px;
}
.control-window .titlebar h2 {
margin: 0.3em 0;
}
.control-window .title {
font-family: 'Chewy', cursive;
font-weight: 100;
font-size: 2.4em;
color: #0180FB;
}
.control-window .promptButtons {
text-align: center;
padding: 0 1em 1.5em 1em;
}
.control-window .promptButtons button:nth-of-type(2) {
display: none;
}
.control-window .promptButtons button, .leaflet-popup-content-wrapper a {
font-size: 1.5em;
margin: 0;
color: beige;
background-color: #0180fb;
}
.leaflet-popup-content-wrapper a {
font-size: 0.9em; /*1.1 */
font-weight: 600;
text-decoration: none;
text-align: center;
display: block;
max-width: 9em;
margin: auto;
border-radius: 15px;
padding: 0.5em 0;
}
.cat-title {
margin-bottom: 0;
}
.listing {
display: none;
margin-bottom: 1em;
}
.listing div {
font-size: 0.7em;
}
.list-picker {
display: flex;
justify-content: space-around;
}
.list-picker button {
text-shadow: none;
opacity: 1;
font-size: 1.1em;
padding: 0;
margin: 0;
}
.list-picker button:focus, .list-picker button:active {
outline: none; /* FIXME: doesn't cut it for firefox */
}
.marker-cluster {
background-clip: padding-box;
border-radius: 12px;
}
.marker-cluster div {
width: 25px;
height: 25px;
margin-left: 7px;
margin-top: 7px;
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 27px;
}
.marker-cluster-fixed {
background-color: rgba(0, 0, 0, 0.9);
}
.marker-cluster-fixed div {
background-color: rgba(110, 204, 57, 0.9);
}
#secret1 {
margin: 0;
font-size: 80%;
color: beige;
}
#secret1:hover {
color: black;
}
form {
margin: 0;
}
input {
margin: 0.15em 0;
}
input:invalid {
background-color: pink;
}
.leaflet-control-window .close {
font-weight: bold;
width: 30px;
height: 30px;
background-color: #0180fb;
opacity: 0.5;
}
.leaflet-control-window .close:hover {
background-color: #0180fb;
opacity: 1;
}
@media (max-width: 600px) {
h1, nav {
font-size: 1.5em;
}
.control-window, .leaflet-popup-content {
font-size: 1.2em;
}
}
</style>
</head>
<body>
<section id="introdiv">
<h1><a href="https://www.facebook.com/Going-Back-to-Green-Future-538200113764297" rel="noopener" target="_blank">Going back to a green future</a></h1>
<nav>
<ul>
<li><a href="" id="cats">Categories</a></li>
<!-- <li><a href="" id="submit">Submit</a></li> -->
<li><a href="" id="about">About</a></li>
</ul>
</nav>
</section>
<section id="maps">
<div id="map1"></div>
</section>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise,fetch"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.markercluster.js"></script>
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
<script>
/* TODO */
var MAPBOX_KEY = "CHANGEME";
var maxZoom = 12;
var map = L.map('map1').setView([45.0, 15], 4);
L.tileLayer(/*'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}'*/'https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: maxZoom,
id: 'mapbox.streets',
accessToken: MAPBOX_KEY
}).addTo(map);
function generateDescription(feature, layer) {
feature.properties.popupContent = `
<span aria-label="Place name">${feature.properties.name} (${feature.properties.country})</span>
<div>
<div class="popup-date">Level: ${feature.properties.level}</div>
<div class="popup-date">SDG goals: ${feature.properties.goals}</div>
<div class="popup-desc">${feature.properties.desc}</div>
<a href="${feature.properties.url}" target="_blank" rel="noopener">Learn more</a>
</div>`;
}
// customize marker to the imgur logo look-alike (needs to be pointy)
// eh, can't just swap the pic in the default for some reason
var imgurMarker = L.icon({
iconUrl: 'marker-icon.png',
iconAnchor: [12, 41],
iconRetinaUrl: "marker-icon-2x.png",
iconSize: [25, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
shadowUrl: "marker-shadow.png",
tooltipAnchor: [16, -28]
});
var markers = L.markerClusterGroup({
showCoverageOnHover: false,
maxClusterRadius: 50, // default: 80; check Bermuda is still spidered when changing
iconCreateFunction: function(cluster) {
return new L.divIcon({
html: '<div><span>' + cluster.getChildCount() + '</span></div>',
className: 'marker-cluster marker-cluster-fixed',
iconSize: new L.Point(40, 40)
});
}
});
var geojsonFeatures;
var geojsonLayer;
fetch('stories.geojson')
.then(response => response.json())
.then(json => geojsonFeatures = json.features)
.then(() => {
geojsonLayer = L.geoJSON(geojsonFeatures, {
onEachFeature: (feature, layer) => {
generateDescription(feature, layer);
layer.bindPopup(feature.properties.popupContent, { maxWidth: 650 });
},
pointToLayer: function(feature, latlng) {
return L.marker(latlng, { icon: imgurMarker });
}
});
})
.then(() => {
markers.addLayer(geojsonLayer);
map.addLayer(markers);
})
.then(populateLists)
.then(generateTables)
.then(createListing)
.then(addAboutModal);
// add a map popup with a GREETING
var greetingWin = L.control.window(map, {
title: 'Welcome!',
prompt: { buttonOK: 'Explore!', buttonCancel: '' },
content: 'Here you can find good practice examples of moving towards the Sustainable development goals (SDGs). This subset was identified in the <em>Going back to a green future</em> project.',
modal: true,
position: 'top',
closeButton: false,
maxWidth: "30em",
});
greetingWin.show();
function registerClickHandler(id, modal) {
var el = document.getElementById(id);
L.DomEvent.on(el, "click", (ev) => {
L.DomEvent.preventDefault(ev);
modal.show();
});
}
// separated into a function only to be able to access the count
function addAboutModal() {
var aboutWin = L.control.window(map, {
title: 'About',
prompt: { buttonOK: 'Explore!', buttonCancel: '' },
content: `<p style="margin-top: 0;"><em>Going back to a green future</em> is a simple web map application to display the results of the namesake project (${geojsonFeatures.length} cases).<br><img alt="Erasmus+ logo" src="logo.png" style="margin:1em">
<h3>About the project</h3>
<p>
The project »Going back to green future (On toure)« addresses an issue which is in increasing demand and relevance among all European communities: climate change (CC) mitigation. In recent years, adult education institutions (AEI) in different ways aim to enable their learners to act sustainable. With a little more in-depth insight into the work of AEI staff, we discover how nearly all areas of their work are to some extent intertwined with CC mitigation or, in other words, reaching sustainable development (SD) goals. Desktop researches, AEI staff conferences' conclusions, a number of projects that deal with SD topics show that AEI themselves stay without proper guidelines as to how to set an example of SD organisation in order to really tackle CC challenge holistically and systematically. </p>
<p>
The project will by exchange of good practices among 7 partners from 6 countries explore the possibility of establishing »an across Europe guidelines« for SD self-evaluation system and incorporation of SD goals in AEI.</p>
<p>
The »Going back to green future« project will:
<ul>
<li>extend and develop adult education institutions staff's competences in the field of climate change mitigation in a broad sense;</li>
<li>improve the capacity of adult learning institutions and organisations to incorporate sustainable development goals in their strategies, plans and, most importantly, in their everyday life and work;</li>
<li>create opportunities for adult learners to become more environmentally responsible citizens in different European countries.</li>
</ul>
The results of the project will be useful for all organisations active in adult education across Europe and they have the potential to be transferred and exploited in other European and other countries of the world. Long-term project's purpose is to increase the involvement of CC mitigation in the formulation of AEI policies/plans and to our daily behaviour.
</p>
<p>
For these reasons – follow us on <a href="https://www.facebook.com/Going-Back-to-Green-Future-538200113764297" rel="noopener" target="_blank">Facebook</a> and <a href="https://back2greenfuture.blogspot.com" rel="noopener" target="_blank">our blog</a>!
</p>
<br><i style="font-size:0.7em">This programme has been funded with support from the European Commission.
The author is solely responsible for this publication (communication) and the Commission accepts no responsibility for any use that may be made of the information contained therein.</i><br><img alt="Erasmus+ logo" src="https://ebm.si/p/zwcities-calc/eu_flag_co_funded_pos_rgb_left-200px.jpg" style="margin:1em">
</p>`,
modal: true,
position: 'top',
closeButton: true,
});
registerClickHandler("about", aboutWin);
}
// pre-construct search lists
var lists = [[], [], []];
function populateLists() {
for (var i=0; i<geojsonFeatures.length; i++) {
var feature = geojsonFeatures[i];
var url = feature.properties.url;
var name = feature.properties.name;
var country = feature.properties.country;
var goals = feature.properties.goals;
var level = feature.properties.level;
var values = [goals, country, level];
var entry = { name: name, url: url };
for (var l=0; l<lists.length; l++) {
list = lists[l];
val = values[l];
if (l == 0) { // special case goals — explode them, copying the entries
goalArray = goals.split(",");
for (var j=0; j < goalArray.length; j++) {
val = goalArray[j].trim();
sdgUrl = "https://sdgs.un.org/goals/goal" + val;
if (val.length == 1) val = "0" + val;
imgUrl = "sdg-icons/SDG_Icons_Inverted_Transparent_WEB-" + val + ".png";
// construct the html so the lexical sorting can emulate number sorting
val = "<a alt='goal" + val + "' href='" + sdgUrl + "' rel='noopener' target='_blank'><img src='" + imgUrl + "'></a>";
var filtered = list.filter(v => v[0] == val);
var idx = list.indexOf(filtered[0]);
if (idx == -1) {
list.push([val, [entry]]);
} else {
list[idx][1].push(entry);
}
}
} else {
var filtered = list.filter(v => v[0] == val);
var idx = list.indexOf(filtered[0]);
if (idx == -1) {
list.push([val, [entry]]);
} else {
list[idx][1].push(entry);
}
}
}
}
}
// sort and generate html
var tables = [ "", "", "" ];
function generateTables() {
function loCaseSorter(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
}
function generateItem(item) {
return `<a href="${item.url}" target="_blank" rel="noopener">${item.name}</a><br/>`;
}
for(var l=0; l<lists.length; l++) {
lists[l].sort((a,b) => loCaseSorter(a[0], b[0]));
for (var j=0; j<lists[l].length; j++) {
lists[l][j][1].sort((a,b) => loCaseSorter(a.name, b.name));
var listing = lists[l][j][1].reduce((a, v) => a + generateItem(v), "");
tables[l] += `<h4 class="cat-title">${lists[l][j][0]}</h4><div>${listing}</div>`;
}
}
}
function createListing() {
var listingWin = L.control.window(map, {
title: 'Categories',
prompt: { buttonOK: 'Explore!', buttonCancel: '' },
content: `<div class="list-picker">
<button onclick="toggleListing(2)">Goals</button>
<button onclick="toggleListing(3)">Country</button>
<button onclick="toggleListing(4)">Level</button>
</div>
<div class="listing" style="display: block">${tables[0]}</div>
<div class="listing">${tables[1]}</div>
<div class="listing">${tables[2]}</div>`,
modal: true,
position: 'top',
closeButton: true,
});
registerClickHandler("cats", listingWin);
}
function toggleListing(idx) {
var enable = document.querySelector(`.listing:nth-of-type(${idx})`);
if (enable.style.display == "block") return;
enable.style.display = "block";
// for some reason the first element is always null
var disableIdx = [2, 3, 4].filter(v => v != idx);
for (var i=0; i<disableIdx.length; i++) {
var disable = document.querySelector(`.listing:nth-of-type(${disableIdx[i]})`);
disable.style.display = "none";
}
}
</script>
</body>
</html>