-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsuperchat.html
More file actions
135 lines (125 loc) · 3.51 KB
/
Copy pathsuperchat.html
File metadata and controls
135 lines (125 loc) · 3.51 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ghost Pitch — Superchat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: #0a0a0f;
color: #e0e0e0;
font-family: 'SF Mono', 'Fira Code', monospace;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 24px 16px;
}
h1 { color: #8b5cf6; font-size: 20px; margin-bottom: 8px; }
.subtitle { color: #666; font-size: 12px; margin-bottom: 24px; text-transform: uppercase; letter-spacing: 2px; }
#form {
width: 100%;
max-width: 500px;
display: flex;
gap: 8px;
margin-bottom: 24px;
}
#form input {
flex: 1;
padding: 14px 16px;
border-radius: 8px;
border: 1px solid #333;
background: #12121a;
color: #e0e0e0;
font-family: inherit;
font-size: 16px;
}
#form input:focus { outline: none; border-color: #8b5cf6; }
#form button {
padding: 14px 24px;
border-radius: 8px;
border: none;
background: #8b5cf6;
color: white;
font-family: inherit;
font-weight: bold;
font-size: 14px;
cursor: pointer;
text-transform: uppercase;
}
#form button:active { transform: scale(0.95); }
#feed {
width: 100%;
max-width: 500px;
display: flex;
flex-direction: column;
gap: 8px;
}
.msg {
background: #12121a;
border: 1px solid #222;
border-radius: 8px;
padding: 12px 16px;
font-size: 14px;
animation: fadeIn 0.3s;
}
.msg .name { color: #8b5cf6; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.msg .text { margin-top: 4px; }
#stats {
color: #666;
font-size: 12px;
margin-bottom: 16px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body>
<h1>GHOST PITCH SUPERCHAT</h1>
<div class="subtitle">Your feedback shapes the build</div>
<div id="stats">0 messages</div>
<div id="form">
<input type="text" id="input" placeholder="Your feedback..." maxlength="280" autofocus>
<button id="send">SEND</button>
</div>
<div id="feed"></div>
<script>
const API = '/api/feedback';
const input = document.getElementById('input');
const feed = document.getElementById('feed');
const stats = document.getElementById('stats');
let lastName = localStorage.getItem('ghost-name') || '';
if (!lastName) {
lastName = prompt('Your name (or leave blank):') || 'Anon';
localStorage.setItem('ghost-name', lastName);
}
document.getElementById('send').addEventListener('click', send);
input.addEventListener('keydown', (e) => { if (e.key === 'Enter') send(); });
async function send() {
const text = input.value.trim();
if (!text) return;
input.value = '';
try {
await fetch(API, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text, name: lastName }),
});
} catch (e) { console.error('Send failed:', e); }
}
async function poll() {
try {
const res = await fetch(API);
const data = await res.json();
stats.textContent = `${data.total} messages`;
feed.innerHTML = data.recent.slice().reverse().map(m =>
`<div class="msg"><div class="name">${esc(m.name)}</div><div class="text">${esc(m.text)}</div></div>`
).join('');
} catch {}
}
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
setInterval(poll, 3000);
poll();
</script>
</body>
</html>