-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
402 lines (353 loc) · 15.7 KB
/
index.html
File metadata and controls
402 lines (353 loc) · 15.7 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
<!DOCTYPE html>
<!--
╔══════════════════════════════════════════════════════════════╗
║ StudyNexus — index.html (v2) ║
║ ║
║ NEW in v2: ║
║ • Add LOCAL FILES (PDF, PPT, images, videos, etc.) ║
║ • File stored as base64 in localStorage ║
║ • AI suggests title + category + tags from filename/URL ║
║ • Edit category (and other fields) after saving ║
║ • Type-tab switcher: URL vs File in the add modal ║
╚══════════════════════════════════════════════════════════════╝
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StudyNexus 📚</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Nunito:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/animations.css">
<link rel="stylesheet" href="css/modal.css">
</head>
<body>
<!-- Decorative glowing background blobs (animated in animations.css) -->
<div class="bg-blob bg-blob-1"></div>
<div class="bg-blob bg-blob-2"></div>
<!-- ═══════════════════════════════════════════
MAIN LAYOUT — sidebar | main content
════════════════════════════════════════════ -->
<div class="layout">
<!-- ╔══════════════╗
║ SIDEBAR ║
╚══════════════╝ -->
<aside class="sidebar">
<div class="logo">
<div class="logo-icon">📚</div>
<div>
<div class="logo-name">StudyNexus</div>
<div class="logo-tagline">Knowledge Hub</div>
</div>
</div>
<!-- Library nav (All, Starred) -->
<div>
<div class="sidebar-label">Library</div>
<div id="main-nav">
<button class="nav-btn active" onclick="setFilter('all', this)">
<span>◈</span> All Resources
<span class="nav-badge" id="count-all">0</span>
</button>
<button class="nav-btn" onclick="setFilter('starred', this)">
<span>★</span> Starred
<span class="nav-badge" id="count-starred">0</span>
</button>
</div>
</div>
<!-- File-type filter nav -->
<div>
<div class="sidebar-label">By Type</div>
<div id="type-nav">
<!-- Filled by render.js -->
</div>
</div>
<!-- Category nav (generated from data) -->
<div>
<div class="sidebar-label">Categories</div>
<div id="cat-nav">
<!-- render.js fills this in dynamically -->
</div>
</div>
<!-- Cerebras API key -->
<div>
<div class="sidebar-label">AI Settings</div>
<div class="api-key-section">
<input
class="api-key-input"
type="password"
id="cerebras-api-key"
placeholder="Paste Cerebras API key…"
oninput="saveApiKey()"
>
<div class="api-key-hint">
Free key at <a href="https://cloud.cerebras.ai" target="_blank" rel="noopener">cloud.cerebras.ai</a>
</div>
<div class="api-key-status" id="api-key-status"></div>
</div>
</div>
<button class="add-resource-btn" onclick="openModal()">
+ Add Resource
</button>
</aside>
<!-- ╔══════════════╗
║ MAIN ║
╚══════════════╝ -->
<main class="main">
<!-- Search + view toggle -->
<div class="topbar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input
class="search-input"
type="text"
id="search-input"
placeholder="Search resources, files, tags…"
oninput="renderAll()"
>
</div>
<div class="view-toggle">
<button class="view-btn active" id="btn-grid" onclick="setView('grid')" title="Grid View">⊞</button>
<button class="view-btn" id="btn-list" onclick="setView('list')" title="List View">≡</button>
</div>
</div>
<div class="content">
<!-- Stats row -->
<div class="stats-row">
<div class="stat-card" style="animation-delay:0.1s">
<div class="stat-num" id="stat-total" style="color:var(--accent)">0</div>
<div class="stat-label">Total Resources</div>
</div>
<div class="stat-card" style="animation-delay:0.2s">
<div class="stat-num" id="stat-cats" style="color:var(--accent2)">0</div>
<div class="stat-label">Categories</div>
</div>
<div class="stat-card" style="animation-delay:0.3s">
<div class="stat-num" id="stat-starred" style="color:var(--yellow)">0</div>
<div class="stat-label">Starred</div>
</div>
<div class="stat-card" style="animation-delay:0.4s">
<div class="stat-num" id="stat-tags" style="color:var(--accent3)">0</div>
<div class="stat-label">Unique Tags</div>
</div>
</div>
<!-- Heading -->
<div class="page-heading">
<h1 class="page-title" id="page-title">All Resources</h1>
<span class="page-subtitle" id="page-count">0 items</span>
</div>
<!-- Tag filter pills -->
<div class="tag-bar" id="tag-bar"></div>
<!-- Cards injected here by render.js -->
<div id="resources-container"></div>
</div>
</main>
</div><!-- end .layout -->
<!-- ═══════════════════════════════════════════════════════
ADD RESOURCE MODAL
Has two tabs: URL tab and File tab.
Switching tabs is handled by modal.js (switchTab function).
════════════════════════════════════════════════════════ -->
<div class="modal-overlay" id="modal-overlay" onclick="closeIfOverlay(event)">
<div class="modal">
<div class="modal-header">
<h2 class="modal-title" id="modal-main-title">Add Resource</h2>
<button class="modal-close" onclick="closeModal()">×</button>
</div>
<!-- ── TAB SWITCHER: URL vs File ── -->
<div class="tab-switcher">
<!-- Tab buttons — clicking calls switchTab() in modal.js -->
<button class="tab-btn active" id="tab-url" onclick="switchTab('url')">
🔗 Web URL
</button>
<button class="tab-btn" id="tab-file" onclick="switchTab('file')">
📁 Local File
</button>
</div>
<!-- ══════════════════════════════
TAB 1: URL input
══════════════════════════════ -->
<div id="url-panel">
<div class="form-group">
<label class="form-label">URL *</label>
<input
class="form-input"
type="url"
id="inp-url"
placeholder="https://…"
oninput="autoFillTitle()"
>
</div>
</div>
<!-- ══════════════════════════════
TAB 2: File upload
══════════════════════════════ -->
<div id="file-panel" style="display:none">
<!-- Drag-and-drop / click-to-browse zone -->
<div class="file-drop-zone" id="file-drop-zone"
onclick="document.getElementById('inp-file').click()"
ondragover="onDragOver(event)"
ondragleave="onDragLeave(event)"
ondrop="onFileDrop(event)">
<div class="file-drop-icon" id="file-drop-icon">📂</div>
<div class="file-drop-text" id="file-drop-text">
Click to browse or drag & drop
</div>
<div class="file-drop-hint">
PDF, PPT, PPTX, DOC, DOCX, XLS, XLSX,<br>
JPG, PNG, GIF, MP4, MOV, AVI, MP3 and more
</div>
<!-- The actual hidden file input — triggered by clicking the zone -->
<input
type="file"
id="inp-file"
style="display:none"
accept=".pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.gif,.webp,.svg,.mp4,.mov,.avi,.mkv,.mp3,.wav,.zip,.txt,.md,.csv"
onchange="onFileSelected(event)"
>
</div>
<!-- File info row — shown once a file is picked -->
<div class="file-info-row" id="file-info-row" style="display:none">
<span class="file-type-icon" id="file-type-icon">📄</span>
<div class="file-info-text">
<div class="file-info-name" id="file-info-name"></div>
<div class="file-info-size" id="file-info-size"></div>
</div>
<!-- × to clear the chosen file -->
<button class="file-clear-btn" onclick="clearFile()" title="Remove file">×</button>
</div>
</div>
<!-- ── Shared fields (shown for both tabs) ── -->
<div class="form-group">
<label class="form-label">Title *</label>
<input
class="form-input"
type="text"
id="inp-title"
placeholder="Give this resource a name"
>
</div>
<div class="form-row">
<div class="form-group" style="margin-bottom:0">
<label class="form-label">Category *</label>
<input
class="form-input"
type="text"
id="inp-cat"
placeholder="e.g. DSA, React…"
list="cat-list"
>
<datalist id="cat-list"></datalist>
</div>
<div class="form-group" style="margin-bottom:0">
<label class="form-label">Importance</label>
<select class="form-select" id="inp-importance">
<option value="normal">Normal</option>
<option value="important">⭐ Important</option>
<option value="critical">🔥 Critical</option>
</select>
</div>
</div>
<div class="form-group" style="margin-top:16px">
<label class="form-label">
Tags <span class="form-hint">(Enter or comma to add)</span>
</label>
<div class="tags-input-area" id="tags-area" onclick="focusTagInput()">
<input class="tags-text-input" id="tag-input" placeholder="Add a tag…" onkeydown="onTagKey(event)">
</div>
</div>
<!-- ── AI SUGGEST SECTION ── -->
<div class="ai-section">
<div class="ai-section-header">
<span class="ai-icon">✦</span>
<span class="ai-label">AI Assistant</span>
<span class="ai-badge">Cerebras</span>
</div>
<p class="ai-description">
AI reads your <strong>URL or filename</strong> and suggests a
<strong>title</strong>, <strong>category</strong>, and <strong>tags</strong>.
</p>
<button class="ai-btn" id="ai-suggest-btn" onclick="askCerebrasAI()">
<span id="ai-btn-icon">✦</span>
<span id="ai-btn-text">Suggest with AI</span>
</button>
<div class="ai-result" id="ai-result" style="display:none">
<div class="ai-result-label">AI suggested:</div>
<div id="ai-result-content"></div>
<button class="ai-apply-btn" onclick="applyAiSuggestion()">✓ Apply Suggestions</button>
</div>
<div class="ai-error" id="ai-error" style="display:none"></div>
</div>
<button class="submit-btn" onclick="addResource()">Save Resource →</button>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════
EDIT RESOURCE MODAL
A second, separate modal that opens when the user clicks
the ✏ (edit) button on any card. Lets them change:
• Title, Category, Importance, Tags
Category change is the key new feature here.
════════════════════════════════════════════════════════ -->
<div class="modal-overlay" id="edit-modal-overlay" onclick="closeEditIfOverlay(event)">
<div class="modal">
<div class="modal-header">
<h2 class="modal-title">Edit Resource</h2>
<button class="modal-close" onclick="closeEditModal()">×</button>
</div>
<!-- Hidden field that stores which resource is being edited -->
<!-- We read this id in actions.js when saving -->
<input type="hidden" id="edit-resource-id">
<!-- Show what type of resource this is (read-only info) -->
<div class="edit-resource-preview" id="edit-resource-preview"></div>
<div class="form-group">
<label class="form-label">Title *</label>
<input class="form-input" type="text" id="edit-inp-title" placeholder="Resource title">
</div>
<div class="form-row">
<div class="form-group" style="margin-bottom:0">
<label class="form-label">Category *
<!-- Small hint explaining they can change category here -->
<span class="form-hint">(you can change this!)</span>
</label>
<input
class="form-input"
type="text"
id="edit-inp-cat"
placeholder="e.g. DSA, React…"
list="edit-cat-list"
>
<datalist id="edit-cat-list"></datalist>
</div>
<div class="form-group" style="margin-bottom:0">
<label class="form-label">Importance</label>
<select class="form-select" id="edit-inp-importance">
<option value="normal">Normal</option>
<option value="important">⭐ Important</option>
<option value="critical">🔥 Critical</option>
</select>
</div>
</div>
<div class="form-group" style="margin-top:16px">
<label class="form-label">
Tags <span class="form-hint">(Enter or comma to add)</span>
</label>
<div class="tags-input-area" id="edit-tags-area" onclick="focusEditTagInput()">
<input class="tags-text-input" id="edit-tag-input" placeholder="Add a tag…" onkeydown="onEditTagKey(event)">
</div>
</div>
<button class="submit-btn" style="background:linear-gradient(135deg,#56d9a0,#38b082)" onclick="saveEditResource()">
Save Changes →
</button>
</div>
</div>
<!-- Toast notifications -->
<div class="toast-container" id="toast-container"></div>
<!-- JS files — ORDER MATTERS -->
<script src="js/data.js"></script>
<script src="js/render.js"></script>
<script src="js/actions.js"></script>
<script src="js/modal.js"></script>
<script src="js/ai.js"></script>
<script src="js/app.js"></script>
</body>
</html>