-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
345 lines (309 loc) · 20.5 KB
/
index.html
File metadata and controls
345 lines (309 loc) · 20.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UniPath AI - Non-Profit Admissions Mentor</title>
<!-- Styles & Icons -->
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Markdown Rendering -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
body { font-family: 'Inter', sans-serif; background: #f8fafc; }
.glass-card { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(226, 232, 240, 0.8); }
.chat-container { height: calc(100vh - 300px); min-height: 400px; }
.typing-dot { animation: typing 1.4s infinite; }
@keyframes typing { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal.active { display: flex; }
.message-content blockquote { border-left: 4px solid #e2e8f0; padding-left: 1rem; color: #64748b; margin: 0.5rem 0; }
.message-content ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 0.5rem; }
.message-content ol { list-style-type: decimal; padding-left: 1.5rem; margin-bottom: 0.5rem; }
.message-content p { margin-bottom: 0.75rem; }
.message-content strong { color: #1e293b; font-weight: 700; }
.btn-active:active { transform: scale(0.95); }
@keyframes fadeInLeft { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeInRight { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
.animate-in-left { animation: fadeInLeft 0.3s ease-out; }
.animate-in-right { animation: fadeInRight 0.3s ease-out; }
.suggestion-chip { cursor: pointer; transition: all 0.2s; border: 1px solid #e2e8f0; }
.suggestion-chip:hover { border-color: #4f46e5; background: #f5f3ff; color: #4f46e5; }
</style>
</head>
<body class="text-slate-800">
<!-- Header Navigation -->
<nav class="sticky top-0 z-50 glass-card px-6 py-4 flex justify-between items-center shadow-sm">
<div class="flex items-center gap-2 cursor-pointer" onclick="location.reload()">
<div class="bg-indigo-600 p-2 rounded-lg shadow-lg">
<i class="fas fa-graduation-cap text-white text-xl"></i>
</div>
<div>
<h1 class="font-bold text-xl tracking-tight text-slate-900">UniPath <span class="text-indigo-600">AI</span></h1>
<p class="text-[10px] text-slate-500 uppercase tracking-widest font-semibold">Non-Profit Admissions Platform</p>
</div>
</div>
<div class="flex items-center gap-3">
<button id="share-btn" class="hidden sm:flex items-center gap-2 px-4 py-2 rounded-xl bg-slate-100 text-slate-600 text-sm font-semibold hover:bg-slate-200 transition-all btn-active">
<i class="fas fa-share-alt"></i>
<span>Share</span>
</button>
<button id="open-settings" class="w-10 h-10 rounded-full hover:bg-slate-100 transition-colors flex items-center justify-center text-slate-500 btn-active" title="Settings">
<i class="fas fa-cog text-lg"></i>
</button>
</div>
</nav>
<!-- Main Content -->
<main class="max-w-4xl mx-auto px-4 py-6">
<!-- Core Value Proposition -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="glass-card p-4 rounded-2xl flex items-center gap-3 border-l-4 border-indigo-500">
<div class="w-10 h-10 rounded-full bg-indigo-50 flex items-center justify-center text-indigo-600">
<i class="fas fa-globe"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-900 uppercase">Global Strategy</h3>
<p class="text-[10px] text-slate-500">Expertise in UK, US, HK, and SG admissions</p>
</div>
</div>
<div class="glass-card p-4 rounded-2xl flex items-center gap-3 border-l-4 border-emerald-500">
<div class="w-10 h-10 rounded-full bg-emerald-50 flex items-center justify-center text-emerald-600">
<i class="fas fa-lightbulb"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-900 uppercase">Data-Driven</h3>
<p class="text-[10px] text-slate-500">Evidence-based profile positioning</p>
</div>
</div>
<div class="glass-card p-4 rounded-2xl flex items-center gap-3 border-l-4 border-amber-500">
<div class="w-10 h-10 rounded-full bg-amber-50 flex items-center justify-center text-amber-600">
<i class="fas fa-hand-holding-heart"></i>
</div>
<div>
<h3 class="text-xs font-bold text-slate-900 uppercase">Pro Bono</h3>
<p class="text-[10px] text-slate-500">Dedicated to educational equity for all</p>
</div>
</div>
</div>
<div class="flex flex-col glass-card rounded-3xl overflow-hidden shadow-2xl relative">
<!-- Status Bar -->
<div class="bg-gradient-to-r from-slate-800 to-slate-900 px-6 py-3 text-white flex justify-between items-center">
<div class="flex items-center gap-3">
<span class="flex h-2 w-2 rounded-full bg-green-500 animate-pulse"></span>
<h2 class="font-bold text-xs tracking-wider uppercase">Consultation Terminal</h2>
</div>
<span id="protocol-indicator" class="text-[10px] font-bold uppercase opacity-60">System Online</span>
</div>
<!-- Chat Window -->
<div id="chat-window" class="chat-container overflow-y-auto p-6 md:p-10 space-y-8 bg-white/50">
<div class="flex gap-4 animate-in-left">
<div class="w-10 h-10 rounded-2xl bg-slate-800 flex items-center justify-center text-white shadow-lg shrink-0">
<i class="fas fa-robot"></i>
</div>
<div class="bg-white p-5 rounded-2xl rounded-tl-none shadow-sm border border-slate-100 max-w-[90%]">
<div class="text-sm leading-relaxed text-slate-700 message-content">
<p><strong>Welcome to UniPath AI.</strong></p>
<p>I am your global admissions consultant. I can help you with:</p>
<ul class="mt-2 text-xs text-slate-500 list-disc pl-4 space-y-1">
<li>Customizing application timelines (UK/US/HK/SG)</li>
<li>Major selection and interdisciplinary profiling</li>
<li>Drafting strategic essays and activity lists</li>
</ul>
<p class="mt-3 text-xs italic text-slate-400">Please provide your background (curriculum, grades, interests) to get started.</p>
<div class="flex flex-wrap gap-2 mt-4">
<span class="suggestion-chip px-3 py-1.5 rounded-lg text-xs font-medium bg-white shadow-sm" onclick="sendQuickMessage('Help me choose between UK and US application paths.')">UK vs US Strategy</span>
<span class="suggestion-chip px-3 py-1.5 rounded-lg text-xs font-medium bg-white shadow-sm" onclick="sendQuickMessage('How should I plan my activities for an Engineering major?')">Activity Planning</span>
<span class="suggestion-chip px-3 py-1.5 rounded-lg text-xs font-medium bg-white shadow-sm" onclick="sendQuickMessage('What is a competitive IELTS/TOEFL score for Ivy League schools?')">Score Requirements</span>
</div>
</div>
</div>
</div>
</div>
<!-- Input Area -->
<div class="p-6 bg-white border-t border-slate-100">
<div class="relative flex items-end gap-3">
<div class="flex-1 relative">
<textarea id="user-input" rows="1" class="w-full pl-5 pr-14 py-4 bg-slate-50 border border-slate-200 rounded-2xl focus:ring-4 focus:ring-indigo-500/10 focus:border-indigo-500 outline-none transition-all resize-none text-sm font-medium" placeholder="Describe your background or ask a question..."></textarea>
<button id="send-btn" class="absolute right-2 bottom-2 p-3 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-all shadow-lg btn-active">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
<p class="text-center text-[10px] text-slate-400 mt-4 uppercase tracking-tighter">
Mission: Promoting Educational Access Through AI
</p>
</div>
</div>
</main>
<!-- Settings Modal -->
<div id="settings-modal" class="modal px-4">
<div class="bg-white rounded-3xl p-8 max-w-md w-full shadow-2xl">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold text-slate-900">API Configuration</h3>
<i class="fas fa-shield-alt text-indigo-600 opacity-50"></i>
</div>
<div class="space-y-5">
<div>
<label class="block text-xs font-bold text-slate-500 uppercase mb-2 tracking-wider">API Key</label>
<input type="password" id="api-key-input" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl outline-none focus:border-indigo-500 transition-all" placeholder="Enter your Gemini or OpenAI API Key">
</div>
<div>
<label class="block text-xs font-bold text-slate-500 uppercase mb-2 tracking-wider">API Endpoint</label>
<input type="text" id="api-url-input" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl outline-none focus:border-indigo-500 transition-all" placeholder="https://generativelanguage.googleapis.com">
<p class="text-[10px] text-slate-400 mt-2 italic">Support official Google Gemini and OpenAI-compatible proxies.</p>
</div>
<div>
<label class="block text-xs font-bold text-slate-500 uppercase mb-2 tracking-wider">Model Name</label>
<input type="text" id="api-model-input" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl outline-none focus:border-indigo-500 transition-all" placeholder="gemini-2.0-flash">
</div>
</div>
<div class="flex gap-3 mt-10">
<button id="save-settings" class="flex-1 bg-indigo-600 text-white py-3.5 rounded-xl font-bold hover:bg-indigo-700 transition-all shadow-lg shadow-indigo-200 btn-active">Apply Changes</button>
<button id="close-settings" class="flex-1 bg-slate-100 text-slate-600 py-3.5 rounded-xl font-bold hover:bg-slate-200 transition-all btn-active">Close</button>
</div>
<p class="text-center text-[10px] text-slate-300 mt-4">Privacy: Your API key is stored locally and never sent to our servers.</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const chatWindow = document.getElementById('chat-window');
const userInput = document.getElementById('user-input');
const sendBtn = document.getElementById('send-btn');
const settingsModal = document.getElementById('settings-modal');
const protocolIndicator = document.getElementById('protocol-indicator');
const shareBtn = document.getElementById('share-btn');
const apiKeyInput = document.getElementById('api-key-input');
const apiUrlInput = document.getElementById('api-url-input');
const apiModelInput = document.getElementById('api-model-input');
// --- Config ---
let config = {
key: localStorage.getItem('unipath_api_key') || "",
url: localStorage.getItem('unipath_api_url') || "https://generativelanguage.googleapis.com",
model: localStorage.getItem('unipath_api_model') || "gemini-2.0-flash"
};
apiKeyInput.value = config.key;
apiUrlInput.value = config.url;
apiModelInput.value = config.model;
updateProtocolLabel();
// General Admissions Strategy System Prompt
const systemPrompt = `Role: Professional Global Admissions Strategic Consultant.
Objective: Provide strategic, non-biased advice for high school students applying to top universities worldwide (UK, US, HK, SG, etc.).
Knowledge: Expertise in A-Level, IB, AP, and various international curricula.
Interaction: Professional, insightful, and structured. Use Markdown.
Language: Default to Professional English, but match the user's language if they use a different one.
Mission: Support educational equity by providing pro bono advisory services through AI.`;
// --- UI ---
document.getElementById('open-settings').onclick = () => settingsModal.classList.add('active');
document.getElementById('close-settings').onclick = () => settingsModal.classList.remove('active');
document.getElementById('save-settings').onclick = () => {
config.key = apiKeyInput.value.trim();
config.url = apiUrlInput.value.trim() || "https://generativelanguage.googleapis.com";
config.model = apiModelInput.value.trim() || "gemini-2.0-flash";
localStorage.setItem('unipath_api_key', config.key);
localStorage.setItem('unipath_api_url', config.url);
localStorage.setItem('unipath_api_model', config.model);
settingsModal.classList.remove('active');
updateProtocolLabel();
appendMessage('ai', "✅ **System ready**. Please describe your academic background or ask your admission questions.");
};
shareBtn.onclick = () => {
const url = window.location.href;
const tempInput = document.createElement("input");
document.body.appendChild(tempInput);
tempInput.value = url;
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
const span = shareBtn.querySelector('span');
const originalText = span.innerText;
span.innerText = "Link Copied!";
setTimeout(() => span.innerText = originalText, 2000);
};
function updateProtocolLabel() {
const isGemini = config.url.includes('googleapis.com');
protocolIndicator.innerText = isGemini ? "Gemini Protocol" : "OpenAI/Proxy Protocol";
}
// --- AI Logic ---
async function callAI(message) {
if (!config.key) return "⚠️ **Configuration Needed**: Please open settings to add your API Key to begin.";
const isGeminiOfficial = config.url.includes('googleapis.com');
let fetchUrl, payload, headers;
try {
if (isGeminiOfficial) {
fetchUrl = `${config.url.replace(/\/$/, '')}/v1beta/models/${config.model}:generateContent?key=${config.key}`;
payload = {
contents: [{ parts: [{ text: message }] }],
systemInstruction: { parts: [{ text: systemPrompt }] },
tools: [{ "google_search": {} }]
};
headers = { 'Content-Type': 'application/json' };
} else {
fetchUrl = `${config.url.replace(/\/$/, '')}/v1/chat/completions`;
payload = {
model: config.model,
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: message }
]
};
headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${config.key}`
};
}
const response = await fetch(fetchUrl, { method: 'POST', headers: headers, body: JSON.stringify(payload) });
const data = await response.json();
if (data.error) throw new Error(data.error.message || "API error occurred");
if (isGeminiOfficial) {
return data.candidates?.[0]?.content?.parts?.[0]?.text || "No response generated.";
} else {
return data.choices?.[0]?.message?.content || "No response generated.";
}
} catch (e) {
return `❌ **Connection Error**: ${e.message}. Check your API Key and Endpoint.`;
}
}
function appendMessage(role, text) {
const wrapper = document.createElement('div');
wrapper.className = `flex gap-4 ${role === 'user' ? 'justify-end animate-in-right' : 'animate-in-left'}`;
const contentHtml = role === 'ai' ? marked.parse(text) : text;
const html = role === 'ai'
? `<div class="w-10 h-10 rounded-2xl bg-slate-800 flex items-center justify-center text-white shadow-lg shrink-0"><i class="fas fa-robot"></i></div>
<div class="bg-white p-5 rounded-2xl rounded-tl-none shadow-sm border border-slate-100 max-w-[90%] text-sm leading-relaxed text-slate-700 message-content">${contentHtml}</div>`
: `<div class="bg-indigo-600 p-5 rounded-2xl rounded-tr-none shadow-lg text-white max-w-[85%] text-sm font-medium leading-relaxed">${contentHtml}</div>`;
wrapper.innerHTML = html;
chatWindow.appendChild(wrapper);
chatWindow.scrollTo({ top: chatWindow.scrollHeight, behavior: 'smooth' });
}
async function handleSend(textOverride = null) {
const text = textOverride || userInput.value.trim();
if (!text) return;
appendMessage('user', text);
if (!textOverride) userInput.value = '';
userInput.style.height = 'auto';
const typing = document.createElement('div');
typing.id = 'temp-typing';
typing.className = 'flex gap-2 text-[10px] font-bold text-slate-400 pl-14 items-center uppercase';
typing.innerHTML = `<span>Mentor is thinking</span><span class="typing-dot">.</span><span class="typing-dot">.</span><span class="typing-dot">.</span>`;
chatWindow.appendChild(typing);
chatWindow.scrollTop = chatWindow.scrollHeight;
const res = await callAI(text);
typing.remove();
appendMessage('ai', res);
}
window.sendQuickMessage = (msg) => handleSend(msg);
sendBtn.onclick = () => handleSend();
userInput.onkeydown = (e) => {
if(e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); }
};
userInput.oninput = function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
};
});
</script>
</body>
</html>