-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat-github.html
More file actions
620 lines (534 loc) · 23.4 KB
/
Copy pathchat-github.html
File metadata and controls
620 lines (534 loc) · 23.4 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>GunkyZone - LIVE_COMMS</title>
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-database-compat.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #020202; --bg2: #080505; --border: #2a0000;
--text: #d4c0c0; --accent: #ff0000; --accent2: #9b0000;
--font-mono: 'VT323', monospace;
}
body {
background: var(--bg); color: var(--text); font-family: var(--font-mono);
font-size: 19px; padding: 10px; line-height: 1.2; overflow: hidden;
animation: terminalOn 0.4s ease-out forwards;
}
@keyframes terminalOn {
0% { opacity: 0; transform: scaleY(0.95) scaleX(0.95); filter: brightness(3) contrast(2); }
20% { opacity: 1; transform: scaleY(1.02) scaleX(1.02); filter: brightness(1.5) contrast(1.5); }
40% { opacity: 0.8; transform: scaleY(0.98) scaleX(0.98); filter: brightness(1.2); }
60% { opacity: 1; transform: scaleY(1.01) scaleX(1.01); filter: brightness(1.1); }
80% { opacity: 0.9; transform: scaleY(0.99) scaleX(0.99); filter: brightness(1.05); }
100% { opacity: 1; transform: none; filter: none; }
}
#chat-app { display: flex; height: 95vh; gap: 10px; }
#sidebar { width: 150px; border: 1px solid var(--border); background: #000; display: flex; flex-direction: column; }
.channel { padding: 10px; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--dim); transition: 0.2s; }
.channel:hover { background: var(--bg2); color: var(--text); }
.channel.active { background: var(--accent2); color: #fff; font-weight: bold; }
#chat-container { flex-grow: 1; display: flex; flex-direction: column; }
#chat-header { display: flex; justify-content: space-between; padding: 5px 10px; border: 1px solid var(--border); background: var(--bg2); margin-bottom: 5px; font-size: 14px; }
#messages-container, #npc-messages-container {
flex-grow: 1; overflow-y: auto; border: 1px solid var(--border);
background: #000; padding: 10px; margin-bottom: 10px;
display: flex; flex-direction: column; gap: 6px;
}
#npc-messages-container { display: none; }
.msg {
border-bottom: 1px solid #1a0000;
padding-bottom: 4px;
animation: scanIn 0.2s ease-out;
word-wrap: break-word;
white-space: pre-wrap;
}
.msg-author { font-weight: bold; text-transform: uppercase; margin-right: 8px; }
.input-wrap { display: flex; gap: 5px; border: 1px solid var(--border); background: var(--bg2); padding: 5px; align-items: center; }
input {
background: transparent; border: none; color: #fff;
padding: 8px; font-family: var(--font-mono); font-size: 18px; outline: none; flex-grow: 1;
min-width: 0; /* Prevents input from pushing past flex container */
}
#name-input { width: 80px; flex-shrink: 0; border-right: 1px solid var(--border); color: var(--accent2); text-align: center; }
#messages-container::-webkit-scrollbar, #npc-messages-container::-webkit-scrollbar { width: 6px; }
#messages-container::-webkit-scrollbar-thumb, #npc-messages-container::-webkit-scrollbar-thumb { background: var(--accent2); }
@keyframes scanIn { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: translateX(0); } }
@keyframes glitchText { 0% { opacity: 1; } 50% { opacity: 0.5; transform: translate(1px, -1px); } 100% { opacity: 1; } }
#settings-btn {
background: transparent; border: 1px solid var(--border); color: var(--accent2);
padding: 8px 12px; cursor: pointer; font-family: var(--font-mono); font-size: 16px;
}
#settings-btn:hover { background: var(--bg2); }
#settings-panel {
position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
background: var(--bg); border: 2px solid var(--accent); padding: 20px;
z-index: 1000; min-width: 300px; display: none;
}
.setting-row {
display: flex; justify-content: space-between; align-items: center;
margin-bottom: 15px; gap: 10px;
}
.setting-row label { color: var(--text); min-width: 80px; }
#color-picker {
width: 60px; height: 30px; border: 1px solid var(--border);
background: transparent; cursor: pointer;
}
#style-select {
background: var(--bg2); border: 1px solid var(--border); color: var(--text);
padding: 5px; font-family: var(--font-mono);
}
#close-settings {
background: var(--accent); color: #fff; border: none; padding: 8px 16px;
cursor: pointer; font-family: var(--font-mono); margin-top: 10px;
}
#settings-overlay {
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.7); z-index: 999; display: none;
}
#back-btn {
display: none; /* Hidden by default, shown via JS if not in iframe */
position: absolute; top: 10px; left: 10px; z-index: 100;
background: var(--bg2); border: 1px solid var(--border); color: var(--accent2);
padding: 5px 15px; cursor: pointer; font-family: var(--font-mono); font-size: 16px;
text-decoration: none; text-transform: uppercase;
}
#back-btn:hover { color: #fff; background: var(--accent2); animation: jitter 0.2s infinite; text-shadow: 2px 0 var(--accent), -2px 0 #00ffff; }
@keyframes jitter { 0% { transform: translate(2px, -1px); } 50% { transform: translate(-1px, 1px); } }
/* CRT Curve Effect */
.crt-mode {
position: relative;
border-radius: 20px;
box-shadow: inset 0 0 80px rgba(255, 0, 0, 0.2), inset 0 0 20px rgba(0,0,0,1) !important;
overflow: hidden;
transform: perspective(800px) rotateX(1deg);
}
.crt-mode .msg {
text-shadow: 0 0 3px rgba(255, 255, 255, 0.6), 0 0 8px rgba(255, 0, 0, 0.5); /* Phosphor glow */
}
.crt-mode::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: linear-gradient(rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 30%, rgba(255,255,255,0) 100%);
pointer-events: none;
z-index: 11;
border-radius: 20px;
}
.crt-mode::after {
content: '';
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background:
radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.6) 100%),
linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%); /* Vignette + Scanlines */
background-size: 100% 100%, 100% 4px;
pointer-events: none;
z-index: 10;
border-radius: 20px;
}
/* Chromatic Aberration Glitch */
.chromatic-glitch {
animation: chromatic 0.08s infinite linear;
display: inline-block;
position: relative;
}
@keyframes chromatic {
0% { text-shadow: 2px 0 0 rgba(255,0,0,0.8), -2px 0 0 rgba(0,255,255,0.8); transform: translate(1px, 1px); }
25% { text-shadow: -2px 0 0 rgba(255,0,0,0.8), 2px 0 0 rgba(0,255,255,0.8); transform: translate(-1px, -1px); }
50% { text-shadow: 2px 0 0 rgba(255,0,0,0.8), -2px 0 0 rgba(0,255,255,0.8); transform: translate(-1px, 1px); }
75% { text-shadow: -2px 0 0 rgba(255,0,0,0.8), 2px 0 0 rgba(0,255,255,0.8); transform: translate(1px, -1px); }
100% { text-shadow: 2px 0 0 rgba(255,0,0,0.8), -2px 0 0 rgba(0,255,255,0.8); transform: translate(1px, 1px); }
}
</style>
</head>
<body>
<a href="index.html" id="back-btn">< RETURN</a>
<div id="chat-app">
<div id="sidebar">
<div class="channel active" id="chan-global" onclick="switchToGlobal()"># GLOBAL_COMMS</div>
<div class="channel" id="chan-c" onclick="switchToNPC()"># SUPERVISOR</div>
</div>
<div id="chat-container">
<div id="chat-header">
<span id="chat-title">GLOBAL_COMMS</span>
<span id="chat-status">SYS_STATUS: ONLINE</span>
</div>
<div id="messages-container">
<div class="msg"><span class="msg-author">SYSTEM:</span> ESTABLISHING_LINK...</div>
</div>
<div id="npc-messages-container">
<div class="msg"><span class="msg-author" style="color:var(--dim)">SYSTEM:</span> <span style="color:var(--dim)">ENCRYPTED_CHANNEL_OPENED</span></div>
</div>
<div class="input-wrap">
<input type="text" id="name-input" placeholder="ANON" maxlength="10">
<input type="text" id="chat-input" placeholder="ENTER MESSAGE..." autocomplete="off">
<button id="settings-btn">⚙</button>
</div>
</div>
</div>
<div id="settings-overlay"></div>
<div id="settings-panel">
<div class="setting-row">
<label>Name:</label>
<input type="text" id="settings-name" maxlength="10" style="background: var(--bg2); border: 1px solid var(--border); color: var(--text); padding: 5px; font-family: var(--font-mono);">
</div>
<div class="setting-row">
<label>Color:</label>
<input type="color" id="color-picker" value="#ff0000">
</div>
<div class="setting-row">
<label>Style:</label>
<select id="style-select">
<option value="normal">Normal</option>
<option value="bold">Bold</option>
<option value="italic">Italic</option>
</select>
</div>
<button id="close-settings">CLOSE</button>
</div>
<script>
const firebaseConfig = {
apiKey: "AIzaSyD1L4Mmgnbl0W7lk1rnaRu5wv61TSFhJqM",
authDomain: "gunkychat.firebaseapp.com",
databaseURL: "https://gunkychat-default-rtdb.firebaseio.com",
projectId: "gunkychat",
storageBucket: "gunkychat.firebasestorage.app",
messagingSenderId: "423489767287",
appId: "1:423489767287:web:ce847768781b0f589dc372"
};
firebase.initializeApp(firebaseConfig);
const db = firebase.database().ref('gunky_chat');
const presenceRef = firebase.database().ref('presence');
const msgContainer = document.getElementById('messages-container');
const chatInput = document.getElementById('chat-input');
const nameInput = document.getElementById('name-input');
// --- PRESENCE SYSTEM ---
const amOnline = firebase.database().ref('.info/connected');
const userRef = presenceRef.push();
amOnline.on('value', (snapshot) => {
if (snapshot.val()) {
userRef.onDisconnect().remove();
userRef.set(true);
}
});
presenceRef.on('value', (snapshot) => {
if (currentChannel === 'global') {
const count = snapshot.numChildren();
document.getElementById('chat-status').innerHTML = `SYS_STATUS: ONLINE | USERS: ${count}`;
}
});
// Check if we are in an iframe via query param
const urlParams = new URLSearchParams(window.location.search);
if (!urlParams.has('iframe')) {
// Not in an iframe, show the back button
document.getElementById('back-btn').style.display = 'inline-block';
// Add some top padding to the chat container so it doesn't overlap the button
document.getElementById('chat-container').style.paddingTop = '40px';
}
let userSettings = {
name: localStorage.getItem('chat-name') || 'ANON',
color: localStorage.getItem('chat-color') || '#ff0000',
style: localStorage.getItem('chat-style') || 'normal'
};
nameInput.value = userSettings.name;
document.getElementById('settings-name').value = userSettings.name;
document.getElementById('color-picker').value = userSettings.color;
document.getElementById('style-select').value = userSettings.style;
if (sessionStorage.getItem('npc_chat_terminated') === 'true') {
document.getElementById('chan-c').textContent = '# ???';
}
const settingsBtn = document.getElementById('settings-btn');
const settingsPanel = document.getElementById('settings-panel');
const settingsOverlay = document.getElementById('settings-overlay');
const closeSettings = document.getElementById('close-settings');
settingsBtn.addEventListener('click', () => {
settingsPanel.style.display = 'block';
settingsOverlay.style.display = 'block';
});
closeSettings.addEventListener('click', () => {
settingsPanel.style.display = 'none';
settingsOverlay.style.display = 'none';
userSettings.name = document.getElementById('settings-name').value || 'ANON';
userSettings.color = document.getElementById('color-picker').value;
userSettings.style = document.getElementById('style-select').value;
localStorage.setItem('chat-name', userSettings.name);
localStorage.setItem('chat-color', userSettings.color);
localStorage.setItem('chat-style', userSettings.style);
nameInput.value = userSettings.name;
});
settingsOverlay.addEventListener('click', () => {
closeSettings.click();
});
db.limitToLast(50).on('value', (snapshot) => {
msgContainer.innerHTML = "";
snapshot.forEach((child) => {
const data = child.val();
const div = document.createElement('div');
div.className = 'msg';
const authorSpan = document.createElement('span');
authorSpan.className = 'msg-author';
authorSpan.textContent = (data.author || 'ANON') + ':';
authorSpan.style.color = data.color || '#ff0000';
const textSpan = document.createElement('span');
textSpan.textContent = data.text || '';
if (data.style === 'bold') textSpan.style.fontWeight = 'bold';
if (data.style === 'italic') textSpan.style.fontStyle = 'italic';
div.appendChild(authorSpan);
div.appendChild(textSpan);
msgContainer.appendChild(div);
});
msgContainer.scrollTop = msgContainer.scrollHeight;
});
function sendMessage() {
const text = chatInput.value.trim();
if (text !== "") {
db.push({
author: userSettings.name,
text: text,
color: userSettings.color,
style: userSettings.style,
timestamp: Date.now()
});
chatInput.value = "";
}
}
// --- NPC CHAT LOGIC ---
let currentChannel = 'global';
const npcContainer = document.getElementById('npc-messages-container');
const forcedMessages = [
"Hello? is someone there?",
"...and who are you?",
"C... youre name is like mine, cool huh?",
"so... where are you, C?",
"and you...?",
"right... right i figured but i just wanted to know, like, WHERE are you?"
];
const npcResponses = [
"I AM.",
"I AM C.",
"YEAH.",
"YOU ARE IN. WHITE SPACE.",
"I AM NOT IN. WHITE SPACE.",
"THE USA. NORTH OF \"THE BIG GAME\""
];
let npcStep = 0;
let forcedProgress = 0;
let ghostTimer = null;
let ghostInterval = null;
let isNpcTyping = false;
function switchToNPC() {
if (sessionStorage.getItem('npc_chat_terminated') === 'true') {
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.inset = '0';
overlay.style.backgroundColor = 'rgba(5, 0, 0, 0.95)';
overlay.style.color = 'red';
overlay.style.display = 'flex';
overlay.style.flexDirection = 'column';
overlay.style.alignItems = 'center';
overlay.style.justifyContent = 'center';
overlay.style.fontSize = '30px';
overlay.style.fontFamily = 'var(--font-mono)';
overlay.style.zIndex = '9999';
overlay.style.animation = 'glitchText 0.05s infinite';
overlay.innerHTML = '<div>ERR_NO_CHAT_FOUND</div><div style="font-size: 16px; margin-top: 10px;">CHANNEL DOES NOT EXIST OR HAS BEEN PURGED.</div>';
document.body.appendChild(overlay);
// Add a quick screen shake effect to the body
const originalTransform = document.body.style.transform;
document.body.style.transform = 'translate(2px, 2px)';
setTimeout(() => document.body.style.transform = 'translate(-2px, -2px)', 50);
setTimeout(() => document.body.style.transform = 'translate(2px, -2px)', 100);
setTimeout(() => document.body.style.transform = 'translate(-2px, 2px)', 150);
setTimeout(() => document.body.style.transform = originalTransform, 200);
setTimeout(() => {
if (document.body.contains(overlay)) {
document.body.removeChild(overlay);
}
}, 600);
return;
}
currentChannel = 'npc';
document.getElementById('chan-global').classList.remove('active');
document.getElementById('chan-c').classList.add('active');
msgContainer.style.display = 'none';
npcContainer.style.display = 'flex';
document.getElementById('chat-title').textContent = 'PRIVATE_COMM_LINK';
document.getElementById('chat-status').innerHTML = 'USERS_ONLINE: <span style="color:red; animation: glitchText 0.2s infinite;">JUST_YOU</span>';
// Visual shift
document.body.style.boxShadow = "inset 0 0 50px rgba(255,0,0,0.15)";
document.getElementById('chat-app').style.filter = "contrast(1.2) brightness(0.9)";
document.getElementById('chat-container').classList.add('crt-mode');
chatInput.value = "";
chatInput.placeholder = "TYPE YOUR MESSAGE...";
nameInput.disabled = true;
chatInput.focus();
}
function switchToGlobal() {
currentChannel = 'global';
document.getElementById('chan-c').classList.remove('active');
document.getElementById('chan-global').classList.add('active');
npcContainer.style.display = 'none';
msgContainer.style.display = 'flex';
document.getElementById('chat-title').textContent = 'GLOBAL_COMMS';
// Update presence count immediately when switching back
presenceRef.once('value').then((snapshot) => {
const count = snapshot.numChildren();
document.getElementById('chat-status').innerHTML = `SYS_STATUS: ONLINE | USERS: ${count}`;
});
// Remove visual shift
document.body.style.boxShadow = "none";
document.getElementById('chat-app').style.filter = "none";
document.getElementById('chat-container').classList.remove('crt-mode');
chatInput.value = "";
chatInput.placeholder = "ENTER MESSAGE...";
chatInput.disabled = false;
nameInput.disabled = false;
clearTimeout(ghostTimer);
clearInterval(ghostInterval);
}
function resetGhostTimer() {
clearTimeout(ghostTimer);
clearInterval(ghostInterval);
const targetMsg = forcedMessages[npcStep];
if (forcedProgress > 0 && forcedProgress < targetMsg.length) {
ghostTimer = setTimeout(() => {
// Ghost takes over
ghostInterval = setInterval(() => {
if (forcedProgress < targetMsg.length) {
forcedProgress++;
chatInput.value = targetMsg.substring(0, forcedProgress);
} else {
clearInterval(ghostInterval);
setTimeout(sendNpcMessage, 500);
}
}, 150);
}, 2000);
}
}
function sendNpcMessage() {
clearTimeout(ghostTimer);
clearInterval(ghostInterval);
const text = chatInput.value;
appendNpcMsg("T", text, userSettings.color);
chatInput.value = "";
forcedProgress = 0;
isNpcTyping = true;
// Show NPC typing indicator
const typingIndicator = document.createElement('div');
typingIndicator.className = 'msg';
typingIndicator.id = 'npc-typing';
typingIndicator.innerHTML = `<span class="msg-author" style="color:#888;">C:</span> <span style="color:#555; font-style:italic;">is typing...</span>`;
npcContainer.appendChild(typingIndicator);
npcContainer.scrollTop = npcContainer.scrollHeight;
// If it's the final message, type it out slowly and then glitch out
if (npcStep === npcResponses.length - 1) {
setTimeout(() => {
const ind = document.getElementById('npc-typing');
if (ind) npcContainer.removeChild(ind);
const finalDiv = document.createElement('div');
finalDiv.className = 'msg';
finalDiv.innerHTML = `<span class="msg-author" style="color:#ffffff">C:</span> <span id="final-npc-text"></span>`;
npcContainer.appendChild(finalDiv);
const finalText = npcResponses[npcStep];
let charIndex = 0;
const slowTypeInterval = setInterval(() => {
if (charIndex < finalText.length) {
document.getElementById('final-npc-text').textContent += finalText.charAt(charIndex);
charIndex++;
npcContainer.scrollTop = npcContainer.scrollHeight;
// Glitch out right before the end (at the 'G' in 'GAME')
if (charIndex === finalText.length - 3) {
clearInterval(slowTypeInterval);
document.getElementById('final-npc-text').classList.add('chromatic-glitch');
// Let the text glitch for a moment before terminating
setTimeout(() => {
triggerTermination();
}, 1500);
}
}
}, 200); // Slow typing speed
}, 3000);
return;
}
// Normal response logic
setTimeout(() => {
const ind = document.getElementById('npc-typing');
if (ind) npcContainer.removeChild(ind);
if (npcStep < npcResponses.length) {
appendNpcMsg("C", npcResponses[npcStep], "#ffffff");
npcStep++;
}
isNpcTyping = false;
}, 3000);
}
function triggerTermination() {
sessionStorage.setItem('npc_chat_terminated', 'true');
document.getElementById('chan-c').textContent = '# ???';
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.inset = '0';
overlay.style.backgroundColor = '#000';
overlay.style.color = 'red';
overlay.style.display = 'flex';
overlay.style.alignItems = 'center';
overlay.style.justifyContent = 'center';
overlay.style.fontSize = '40px';
overlay.style.fontFamily = 'var(--font-mono)';
overlay.style.zIndex = '9999';
overlay.style.animation = 'glitchText 0.1s infinite';
overlay.innerHTML = 'LIVE FEED TERMINATED';
document.body.appendChild(overlay);
// Optional: redirect back to index after a few seconds
setTimeout(() => {
if (window.self !== window.top) {
// We are in an iframe, just reload the chat
window.location.reload();
} else {
// We are on the standalone chat page, go back to index
window.location.href = 'index.html';
}
}, 4000);
}
function appendNpcMsg(author, text, color) {
const div = document.createElement('div');
div.className = 'msg';
div.innerHTML = `<span class="msg-author" style="color:${color}">${author}:</span> <span>${text}</span>`;
npcContainer.appendChild(div);
npcContainer.scrollTop = npcContainer.scrollHeight;
}
chatInput.addEventListener('keydown', (e) => {
if (currentChannel === 'global') {
if (e.key === 'Enter') sendMessage();
return;
}
// NPC Channel Logic
if (e.key === 'Enter') {
e.preventDefault();
if (npcStep < forcedMessages.length && forcedProgress === forcedMessages[npcStep].length) {
sendNpcMessage();
}
return;
}
// Ignore control keys
if (e.key.length > 1 && e.key !== 'Backspace') return;
e.preventDefault(); // Stop normal typing
if (isNpcTyping || npcStep >= forcedMessages.length) return;
const targetMsg = forcedMessages[npcStep];
if (e.key === 'Backspace') {
// Don't allow backspace
return;
}
// Type 3 characters per keystroke to make it feel faster and more frantic
forcedProgress += 3;
if (forcedProgress > targetMsg.length) forcedProgress = targetMsg.length;
chatInput.value = targetMsg.substring(0, forcedProgress);
resetGhostTimer();
});
</script>
</body>
</html>