-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
303 lines (272 loc) · 14.9 KB
/
index.html
File metadata and controls
303 lines (272 loc) · 14.9 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>풋볼 AI</title>
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap" rel="stylesheet">
<style>
:root {
--pitch: #0a1f0e;
--pitch-mid: #0f2b14;
--pitch-light: #163d1e;
--neon: #00e64d;
--gold: #f0c040;
--white: #f0efe8;
--gray: #8a9a8e;
--red: #e63946;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--pitch); color: var(--white); font-family: 'Noto Sans KR', sans-serif; overflow: hidden; }
body::before {
content: '';
position: fixed; inset: 0; z-index: 0; pointer-events: none;
background-image:
repeating-linear-gradient(90deg, transparent 0, transparent 99px, rgba(255,255,255,.018) 99px, rgba(255,255,255,.018) 100px),
repeating-linear-gradient(0deg, transparent 0, transparent 79px, rgba(255,255,255,.018) 79px, rgba(255,255,255,.018) 80px);
}
/* 헤더 */
header {
position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 58px;
background: linear-gradient(180deg, rgba(0,0,0,.92), rgba(0,0,0,.7));
border-bottom: 2px solid var(--neon);
display: flex; align-items: center; padding: 0 24px; gap: 16px;
backdrop-filter: blur(12px);
}
.logo { font-family: 'Oswald', sans-serif; font-size: 1.5rem; font-weight: 700; letter-spacing: 4px; display: flex; align-items: center; gap: 10px; }
.logo em { color: var(--neon); font-style: normal; }
.live { background: var(--red); font-family: 'Oswald', sans-serif; font-size: .65rem; font-weight: 600; letter-spacing: 2px; padding: 3px 8px; border-radius: 3px; animation: liveBlink 1.5s infinite; }
@keyframes liveBlink { 0%,100% { opacity:1 } 50% { opacity:.5 } }
.ticker-wrap { flex: 1; overflow: hidden; border-left: 1px solid rgba(255,255,255,.1); border-right: 1px solid rgba(255,255,255,.1); margin: 0 12px; height: 100%; display: flex; align-items: center; }
.ticker { display: flex; white-space: nowrap; animation: scroll 38s linear infinite; }
.ticker span { font-size: .72rem; color: var(--gray); padding: 0 28px; border-right: 1px solid rgba(255,255,255,.08); }
.ticker span b { color: var(--gold); font-weight: 500; }
@keyframes scroll { 0% { transform: translateX(0) } 100% { transform: translateX(-50%) } }
.clear-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: var(--gray); font-family: 'Noto Sans KR', sans-serif; font-size: .72rem; padding: 5px 12px; border-radius: 20px; cursor: pointer; transition: all .2s; }
.clear-btn:hover { background: rgba(255,255,255,.12); color: var(--white); }
/* 레이아웃 */
.main { position: fixed; top: 58px; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; }
.chat-col { width: 700px; max-width: 100%; display: flex; flex-direction: column; }
/* 채팅 */
#chatbox { flex: 1; overflow-y: auto; padding: 28px 24px 16px; display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; }
#chatbox::-webkit-scrollbar { width: 3px; }
#chatbox::-webkit-scrollbar-thumb { background: rgba(0,230,77,.3); border-radius: 3px; }
/* 웰컴 */
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding: 40px 20px; }
.welcome-ball { font-size: 4rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-12px) } }
.welcome h2 { font-family: 'Oswald', sans-serif; font-size: 2rem; letter-spacing: 2px; }
.welcome h2 em { color: var(--neon); font-style: normal; }
.welcome p { color: var(--gray); font-size: .85rem; font-weight: 300; }
.welcome-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; width: 100%; max-width: 480px; }
.w-chip { background: rgba(0,230,77,.07); border: 1px solid rgba(0,230,77,.2); color: var(--white); font-family: 'Noto Sans KR', sans-serif; font-size: .78rem; padding: 10px 14px; border-radius: 10px; cursor: pointer; text-align: left; transition: all .2s; }
.w-chip:hover { background: rgba(0,230,77,.15); border-color: var(--neon); transform: translateY(-1px); }
/* 버블 */
.msg { display: flex; flex-direction: column; max-width: 86%; animation: msgIn .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes msgIn { from { opacity:0; transform: translateY(14px) scale(.96) } to { opacity:1; transform: none } }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
.msg-meta { font-size: .63rem; color: var(--gray); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.avatar { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .65rem; }
.msg.bot .avatar { background: var(--neon); color: #000; }
.msg.user .avatar { background: var(--gold); color: #000; }
.bubble { padding: 13px 18px; border-radius: 18px; font-size: .9rem; line-height: 1.75; word-break: break-word; }
.msg.user .bubble { background: var(--gold); color: #1a1200; font-weight: 500; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--pitch-light); color: var(--white); border: 1px solid rgba(0,230,77,.12); border-bottom-left-radius: 4px; }
.cursor { display: inline-block; width: 2px; height: 1em; background: var(--neon); margin-left: 2px; vertical-align: text-bottom; animation: blink .7s infinite; }
@keyframes blink { 0%,50% { opacity:1 } 51%,100% { opacity:0 } }
.typing-indicator .bubble { display: flex; gap: 5px; align-items: center; padding: 16px 20px; }
.dot { width: 7px; height: 7px; background: var(--neon); border-radius: 50%; animation: bounce 1.1s infinite; }
.dot:nth-child(2) { animation-delay: .18s; }
.dot:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.5 } 30% { transform: translateY(-8px); opacity:1 } }
/* 입력 */
.input-section { flex-shrink: 0; padding: 0 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.quick-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.quick-row::-webkit-scrollbar { display: none; }
.q-chip { flex-shrink: 0; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); color: var(--gray); font-family: 'Noto Sans KR', sans-serif; font-size: .72rem; padding: 5px 12px; border-radius: 20px; cursor: pointer; transition: all .18s; white-space: nowrap; }
.q-chip:hover { background: rgba(0,230,77,.1); border-color: rgba(0,230,77,.3); color: var(--neon); }
.input-row { display: flex; gap: 10px; align-items: flex-end; background: var(--pitch-light); border: 1px solid rgba(0,230,77,.2); border-radius: 16px; padding: 10px 10px 10px 18px; transition: border-color .2s; }
.input-row:focus-within { border-color: rgba(0,230,77,.6); box-shadow: 0 0 0 3px rgba(0,230,77,.06); }
#userInput { flex: 1; background: transparent; border: none; outline: none; color: var(--white); font-family: 'Noto Sans KR', sans-serif; font-size: .9rem; resize: none; max-height: 120px; line-height: 1.5; }
#userInput::placeholder { color: rgba(255,255,255,.2); }
#sendBtn { width: 42px; height: 42px; flex-shrink: 0; background: var(--neon); border: none; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; }
#sendBtn:hover { background: #00ff55; transform: scale(1.06); }
#sendBtn:active { transform: scale(.95); }
#sendBtn:disabled { background: rgba(0,230,77,.25); cursor: not-allowed; transform: none; }
#sendBtn svg { width: 18px; height: 18px; fill: #000; }
.footer-note { text-align: center; font-size: .62rem; color: rgba(255,255,255,.15); }
</style>
</head>
<body>
<header>
<div class="logo">⚽ <em>FOOTBALL</em> AI</div>
<div class="live">LIVE</div>
<div class="ticker-wrap">
<div class="ticker">
<span>🏆 레알 마드리드 <b>UCL 15회 우승</b></span>
<span>⚽ 홀란드 <b>PL 단일 시즌 36골</b> 신기록</span>
<span>🇰🇷 손흥민 <b>아시아 선수 PL 최다 득점</b></span>
<span>🐐 메시 <b>발롱도르 8회</b> 역대 최다</span>
<span>🇰🇷 김민재 <b>바이에른 뮌헨</b> 수비 핵심</span>
<span>🌍 2026 월드컵 <b>미국·캐나다·멕시코</b> 공동 개최</span>
<span>🔥 음바페 <b>레알 마드리드</b> 이적 완료</span>
<span>🏆 레알 마드리드 <b>UCL 15회 우승</b></span>
<span>⚽ 홀란드 <b>PL 단일 시즌 36골</b> 신기록</span>
<span>🇰🇷 손흥민 <b>아시아 선수 PL 최다 득점</b></span>
<span>🐐 메시 <b>발롱도르 8회</b> 역대 최다</span>
<span>🇰🇷 김민재 <b>바이에른 뮌헨</b> 수비 핵심</span>
<span>🌍 2026 월드컵 <b>미국·캐나다·멕시코</b> 공동 개최</span>
<span>🔥 음바페 <b>레알 마드리드</b> 이적 완료</span>
</div>
</div>
<button class="clear-btn" onclick="clearChat()">🗑 초기화</button>
</header>
<div class="main">
<div class="chat-col">
<div id="chatbox">
<div class="welcome" id="welcomeScreen">
<div class="welcome-ball">⚽</div>
<h2>풋볼 <em>AI</em>에 오신 걸 환영합니다</h2>
<p>선수, 팀, 전술, 역사 — 축구에 관한 모든 것을 물어보세요</p>
<div class="welcome-chips" id="welcomeChips"></div>
</div>
</div>
<div class="input-section">
<div class="quick-row" id="quickRow"></div>
<div class="input-row">
<textarea id="userInput" rows="1" placeholder="축구에 관해 무엇이든..."></textarea>
<button id="sendBtn" onclick="send()">
<svg viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>
</button>
</div>
<p class="footer-note">풋볼 AI · Powered by Claude · 대화 내용은 세션 동안 기억됩니다</p>
</div>
</div>
</div>
<script>
const chatbox = document.getElementById("chatbox");
const input = document.getElementById("userInput");
const sendBtn = document.getElementById("sendBtn");
// 빠른 질문 버튼 서버에서 받아서 렌더링
async function loadQuestions() {
const qs = await fetch("/api/questions").then(r => r.json());
const wChips = document.getElementById("welcomeChips");
const qRow = document.getElementById("quickRow");
qs.forEach(q => {
wChips.innerHTML += `<button class="w-chip" onclick="quickSend('${q.text}')">${q.label}</button>`;
qRow.innerHTML += `<button class="q-chip" onclick="quickSend('${q.text}')">${q.label}</button>`;
});
}
loadQuestions();
input.addEventListener("input", () => {
input.style.height = "auto";
input.style.height = Math.min(input.scrollHeight, 120) + "px";
});
input.addEventListener("keydown", e => {
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); send(); }
});
function quickSend(text) { input.value = text; send(); }
function hideWelcome() {
const w = document.getElementById("welcomeScreen");
if (!w) return;
w.style.transition = "opacity .3s";
w.style.opacity = "0";
setTimeout(() => w.remove(), 300);
}
function addMsg(role, text) {
hideWelcome();
const el = document.createElement("div");
el.className = `msg ${role}`;
el.innerHTML = `
<div class="msg-meta">
<span class="avatar">${role === "user" ? "👤" : "⚽"}</span>
${role === "user" ? "나" : "풋볼 AI"}
</div>
<div class="bubble">${text.replace(/</g,"<").replace(/>/g,">")}</div>
`;
chatbox.appendChild(el);
scrollDown();
return el;
}
function showTyping() {
const el = document.createElement("div");
el.className = "msg bot typing-indicator";
el.id = "typing";
el.innerHTML = `
<div class="msg-meta"><span class="avatar">⚽</span>풋볼 AI</div>
<div class="bubble"><span class="dot"></span><span class="dot"></span><span class="dot"></span></div>
`;
chatbox.appendChild(el);
scrollDown();
}
function scrollDown() { setTimeout(() => chatbox.scrollTop = chatbox.scrollHeight, 50); }
async function send() {
const text = input.value.trim();
if (!text || sendBtn.disabled) return;
input.value = "";
input.style.height = "auto";
sendBtn.disabled = true;
addMsg("user", text);
showTyping();
try {
const res = await fetch("/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: text }),
});
document.getElementById("typing")?.remove();
// 스트리밍 버블 만들기
const wrapper = document.createElement("div");
wrapper.className = "msg bot";
const bubble = document.createElement("div");
bubble.className = "bubble";
const cursor = document.createElement("span");
cursor.className = "cursor";
bubble.appendChild(cursor);
wrapper.innerHTML = `<div class="msg-meta"><span class="avatar">⚽</span>풋볼 AI</div>`;
wrapper.appendChild(bubble);
chatbox.appendChild(wrapper);
// SSE 읽기
const reader = res.body.getReader();
const decoder = new TextDecoder();
let buf = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buf += decoder.decode(value, { stream: true });
const lines = buf.split("\n");
buf = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
try {
const data = JSON.parse(line.slice(6));
if (data.chunk) { cursor.before(document.createTextNode(data.chunk)); scrollDown(); }
if (data.done || data.error) cursor.remove();
} catch {}
}
}
} catch {
document.getElementById("typing")?.remove();
addMsg("bot", "연결 오류가 났어요. 잠깐 후에 다시 해봐요.");
} finally {
sendBtn.disabled = false;
input.focus();
}
}
async function clearChat() {
if (!confirm("대화 기록 초기화할까요?")) return;
await fetch("/api/clear", { method: "POST" });
chatbox.innerHTML = `
<div class="welcome" id="welcomeScreen">
<div class="welcome-ball">⚽</div>
<h2>풋볼 <em>AI</em>에 오신 걸 환영합니다</h2>
<p>선수, 팀, 전술, 역사 — 축구에 관한 모든 것을 물어보세요</p>
<div class="welcome-chips" id="welcomeChips"></div>
</div>
`;
loadQuestions();
}
</script>
</body>
</html>