-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
626 lines (610 loc) · 20.7 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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<meta
name="description"
content="Are Images Real? - A tour of visual manipulation from darkroom to AI"
/>
<title>
Are Images Real? - A tour of visual manipulation from darkroom to AI
</title>
<link rel="icon" href="favicon.png" />
<link rel="stylesheet" href="style.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<script src="grid.js"></script>
<script src="utils.js"></script>
<script>
let controller;
const eventScenes = {};
const eraScenes = {};
let yearRange = [];
const gridSize = 32;
function currentPage() {
return location.hash.substr(1) || "home";
}
function setPage(newPage) {
if (newPage) {
location.hash = newPage;
} else {
newPage = currentPage();
}
const classes = document.getElementsByTagName("body")[0].classList;
classes.remove(
Array.from(classes).filter((c) => c.startsWith("page-"))
);
classes.add(`page-${newPage}`);
scrollTo(0, 0);
gridify(false, gridSize);
}
function setEraDurations() {
for (era in eraScenes) {
el = elementFromEra(era);
eraScenes[era].duration(el.clientHeight + gridSize * 3);
}
}
function erasToTimelineHeights(eras) {
return eras.map((e) => [
yearToPct(e.first_year),
yearToPct(e.last_year),
]);
}
function jumpToEvent(event) {
/* Move a little beyond the top of the scene because
otherwise the "enter" event doesn't fire.*/
controller.scrollTo(eventScenes[event.id].scrollOffset() + 40);
}
function elementFromEvent(event) {
return document.getElementById(`event${event.id}`);
}
function elementFromEra(era) {
return document.getElementById(`era${era}`);
}
function yearToPct(year) {
year = parseInt(year);
if (year === yearRange[1]) {
return 1.0;
}
return (year - yearRange[0]) / (yearRange[1] - yearRange[0]);
}
function setEraActive(era) {
const classes = document.getElementById("container").classList;
classes.remove(
Array.from(classes).filter((c) => c.startsWith("activeEra"))
);
classes.add(`activeEra${era}`);
}
function jumpToEra(era) {
if (currentPage() === "timeline") {
controller.scrollTo(eraScenes[era].scrollOffset() + 10);
} else {
/* The whole thing rerenders when the page changes,
and we want to wait for that to happen before we scroll.
This does that.*/
eraScenes[era].on("shift", () => {
controller.scrollTo(eraScenes[era].scrollOffset() + 10);
eraScenes[era].off("shift");
});
setPage("timeline");
}
setEraActive(era);
}
function setupEraScrolling(era, onEnter, onLeave) {
const el = document.getElementById(`era${era.era}`);
scene = new ScrollMagic.Scene({
triggerElement: el,
offset: -20,
triggerHook: 0.1,
});
eraScenes[era.era] = scene;
scene
//.addIndicators()
.on("enter", () => {
if (window.scrollY > 0 && el.clientHeight > 0) {
onEnter(era, el);
}
})
.on("leave", onLeave)
.addTo(controller);
}
function setupEventScrolling(event, onEnter, onLeave) {
const el = elementFromEvent(event);
const scene = new ScrollMagic.Scene({
triggerElement: el,
offset: -20,
triggerHook: 0.25,
});
eventScenes[event.id] = scene;
scene
//.addIndicators()
.on("enter", () => {
if (window.scrollY > 0 && el.clientHeight > 0) {
onEnter(event, el);
}
})
.on("leave", onLeave)
.addTo(controller);
}
function onLoad() {
document.querySelector("body").classList.remove("loading");
gridify(false, gridSize);
}
</script>
</head>
<body class="page-home loading" v-scope @vue:mounted="onLoad">
<div id="loading">...</div>
<header id="topBar">
<a href="#about" id="link-about"> /about </a>
<a id="link-home" href="#home" aria-label="home">
<svg
version="1.1"
id="home"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 700 700"
width="32"
height="32"
aria-hidden="true"
style="enable-background: new 0 0 700 700"
xml:space="preserve"
>
<style type="text/css">
.st0 {
fill-rule: evenodd;
clip-rule: evenodd;
}
</style>
<path
class="st0"
d="M626.4,341.3l-269-241.2c-4.2-3.7-10.5-3.7-14.7,0l-269,241.2c-3.4,3-4.6,7.9-2.9,12.1
c1.6,4.2,5.7,7.1,10.3,7.1h58.6v231.3c0,6.1,4.9,11,11,11h134.2c6.1,0,11-4.9,11-11V423.9h108.5v167.8c0,6.1,4.9,11,11,11h134.2
c6.1,0,11-4.9,11-11V360.4H619c4.6,0,8.6-2.8,10.3-7.1S629.7,344.3,626.4,341.3"
/>
</svg>
<svg
version="1.1"
id="homeHover"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 700 700"
style="enable-background: new 0 0 700 700"
xml:space="preserve"
width="32"
height="32"
aria-hidden="true"
>
<style type="text/css">
.st0 {
fill-rule: evenodd;
clip-rule: evenodd;
}
.st1 {
fill: #f3affc;
}
</style>
<path
class="st0"
d="M626.4,341.3l-269-241.2c-4.2-3.7-10.5-3.7-14.7,0l-269,241.2c-3.4,3-4.6,7.9-2.9,12.1
c1.6,4.2,5.7,7.1,10.3,7.1h58.6v231.3c0,6.1,4.9,11,11,11h134.2c6.1,0,11-4.9,11-11V423.9h108.5v167.8c0,6.1,4.9,11,11,11h134.2
c6.1,0,11-4.9,11-11V360.4H619c4.6,0,8.6-2.8,10.3-7.1S629.7,344.3,626.4,341.3"
/>
<path
class="st1"
d="M306.1,328.3c16.6-5.3,34.4,3.8,39.8,20.4c5.3,16.6-3.8,34.4-20.4,39.7c-16.6,5.3-34.4-3.8-39.8-20.4
C280.3,351.5,289.5,333.7,306.1,328.3"
/>
<path class="st1" d="M386.7,503.4l5-3" />
<path
class="st1"
d="M404.2,430.9L404.2,430.9l-20.6-33.2c3.3,0.9,7.5,2.8,12.8,6.6c10.1,7.3,23.8,21.8,40,48.8
c2.3,3.8,4.6,7.8,6.9,12c3,5.4,9.8,7.4,15.3,4.4c0.1-0.1,0.2-0.1,0.3-0.2c5.2-3.1,7-9.8,4-15.1c-2.5-4.5-4.9-8.7-7.3-12.7
c-23-38.2-42.4-55.6-59.2-63c-8.3-3.6-16-4.5-22-3.9c-6.1,0.6-10.5,2.7-13,4.2c0,0-0.1,0.1-0.1,0.1c-0.5,0.2-0.9,0.4-1.3,0.7
l-44.4,26.6c-0.9,0.2-2.9,0.5-6,0.6c-6.1,0.1-15.9-1-27.7-7.6c-11.8-6.6-25.8-18.8-39.7-41.9c-1.3-2.2-2.7-4.6-4-7
c-3-5.4-9.8-7.5-15.2-4.5c-5.4,3-7.5,9.8-4.5,15.2c1.5,2.7,3,5.3,4.5,7.8c21.3,35.6,45.4,51.4,64.8,57.2c10.8,3.3,19.9,3.5,26.1,3
l0,0l90.3,104"
/>
</svg>
</a>
<button id="link-menu" @click="state.toggleMobileMenu">menu</button>
</header>
<div id="container" :class="`activeEra${state.currentEra}`">
<div id="eraMenu" style="display: none">
<a
href="#timeline"
v-for="era in eras"
:class="`${era.color}Backed`"
@click.prevent="jumpToEra(era.era)"
>
{{era.first_year}} – {{era.last_year}}:<br />
{{era.slug}}
</a>
</div>
<main id="page-about">
<div class="title orangeBacked box" v-html="s.about_title"></div>
<div id="aboutContent" class="box yellowBacked" v-html="s.about"></div>
<div class="gridded background"></div>
</main>
<main id="page-timeline">
<div id="mobile">
<div id="mobileMenu" v-show="state.mobileMenuVisible">
<a
href="#timeline"
v-for="era in eras"
:class="`${era.color}Backed`"
@click.prevent="jumpToEra(era.era); state.toggleMobileMenu()"
>
{{era.first_year}} – {{era.last_year}}: {{era.slug}}
</a>
</div>
<div
id="mobileContext"
v-show="!!state.currentEvent.year && !state.mobileMenuVisible"
>
{{state.currentEvent.year}}
<span v-for="tag in state.currentEvent.tags" class="tagIcon"
>{{tag.icon}}</span
>
</div>
</div>
<div id="fixedContent">
<div id="eraTimeline">
<div
v-for="era in eras"
:class="['box', `${era.color}Backed`]"
id="`era${era.era}Box`"
:style="{height: `${era.height * 100}%`}"
></div>
<div id="firstLabel">{{eras[0].first_year}}</div>
<div id="lastLabel">{{eras[eras.length - 1].last_year}}</div>
<div
id="year"
class="box"
:style="{
top: `clamp(0vh, calc(${
yearToPct(state.currentEvent.year) * 100
}vh - 1.5rem), calc(100vh - 4rem))`}"
>
{{state.currentEvent.year}}
</div>
</div>
<nav id="nav">
<div id="context">
<div id="legend" class="box">
<button
v-for="tag in tags"
:class="['tag', 'box', {selected: state.selectedTags.includes(tag.tag) }]"
@click="state.toggleTag(tag.tag)"
tabindex="0"
>
<span class="tagIcon">{{tag.icon}}</span>{{tag.name}}
</button>
</div>
</div>
<div
v-for="era in eras"
:id="`era${era.era}Nav`"
:class="['imageContainer','box',`${era.color}Backed`]"
>
<div class="imageGrid box">
<div class="eraName">{{era.slug}}</div>
<button
v-for="(event, i) in eraEvents(era.era)"
:class="['imageThumb', { showing: event.id === state.currentEvent.id}]"
:id="`thumb-event${event.id}`"
:aria-label="`Jump to ${event.title}`"
tabindex="0"
@click="jumpToEvent(event)"
@keyup.enter="jumpToEvent(event)"
@mouseenter="state.setHoveredEvent(event)"
@mouseleave="state.setHoveredEvent({})"
>
<img
:src="event.image_url"
:class="{hidden: !hasSelectedTag(event)}"
:alt="event.title"
/>
</button>
</div>
</div>
</nav>
</div>
<div id="timeline" class="box">
<div id="border"></div>
<div id="events">
<div
v-for="era in eras"
class="era"
:id="`era${era.era}`"
@vue:mounted="setupEra(era)"
>
<h4>PART {{era.era}}</h4>
<h3>{{era.title}}</h3>
<ol>
<li
v-for="event in eraEvents(era.era)"
:id="`event${event.id}`"
:class="['event']"
@vue:mounted="setupEvent(event)"
>
<div class="eventData">
<div class="eventTitle">
{{event.year}} – {{event.title}}
<span v-for="tag in event.tags" class="tagIcon"
>{{tag.icon}}</span
>
</div>
<button
class="eventImage"
tabindex="0"
@click="state.setSelectedImage(event.image_url)"
@keyup.enter="state.setSelectedImage(event.image_url)"
>
<img :src="event.image_url" :alt="event.title" />
</button>
<p class="eventText" v-html="event.text"></p>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="gridded background"></div>
<button
id="link-eraTop"
class="box"
v-show="!!state.currentEvent.year"
@click.prevent="jumpToEra(state.currentEvent.era)"
@keyup.enter="jumpToEra(state.currentEvent.era)"
title="Jump to top of era"
>
<svg aria-hidden="true">
<defs>
<marker
id="head"
orient="auto"
markerWidth="3"
markerHeight="4"
refX="0.1"
refY="2"
>
<path d="M0,0 V4 L3,2 Z" fill="black" />
</marker>
</defs>
<path
id="arrow-line"
marker-end="url(#head)"
fill="none"
stroke="black"
stroke-width="3"
d="M18,30, 18 14"
></path>
</svg>
</button>
</main>
<main id="page-home">
<div class="gridded background"></div>
<div class="box" id="hTitle">
<h1>{{s.title}}</h1>
</div>
<div class="box" id="hSubtitle">
<h2>{{s.subtitle}}</h2>
</div>
<div class="box" id="hEnticement">
<p v-html="s.enticement"></p>
</div>
<div id="hButtons">
<div class="box hButton" id="introPointer">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 96 960 960"
height="26"
width="26"
aria-hidden
>
<path
d="m561 814-43-42 168-168H60v-60h626L517 375l43-42 241 241-240 240Z"
></path>
</svg>
Introduction
</div>
<a href="#timeline" class="box hButton" id="jumpToTimeline">
Jump to timeline
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 96 960 960"
height="26"
width="26"
aria-hidden
>
<path
d="m561 814-43-42 168-168H60v-60h626L517 375l43-42 241 241-240 240Z"
></path>
</svg>
</a>
</div>
<div class="box" id="hOverview" v-html="s.overview"></div>
<div class="box" id="hExample">
<img :src="s.example_img" :alt="s.example_img_alt" />
<p>{{s.example}}</p>
</div>
<a
href="#timeline"
id="startTimeline"
class="box"
title="Jump to timeline"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 96 960 960"
height="26"
width="26"
aria-hidden="true"
>
<path
d="m702 755-43-42 106-106H60v-60h706L660 441l42-42 178 178-178 178Z"
/>
</svg>
</a>
</main>
<div
id="lightbox"
v-show="Object.keys(state.selectedImage).length > 0"
@click="state.setSelectedImage(null)"
@keyup.enter="state.setSelectedImage(null)"
>
<img v-if="!!state.selectedImage.src" :src="state.selectedImage.src" />
<button
id="lightboxClose"
@click="state.setSelectedImage(null)"
tabindex="0"
@keyup.enter="state.setSelectedImage(null)"
>
Close
</button>
</div>
<div
id="bigYear"
v-text="state.hoveredEvent.year"
:class="{ hidden: !state.hoveredEvent || state.hoveredEvent.id === state.currentEvent.id }"
></div>
</div>
<script type="module">
import { createApp, reactive } from "https://unpkg.com/petite-vue?module";
const state = reactive({
currentEra: "1",
setCurrentEra: function (era) {
this.currentEra = era;
},
currentEvent: {},
setCurrentEvent: function (event) {
this.currentEvent = event;
},
hoveredEvent: {},
setHoveredEvent: function (event) {
this.hoveredEvent = event;
},
selectedTags: [],
toggleTag: function (tag) {
// Vue can't handle Sets as state, so convert to object and back.
let tags = new Set(this.selectedTags);
if (tags.has(tag)) {
tags.delete(tag);
} else {
tags.add(tag);
}
this.selectedTags = Array.from(tags.values());
},
hovering: false,
toggleHovering: function () {
this.hovering = !this.hovering;
},
selectedImage: {},
setSelectedImage: function (url) {
if (url === null) {
this.selectedImage = {};
} else {
this.selectedImage = { src: url };
document.getElementById("lightboxClose").focus();
}
},
mobileMenuVisible: false,
toggleMobileMenu: function () {
this.mobileMenuVisible = !this.mobileMenuVisible;
},
});
function populateApp(timeline, eras, tags, strings) {
eras = parseCSVtoObjects(eras);
yearRange = [
parseInt(eras[0].first_year),
parseInt(eras[eras.length - 1].last_year),
];
const heights = erasToTimelineHeights(eras);
let heightSoFar = 0;
eras.forEach((e, i) => {
e.height = heights[i][1] - heightSoFar;
heightSoFar = heights[i][1];
});
tags = parseCSVtoObjects(tags);
let events = parseCSVtoObjects(timeline).map((e, i) => {
e.id = i;
e.tags = tags.filter((t) => e[t.tag] === "1");
return e;
});
strings = Object.fromEntries(
parseCSVtoObjects(strings).map((r) => [r.name, r.text])
);
console.log(events);
console.log(eras);
console.log(tags);
controller = new ScrollMagic.Controller({});
createApp({
state: state,
events: events,
eras: eras,
tags: tags,
s: strings,
eraEvents(i) {
return this.events.filter((e) => e.era === i);
},
setupEvent(event) {
setupEventScrolling(event, this.activateEvent);
},
activateEvent(event, el) {
this.state.setCurrentEvent(event);
this.state.setCurrentEra(event.era);
/* Sometimes this event runs even though the events are hidden.
Just don't do that. */
eventScenes[event.id].duration(el.clientHeight + gridSize * 3);
},
setupEra(era) {
setupEraScrolling(era, this.activateEra);
},
activateEra(era, el) {
this.state.setCurrentEra(era.era);
eraScenes[era.era].duration(el.clientHeight + gridSize * 3);
},
hasSelectedTag(event) {
if (this.state.selectedTags.length === 0) {
return true;
}
tags = new Set(this.state.selectedTags);
return !!event.tags.find((t) => tags.has(t.tag));
},
}).mount();
addEventListener("hashchange", () => setPage());
setPage();
}
const timelineURL =
"https://docs.google.com/spreadsheets/d/1fpHxE_ketMRAzXCKKmMwXxHpvdlT8GNdPWeugIUZ0D0/gviz/tq?tqx=out:csv";
const erasURL =
"https://docs.google.com/spreadsheets/d/1fpHxE_ketMRAzXCKKmMwXxHpvdlT8GNdPWeugIUZ0D0/gviz/tq?gid=1115017889&tqx=out:csv";
const tagsURL =
"https://docs.google.com/spreadsheets/d/1fpHxE_ketMRAzXCKKmMwXxHpvdlT8GNdPWeugIUZ0D0/gviz/tq?gid=359238604&tqx=out:csv";
const stringsURL =
"https://docs.google.com/spreadsheets/d/1fpHxE_ketMRAzXCKKmMwXxHpvdlT8GNdPWeugIUZ0D0/gviz/tq?gid=1102126140&tqx=out:csv";
Promise.all([
fetch(timelineURL),
fetch(erasURL),
fetch(tagsURL),
fetch(stringsURL),
])
.then((responses) => Promise.all(responses.map((r) => r.text())))
.then((texts) => {
if (document.readyState === "loading") {
document.addEventListener(
"DOMContentLoaded",
populateApp(...texts)
);
} else {
populateApp(...texts);
}
});
</script>
</body>
</html>