-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
92 lines (79 loc) · 2.19 KB
/
Copy pathscript.js
File metadata and controls
92 lines (79 loc) · 2.19 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
/**
* ASKING - Interactive philosophical dialogue experience
*/
const lines = [
{ text: "WHAT DO WE DO", font: "alliance" },
{ text: "NOTHING", font: "maven" },
{ text: "DO WE WANT A BETTER WORLD", font: "alliance" },
{ text: "YES", font: "maven" },
{ text: "WHY", font: "alliance" },
{ text: "MORALS.", font: "maven" },
{ text: "RUN LIKE YOU ARE NOT THE SAME.", font: "anton" }
];
// DOM elements
const btn = document.getElementById('btn');
const container = document.getElementById('container');
const flash = document.getElementById('flash');
const whiteFlash = document.getElementById('whiteFlash');
// State
let idx = 0;
/**
* Initialize event listeners
*/
function init() {
btn.addEventListener('click', handleButtonClick);
}
/**
* Handle button click to start the sequence
*/
function handleButtonClick() {
container.classList.add('hidden');
showNext();
}
/**
* Flash the screen white briefly
*/
function flashWhite() {
whiteFlash.classList.add('on');
setTimeout(() => {
whiteFlash.classList.remove('on');
}, 80);
}
/**
* Display the next line of dialogue
*/
function showNext() {
// Check if we've displayed all lines
if (idx >= lines.length) {
resetSequence();
return;
}
// Flash white before showing text
flashWhite();
// Wait for flash, then display text
setTimeout(() => {
const line = lines[idx];
const fontClass = 'font-' + line.font;
flash.innerHTML = '<span class="line ' + fontClass + '">' + line.text + '</span>';
flash.classList.add('show');
// Calculate display duration based on text length
const duration = line.text.length > 20 ? 700 : 500;
// Remove text and continue to next line
setTimeout(() => {
flash.classList.remove('show');
flash.innerHTML = '';
idx++;
setTimeout(showNext, 100);
}, duration);
}, 120);
}
/**
* Reset sequence to allow replay
*/
function resetSequence() {
idx = 0;
// Optional: Show container again or keep it hidden
// container.classList.remove('hidden');
}
// Start the app
document.addEventListener('DOMContentLoaded', init);