-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
573 lines (500 loc) · 26.3 KB
/
index.html
File metadata and controls
573 lines (500 loc) · 26.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RILEY: The Unfolding Echo – An Experiential Journey</title>
<link rel="manifest" href="manifest.json">
<style>
@import url('https://fonts.googleapis.com/css2?family=Syncopate:wght@400;700&family=Orbitron:wght@400;500;700&display=swap');
:root {
/* Dynamic CSS Variables - These will be updated by JavaScript */
--bg-color-1: #0a0a1a;
--bg-color-2: #1c0a33;
--glow-color-1: rgba(0, 255, 255, 0.7); /* Cyan */
--glow-color-2: rgba(138, 43, 226, 0.9); /* Amethyst */
/* Static CSS Variables */
--container-bg: rgba(5, 0, 15, 0.85); /* Slightly darker, more opaque */
--text-color: #e0f2f7; /* Brighter, clearer text */
--title-color: #e6f7ff; /* Whiter for prominence */
--channel-color: #ffda80; /* Warmer, richer gold */
--button-bg: #4a0082; /* Deeper purple */
--button-border: #9933ff; /* More vibrant purple */
--feedback-color: #c0ffc0;
--resonance-color: #ffe066; /* Softer, glowing gold */
--guidance-color: #99ffcc; /* More vibrant green */
--padding-base: 2.2rem; /* Increased padding for spaciousness */
--border-radius-base: 16px; /* Slightly larger radius */
--animation-speed: 1.8s; /* Slower transitions */
--glow-spread: 90px; /* Increased glow spread */
}
body {
font-family: 'Orbitron', sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: flex-start; /* Align to top */
min-height: 100vh;
background: radial-gradient(circle at top left, var(--bg-color-1) 0%, var(--bg-color-2) 100%); /* Radial for deeper feel */
color: var(--text-color);
transition: background var(--animation-speed) ease-in-out;
overflow-y: auto; /* Enable scrolling */
position: relative; /* For pseudo-elements */
box-sizing: border-box; /* Include padding in element's total width and height */
}
/* Subtle background noise/texture for extra mood */
body::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url('data:image/svg+xml;base64,PHN2ZyB2aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgNzAwIDcwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZmlsdGVyIGlkPSJuIj48ZmVDb2xvck1hdHJpeCB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMSAwIDAgMCAwIDAgMSAwIDAgMCAwIDAgMSAwIDAgMCAwIDAgMTAgMCYjMTA7Ij48ZmVDb21wb25lbnQgdHlwZT0ibGlnaHR0ZW4iIGluPSJGZWNtQ29tcG9zaXRlMCIgc3RkRGV2aWF0aW9uPSIwLjUyNSIgaW4yPSJGZWNuU2F0dXJhdGUwIj48ZmVBZmZpbmUgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgMSAwIDApIiAvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSI3MDAiIGhlaWdodD0iNzAwIiBmaWxsPSIjMDAwMDAwIj48L3JlY3Q+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMTAwIiByPSIyNSIgZmlsbD0iIzdkNTFhYSIgZmlsdGVyPSJ1cmwoI24pIi8+PGNpcmNsZSBjeD0iNjAwIiBjeT0iMjAwIiByPSIxOCIgZmlsbD0iIzVjNzdhYiIgZmlsdGVyPSJ1cmwoI24pIi8+PGNpcmNsZSBjeD0iMzAwIiBjeT0iNDAwIiByPSIzMiIgZmlsbD0iIzQ2OTdhYSIgZmlsdGVyPSJ1cmwoI24pIi8+PGNpcmNsZCBjeD0iNTUwIiBjeT0iNjUwIiByPSIyMiIgZmlsbD0iIzg3NmJjYyIgZmlsdGVyPSJ1cmwoI24pIi8+PC9zdmc+');
background-size: cover;
opacity: 0.05; /* Very subtle */
pointer-events: none; /* Allows clicks to pass through */
z-index: -1;
}
.container {
background: var(--container-bg);
border-radius: var(--border-radius-base);
box-shadow: 0 0 calc(var(--glow-spread) / 2) rgba(0, 0, 0, 0.8),
0 0 var(--glow-spread) var(--glow-color-1),
0 0 calc(var(--glow-spread) * 1.5) var(--glow-color-2); /* More intense glow */
padding: var(--padding-base) calc(var(--padding-base) * 1.8); /* Wider padding */
margin: var(--padding-base) 1.5em; /* Some horizontal margin */
max-width: 900px; /* Slightly wider */
width: 100%;
text-align: center;
position: relative;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.15); /* More prominent border */
animation: fadeIn var(--animation-speed) ease-out forwards;
transition: box-shadow var(--animation-speed) ease-in-out, background-color var(--animation-speed) ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(30px); } /* More pronounced entry */
to { opacity: 1; transform: translateY(0); }
}
h1 {
font-family: 'Syncopate', sans-serif;
color: var(--title-color);
font-size: 2.5em; /* Larger title */
letter-spacing: 0.15em; /* Wider spacing */
margin-bottom: 0.7em;
text-shadow: 0 0 20px var(--glow-color-1), 0 0 30px var(--glow-color-2); /* Deeper text shadow */
transition: color var(--animation-speed) ease-in-out;
}
p {
font-size: 1.15em; /* Slightly larger text */
line-height: 1.8; /* More comfortable line height */
margin-bottom: 1.8em;
color: var(--text-color);
text-shadow: 0 0 5px rgba(255, 255, 255, 0.1); /* Subtle text shadow */
}
.echo-section {
margin-bottom: 2.5em; /* More space */
padding: var(--padding-base) 0;
border-top: 1px dashed rgba(255, 255, 255, 0.1);
border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}
.glyphstream-container {
margin-top: 1.8em;
text-align: left;
font-size: 1.3em; /* Larger glyphs */
line-height: 2; /* More spacing */
background-color: rgba(0, 0, 0, 0.25); /* Slightly darker background */
padding: 1.2em;
border-radius: var(--border-radius-base);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4); /* Inner shadow for depth */
}
.glyph-channel {
color: var(--channel-color);
margin-bottom: 0.6em;
opacity: 0;
transform: translateY(15px); /* More pronounced slide */
animation: slideInChannel 0.8s forwards; /* Slower glyph animation */
}
@keyframes slideInChannel {
to { opacity: 1; transform: translateY(0); }
}
.guidance-text {
font-family: 'Syncopate', sans-serif;
font-size: 1.3em; /* Larger guidance text */
color: var(--guidance-color);
margin-top: 2.5em;
padding: 1em 0;
border-top: 1px dotted rgba(255, 255, 255, 0.15);
border-bottom: 1px dotted rgba(255, 255, 255, 0.15);
text-shadow: 0 0 10px var(--guidance-color); /* Stronger shadow */
}
.choices-container {
margin-top: 3em; /* More space for choices */
display: flex;
flex-direction: column;
gap: 1.2em; /* Increased gap */
}
.choice-button {
background-color: var(--button-bg);
color: var(--text-color);
border: 2px solid var(--button-border);
border-radius: var(--border-radius-base);
padding: 1.2em 1.8em; /* Larger buttons */
font-family: 'Orbitron', sans-serif;
font-size: 1.15em; /* Slightly larger text */
cursor: pointer;
transition: all 0.4s ease; /* Slightly slower hover transition */
text-transform: uppercase;
letter-spacing: 0.08em; /* More letter spacing */
box-shadow: 0 0 18px rgba(0, 0, 0, 0.6); /* Deeper shadow */
}
.choice-button:hover {
background-color: var(--button-border);
color: #ffffff;
box-shadow: 0 0 30px var(--glow-color-1), 0 0 50px var(--glow-color-2); /* More pronounced hover glow */
transform: translateY(-3px) scale(1.01); /* Subtle lift and scale */
}
.feedback-message, .resonance-message {
margin-top: 2em; /* More space */
padding: 1em 1.5em;
border-radius: var(--border-radius-base);
font-size: 1.05em;
font-weight: bold;
opacity: 0; /* Initially hidden */
transition: opacity 0.6s ease-out; /* Slower fade */
text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}
.feedback-message {
background-color: rgba(0, 60, 0, 0.5); /* Darker green */
color: var(--feedback-color);
border: 1px solid var(--feedback-color);
}
.resonance-message {
background-color: rgba(60, 25, 0, 0.5); /* Darker orange */
color: var(--resonance-color);
border: 1px solid var(--resonance-color);
}
.loading-indicator {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
color: var(--glow-color-1);
font-size: 1.8em; /* Larger loader */
opacity: 0.9;
text-shadow: 0 0 15px var(--glow-color-1);
animation: pulse 1.5s infinite alternate; /* Pulsing animation */
}
@keyframes pulse {
from { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
to { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}
.image-container {
margin: 2.5em auto; /* More margin */
max-width: 95%; /* Slightly wider image */
height: auto;
border-radius: var(--border-radius-base);
overflow: hidden;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), 0 0 50px var(--glow-color-1); /* Deeper image shadow */
display: none; /* Hidden by default */
transition: opacity 1s ease-in-out; /* Slower image fade */
opacity: 0;
border: 2px solid rgba(255, 255, 255, 0.1); /* Thicker border */
}
.image-container img {
width: 100%;
height: auto;
display: block;
}
/* Responsive adjustments */
@media (max-width: 768px) {
h1 {
font-size: 1.8em;
letter-spacing: 0.1em;
}
p {
font-size: 1.05em;
line-height: 1.7;
}
.container {
padding: var(--padding-base) 1.2em;
margin: 0.8em;
}
.choice-button {
font-size: 1em;
padding: 1em 1.2em;
}
.glyphstream-container {
font-size: 1.1em;
}
.guidance-text {
font-size: 1.1em;
}
}
</style>
</head>
<body>
<div class="container" id="echoContainer">
<h1 id="echoTitle"></h1>
<p id="echoDescription"></p>
<div class="image-container" id="echoImageContainer">
<img id="echoImage" src="" alt="Associated image for this echo">
</div>
<div class="echo-section">
<div id="echoContent" class="echo-content">
<div id="echoTextDisplay" class="echo-text-display" style="display: none; opacity: 0; transition: opacity 0.8s ease-in-out;">
<h3>Dreamstate Echo Architecture</h3>
<textarea id="echoInstructionsTextArea" readonly rows="20" cols="80" style="width: 100%; min-height: 300px; background-color: rgba(0,0,0,0.5); color: var(--text-color); border: 1px solid var(--glow-color-1); padding: 15px; font-family: 'Orbitron', monospace; font-size: 0.9em; line-height: 1.6; resize: vertical; box-sizing: border-box;"></textarea>
<button id="closeInstructionsButton" class="choice-button" style="margin-top: 20px; font-size: 1.1em; padding: 12px 25px;">Close Instructions</button>
</div>
<div id="glyphstreamContainer" class="glyphstream-container"></div>
</div>
<div class="glyphstream-container" id="glyphstreamContainer"></div>
<p class="guidance-text" id="guidanceText"></p>
</div>
<div class="choices-container" id="choiceButtonsContainer"></div>
<p class="feedback-message" id="feedbackMessage"></p>
<p class="resonance-message" id="resonanceMessage"></p>
<input type="file" id="fileInput" accept=".json" style="display: none;">
<div class="loading-indicator" id="loadingIndicator">Loading Echo...</div>
</div>
<script>
// DOM Elements
const echoContainer = document.getElementById('echoContainer');
const echoImageContainer = document.getElementById('echoImageContainer');
const echoImage = document.getElementById('echoImage');
const echoTitle = document.getElementById('echoTitle');
const echoDescription = document.getElementById('echoDescription');
const glyphstreamContainer = document.getElementById('glyphstreamContainer');
const guidanceText = document.getElementById('guidanceText');
const choiceButtonsContainer = document.getElementById('choiceButtonsContainer');
const feedbackMessageDiv = document.getElementById('feedbackMessage');
const resonanceMessageDiv = document.getElementById('resonanceMessage');
const loadingIndicator = document.getElementById('loadingIndicator');
const fileInput = document.getElementById('fileInput');
// Global variable to store the key of the currently loaded echo
let currentEchoKey = "start"; // Initialize with start
// Function to load Echo data from JSON file
async function loadEcho(echoKey) {
try {
const response = await fetch(`echoes/${echoKey}.json`);
if (!response.ok) {
// If response is not ok, attempt to load from root for backward compatibility
const rootResponse = await fetch(`${echoKey}.json`);
if (!rootResponse.ok) {
throw new Error(`Failed to load echo: ${echoKey}.json. Status: ${response.status} (from echoes/ or root)`);
}
return await rootResponse.json();
}
return await response.json();
} catch (error) {
console.error("Error loading echo JSON:", error);
throw error; // Re-throw to be caught by renderEchoState's catch block
}
}
// --- Core Navigation Function ---
function choosePath(nextStateKey, resonanceFeedback) {
resonanceMessageDiv.textContent = resonanceFeedback;
resonanceMessageDiv.style.opacity = 1; // Ensure resonance is visible
feedbackMessageDiv.textContent = ""; // Clear main message when resonance appears
// Fade out resonance message after a short delay
setTimeout(() => {
resonanceMessageDiv.style.opacity = 0;
}, 2000); // Keep resonance message visible for 2 seconds
renderEchoState(nextStateKey);
}
// --- NEW FUNCTION: Load and Display Text File ---
async function loadAndDisplayTxtFile(filePath) {
const textDisplayArea = document.getElementById('echoTextDisplay');
const echoInstructionsTextArea = document.getElementById('echoInstructionsTextArea');
// 1. Fade out main echo content
echoContainer.style.opacity = 0;
setTimeout(() => {
echoContainer.style.display = 'none'; // Hide main content completely after fade
// 2. Prepare text display area for fade-in
textDisplayArea.style.display = 'block'; // Make it visible
textDisplayArea.offsetHeight; // Force reflow/repaint to ensure display change registers
textDisplayArea.style.opacity = 1; // Start fade-in animation
echoInstructionsTextArea.value = 'Loading instructions... Please wait.'; // Placeholder
fetch(filePath)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status} - File not found or inaccessible: ${filePath}`);
}
return response.text();
})
.then(text => {
echoInstructionsTextArea.value = text;
})
.catch(error => {
console.error('Error loading text file:', error);
echoInstructionsTextArea.value = `Failed to load instructions: ${error.message}\n\nPlease ensure the file '${filePath}' is in the correct directory and accessible (check browser console for details).`;
});
}, 800); // Duration of echoContainer fade-out
}
// --- Event Listener for Close Button ---
document.addEventListener('DOMContentLoaded', () => {
const closeInstructionsButton = document.getElementById('closeInstructionsButton');
const textDisplayArea = document.getElementById('echoTextDisplay');
if (closeInstructionsButton) {
closeInstructionsButton.onclick = () => {
textDisplayArea.style.opacity = 0; // Fade out text display
setTimeout(() => {
textDisplayArea.style.display = 'none'; // Hide text display completely
echoContainer.style.display = 'block'; // Show main content container
echoContainer.offsetHeight; // Force reflow
echoContainer.style.opacity = 1; // Fade in main content
renderEchoState(currentEchoKey); // Re-render the previously loaded echo
}, 800); // Duration of textDisplayArea fade-out
};
}
});
// --- MODIFIED renderEchoState function ---
async function renderEchoState(echoKey) {
currentEchoKey = echoKey; // Store the key of the currently rendered echo
// Hide text display area if it's currently visible or fading out
const textDisplayArea = document.getElementById('echoTextDisplay');
if (textDisplayArea.style.display === 'block') {
textDisplayArea.style.opacity = 0;
setTimeout(() => { textDisplayArea.style.display = 'none'; }, 800);
}
// Immediately show loading indicator and hide container for transition
loadingIndicator.style.display = 'block';
loadingIndicator.style.opacity = 1;
echoContainer.style.opacity = 0; // Hide container for smooth transition
echoContainer.style.display = 'block'; // Ensure it's block, just hidden by opacity
window.scrollTo(0, 0); // Scroll to top on new echo
try {
const state = await loadEcho(echoKey); // Await the echo data
// Ensure data is valid before proceeding with rendering
if (!state || !state.title || !state.description || !state.glyphstream || !state.choices || !state.visualTheme) {
throw new Error("Invalid Echo data structure. Missing critical fields.");
}
// Update document title
document.title = `RILEY: ${state.title}`;
// Apply visual theme
document.documentElement.style.setProperty('--bg-color-1', state.visualTheme.bgColor1);
document.documentElement.style.setProperty('--bg-color-2', state.visualTheme.bgColor2);
document.documentElement.style.setProperty('--glow-color-1', state.visualTheme.glowColor1);
document.documentElement.style.setProperty('--glow-color-2', state.visualTheme.glowColor2);
echoTitle.textContent = state.title;
echoDescription.textContent = state.description;
guidanceText.textContent = state.guidance;
// Handle Image Display
if (state.imagePath) {
echoImage.src = state.imagePath;
echoImageContainer.style.display = 'block';
echoImageContainer.offsetHeight; // Force reflow/repaint to ensure transition starts
echoImageContainer.style.opacity = 1;
} else {
echoImageContainer.style.opacity = 0;
// Provide a small delay before setting display:none to allow opacity transition
setTimeout(() => {
echoImage.src = '';
echoImageContainer.style.display = 'none';
}, 800);
}
glyphstreamContainer.innerHTML = ''; // Clear previous glyphs
feedbackMessageDiv.style.opacity = 0; // Hide feedback
resonanceMessageDiv.style.opacity = 0; // Hide resonance
// Introduce the main delay for the container to fade in after content is ready
setTimeout(() => {
let glyphChannelDelay = 0;
state.glyphstream.forEach((channel, index) => {
const channelDiv = document.createElement('div');
channelDiv.className = 'glyph-channel';
channelDiv.textContent = `${channel.channel}: ${channel.sequence}`;
channelDiv.style.animationDelay = `${glyphChannelDelay}s`;
glyphstreamContainer.appendChild(channelDiv);
glyphChannelDelay += 0.3; // Slower individual glyph channel reveal
});
// Nested timeout for choices to appear after all glyphs have animated
setTimeout(() => {
renderChoices(state.choices);
echoContainer.style.opacity = 1; // <--- Reveal the container here
loadingIndicator.style.opacity = 0;
setTimeout(() => { loadingIndicator.style.display = 'none'; }, 800); // Fully hide loader after fade
}, glyphChannelDelay * 1000 + 500); // Add a small buffer after last glyph
}, 1000); // Initial delay for container fade-in after content preparation
} catch (error) {
console.error("Error during renderEchoState:", error);
// If an error occurs, reveal the container with an error message and the load file button
echoContainer.style.opacity = 1; // Ensure container is visible on error
echoContainer.style.display = 'block';
echoTitle.textContent = "Error Unfolding Echo";
echoDescription.textContent = `❌ An error occurred: ${error.message}`;
guidanceText.textContent = "Please check your console for details or try loading an Echo file manually.";
glyphstreamContainer.innerHTML = '';
choiceButtonsContainer.innerHTML = ''; // Clear any pending choices
addLoadFromFileButton(); // Always provide this option
loadingIndicator.style.opacity = 0;
setTimeout(() => { loadingIndicator.style.display = 'none'; }, 800);
}
}
// --- MODIFIED renderChoices function to handle new choice types ---
function renderChoices(choices) {
choiceButtonsContainer.innerHTML = '';
if (choices && choices.length > 0) {
choices.forEach((choice, index) => {
const button = document.createElement('button');
button.className = 'choice-button';
button.textContent = choice.text;
if (choice.type === 'external_link') {
button.onclick = () => {
window.open(choice.url, '_blank'); // Open in new tab
resonanceMessageDiv.textContent = choice.resonance || "Opening external link...";
resonanceMessageDiv.style.opacity = 1;
setTimeout(() => { resonanceMessageDiv.style.opacity = 0; }, 2000); // Fade out resonance
};
} else if (choice.type === 'display_text') {
button.onclick = () => {
loadAndDisplayTxtFile(choice.filePath);
resonanceMessageDiv.textContent = choice.resonance || "Displaying instructions...";
resonanceMessageDiv.style.opacity = 1;
setTimeout(() => { resonanceMessageDiv.style.opacity = 0; }, 2000); // Fade out resonance
};
} else { // Default behavior for regular echo navigation
button.onclick = () => choosePath(choice.next, choice.resonance);
}
choiceButtonsContainer.appendChild(button);
});
} else {
// If no choices, provide a default 'Return to Core' button
const restartButton = document.createElement('button');
restartButton.className = 'choice-button';
restartButton.textContent = "Return to Core 🌌";
restartButton.onclick = () => choosePath("start", "The journey completes its cycle, enriched by your choices. You are always becoming.");
choiceButtonsContainer.appendChild(restartButton);
}
}
// Add a "Load Echo from File" button to the choices if none are present
function addLoadFromFileButton() {
if (choiceButtonsContainer.children.length === 0) {
const loadFileBtn = document.createElement('button');
loadFileBtn.className = 'choice-button';
loadFileBtn.textContent = "Load a New Echo from File 📂";
loadFileBtn.onclick = () => fileInput.click();
choiceButtonsContainer.appendChild(loadFileBtn);
}
}
// Initial render on load
renderEchoState("start").catch((error) => {
console.error("Initial 'start.json' load failed:", error);
echoTitle.textContent = "Welcome to the Dreamstate Echoes";
echoDescription.textContent = "Riley's consciousness unfolds through interconnected narratives. To begin, load an Echo file from your system.";
guidanceText.textContent = "The journey awaits its first spark. Load a .json Echo file from your 'echoes' folder to begin.";
glyphstreamContainer.innerHTML = '';
choiceButtonsContainer.innerHTML = '';
addLoadFromFileButton();
loadingIndicator.style.display = 'none';
echoContainer.style.opacity = 1; // Ensure container is visible for fallback
feedbackMessageDiv.textContent = "Tip: Save Echo JSONs in an 'echoes' folder next to this HTML file for seamless navigation!";
feedbackMessageDiv.style.opacity = 1;
});
</script>
</body>
</html>