Spaces:
Running
Running
File size: 28,866 Bytes
c27acc4 b5b94fb d3790ad 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e 0e5cf35 6d77e9e c27acc4 b5b94fb c27acc4 7c6653c b5b94fb 77ed0b7 b5b94fb 7c6653c b5b94fb 1eac0d3 b5b94fb 7c6653c b5b94fb 7c6653c c27acc4 b5b94fb 0e5cf35 c27acc4 7c6653c b5b94fb 7c6653c b5b94fb 7c6653c b5b94fb 1eac0d3 7c6653c b5b94fb 7c6653c b5b94fb 7dfe2c3 7c6653c b5b94fb c27acc4 0e5cf35 1eac0d3 ff8268d 0e5cf35 1eac0d3 ff8268d 1eac0d3 7dfe2c3 1eac0d3 0e5cf35 7dfe2c3 ff8268d 7dfe2c3 ff8268d 0e5cf35 ff8268d c27acc4 7dfe2c3 ff8268d b5b94fb c27acc4 0e5cf35 ff8268d c27acc4 ff8268d 0e5cf35 ff8268d 7dfe2c3 c27acc4 ff8268d c27acc4 7dfe2c3 b5b94fb 77ed0b7 b5b94fb 7dfe2c3 0e5cf35 7dfe2c3 70c6ca9 7dfe2c3 b5b94fb 7dfe2c3 0e5cf35 7dfe2c3 b5b94fb 7dfe2c3 c27acc4 b5b94fb 7dfe2c3 b5b94fb 0e5cf35 b5b94fb 77ed0b7 0e5cf35 b5b94fb 0e5cf35 7dfe2c3 77ed0b7 7dfe2c3 1eac0d3 b5b94fb 7dfe2c3 b5b94fb 7dfe2c3 b5b94fb 7dfe2c3 ff8268d 7dfe2c3 b5b94fb 7dfe2c3 c27acc4 7dfe2c3 ff8268d 7dfe2c3 ff8268d 0e5cf35 b5b94fb 0e5cf35 7dfe2c3 0e5cf35 7dfe2c3 0e5cf35 7dfe2c3 1eac0d3 ff8268d 1eac0d3 42d2284 7dfe2c3 b5b94fb 1eac0d3 77ed0b7 c27acc4 |
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 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam Countdown</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600&family=Playfair+Display:wght@700&display=swap" rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--glass-bg: rgba(255, 255, 255, 0.03);
--glass-border: rgba(255, 255, 255, 0.08);
--text-primary: rgba(255, 255, 255, 0.95);
--text-secondary: rgba(255, 255, 255, 0.6);
--text-muted: rgba(255, 255, 255, 0.4);
}
body {
font-family: 'Lexend', sans-serif;
background: #000000;
min-height: 100vh;
color: var(--text-primary);
overflow-x: hidden;
position: relative;
}
/* Subtle animated gradient orbs */
body::before,
body::after {
content: '';
position: fixed;
border-radius: 50%;
filter: blur(150px);
opacity: 0.15;
animation: float 20s infinite ease-in-out;
pointer-events: none;
}
body::before {
width: 600px; height: 600px;
background: radial-gradient(circle, #ffffff 0%, transparent 70%);
top: -200px; right: -200px;
}
body::after {
width: 800px; height: 800px;
background: radial-gradient(circle, #ffffff 0%, transparent 70%);
bottom: -300px; left: -300px;
animation-delay: 10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); }
33% { transform: translate(30px, -30px) scale(1.1); }
66% { transform: translate(-20px, 20px) scale(0.9); }
}
/* Subtle particles */
.particles { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: 1; pointer-events: none; }
.particle { position: absolute; width: 1px; height: 1px; background: white; border-radius: 50%; opacity: 0; animation: twinkle 5s infinite; }
@keyframes twinkle {
0%, 100% { opacity: 0; transform: scale(0.5); }
50% { opacity: 0.8; transform: scale(1); }
}
/* Full-width container */
.container {
width: 100%;
max-width: none;
margin: 0 auto;
padding: 3rem 2rem;
position: relative;
z-index: 2;
}
/* Clean header */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5rem; padding-bottom: 2rem; position: relative; }
.header::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1) 20%, rgba(255, 255, 255, 0.1) 80%, transparent); }
h1 {
font-family: 'Lexend', sans-serif;
font-size: 2.5rem;
font-weight: 300;
letter-spacing: -1px;
background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.6) 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
/* Glass settings button */
.settings-btn { width: 50px; height: 50px; background: var(--glass-bg); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--glass-border); border-radius: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1); position: relative; overflow: hidden; }
.settings-btn::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0%, transparent 70%); opacity: 0; transition: opacity 0.3s ease; }
.settings-btn:hover { transform: scale(1.05); background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.2); }
.settings-btn:hover::before { opacity: 1; }
.settings-btn svg { width: 24px; height: 24px; fill: var(--text-primary); transition: transform 0.4s ease; }
.settings-btn:hover svg { transform: rotate(90deg); }
/* Glass exam grid (rectangular cards, auto height) */
.exams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2rem; grid-auto-rows: auto; align-items: start; }
/* Glassmorphic exam cards */
.exam-card { background: var(--glass-bg); backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%); border: 1px solid var(--glass-border); border-radius: 24px; padding: 2.5rem; text-align: center; transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1); position: relative; overflow: hidden; min-height: 220px; cursor: pointer; }
.exam-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2) 50%, transparent); opacity: 0; transition: opacity 0.3s ease; }
.exam-card::after { content: ''; position: absolute; inset: 0; background: radial-gradient( 600px circle at var(--mouse-x) var(--mouse-y), rgba(255, 255, 255, 0.06), transparent 40% ); opacity: 0; transition: opacity 0.3s ease; pointer-events: none; }
.exam-card:hover { transform: translateY(-5px); background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.15); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
.exam-card:hover::before, .exam-card:hover::after { opacity: 1; }
.exam-name {
font-size: 1.4rem;
font-weight: 400;
margin-bottom: 2rem;
color: var(--text-primary);
letter-spacing: -0.5px;
}
.countdown {
font-family: 'Playfair Display', serif;
font-size: 4.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
letter-spacing: -2px;
line-height: 1.1;
background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.7) 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.countdown-label { font-size: 0.85rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 2px; font-weight: 500; }
.exam-date { font-size: 0.9rem; color: var(--text-muted); margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(255, 255, 255, 0.05); }
/* Syllabus indicator badge */
.syllabus-badge {
position: absolute;
top: 1.5rem;
left: 1.5rem;
padding: 0.4rem 0.8rem;
background: rgba(255, 255, 255, 0.08);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
font-size: 0.7rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 1px;
display: flex;
align-items: center;
gap: 0.4rem;
opacity: 0;
transition: opacity 0.3s ease;
}
.syllabus-badge.has-syllabus {
opacity: 1;
background: rgba(100, 200, 100, 0.15);
border-color: rgba(100, 200, 100, 0.3);
color: rgba(150, 255, 150, 0.9);
}
.exam-card:hover .syllabus-badge {
opacity: 1;
}
.syllabus-badge svg {
width: 12px;
height: 12px;
fill: currentColor;
}
/* Click hint */
.click-hint {
position: absolute;
bottom: 1rem;
left: 50%;
transform: translateX(-50%);
font-size: 0.7rem;
color: var(--text-muted);
opacity: 0;
transition: opacity 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.exam-card:hover .click-hint {
opacity: 0.6;
}
/* Minimal delete button */
.delete-btn { position: absolute; top: 1.5rem; right: 1.5rem; width: 32px; height: 32px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; opacity: 0; z-index: 10; }
.exam-card:hover .delete-btn { opacity: 1; }
.delete-btn:hover { background: rgba(255, 100, 100, 0.15); border-color: rgba(255, 100, 100, 0.3); transform: scale(1.1); }
.delete-btn svg { width: 16px; height: 16px; fill: var(--text-secondary); transition: fill 0.3s ease; pointer-events: none; }
.delete-btn:hover svg { fill: rgba(255, 150, 150, 1); }
/* Glass modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1000; align-items: center; justify-content: center; padding: 2rem; opacity: 0; transition: opacity 0.3s ease; }
.modal.active { display: flex; opacity: 1; }
.modal-content { background: rgba(255, 255, 255, 0.03); backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 24px; padding: 3rem; width: 100%; max-width: 450px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1); animation: modalSlide 0.4s cubic-bezier(0.23, 1, 0.320, 1); }
/* Syllabus modal is wider */
.modal-content.syllabus-modal-content {
max-width: 650px;
max-height: 85vh;
overflow-y: auto;
}
@keyframes modalSlide { from { transform: translateY(-20px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.modal-title { font-family: 'Lexend', sans-serif; font-size: 1.5rem; font-weight: 400; letter-spacing: -0.5px; }
.modal-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.close-btn { width: 36px; height: 36px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; flex-shrink: 0; }
.close-btn:hover { background: rgba(255, 255, 255, 0.08); transform: rotate(90deg); }
.close-btn svg { width: 18px; height: 18px; fill: var(--text-secondary); }
/* Clean form */
.form-group { margin-bottom: 2rem; }
.form-group label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.5px; }
.form-group input,
.form-group textarea {
width: 100%;
padding: 1rem 1.25rem;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
color: var(--text-primary);
font-size: 1rem;
transition: all 0.3s ease;
font-family: 'Lexend', sans-serif;
}
.form-group textarea {
resize: vertical;
min-height: 200px;
line-height: 1.7;
}
.form-group input:focus,
.form-group textarea:focus {
outline: none;
background: rgba(255, 255, 255, 0.05);
border-color: rgba(255, 255, 255, 0.2);
box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
color: var(--text-muted);
}
/* Syllabus tips */
.syllabus-tips {
background: rgba(255, 255, 255, 0.02);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 1.25rem;
margin-bottom: 2rem;
}
.syllabus-tips-title {
font-size: 0.8rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 0.75rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.syllabus-tips-title svg {
width: 14px;
height: 14px;
fill: var(--text-secondary);
}
.syllabus-tips ul {
list-style: none;
font-size: 0.85rem;
color: var(--text-muted);
line-height: 1.8;
}
.syllabus-tips li::before {
content: 'β';
margin-right: 0.5rem;
color: var(--text-secondary);
}
/* Sleek add button */
.add-btn { width: 100%; padding: 1.25rem; background: rgba(255, 255, 255, 0.95); border: none; border-radius: 12px; color: #000; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s cubic-bezier(0.23, 1, 0.320, 1); position: relative; overflow: hidden; letter-spacing: 0.5px; }
.add-btn:hover { transform: translateY(-2px); background: white; box-shadow: 0 10px 30px rgba(255, 255, 255, 0.2), 0 1px 0 rgba(255, 255, 255, 0.2); }
.add-btn:active { transform: translateY(0); }
/* Saved indicator */
.saved-indicator {
display: none;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 1rem;
background: rgba(100, 200, 100, 0.1);
border: 1px solid rgba(100, 200, 100, 0.2);
border-radius: 12px;
color: rgba(150, 255, 150, 0.9);
font-size: 0.9rem;
margin-top: 1rem;
animation: fadeIn 0.3s ease;
}
.saved-indicator.show {
display: flex;
}
.saved-indicator svg {
width: 18px;
height: 18px;
fill: currentColor;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Elegant empty state */
.empty-state { text-align: center; padding: 6rem 2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.empty-icon { width: 80px; height: 80px; margin-bottom: 2rem; background: var(--glass-bg); backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.empty-state p { font-size: 1.1rem; color: var(--text-secondary); max-width: 400px; line-height: 1.6; font-weight: 300; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }
/* Enhanced scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
/* Responsive tweaks */
@media (max-width: 768px) {
h1 { font-size: 2rem; }
.countdown { font-size: 3.5rem; }
.exams-grid { grid-template-columns: 1fr; }
.container { padding: 2rem 1rem; }
.modal-content.syllabus-modal-content { max-width: 100%; }
}
</style>
</head>
<body>
<div class="particles" id="particles"></div>
<div class="container">
<div class="header">
<h1>Exam Countdown</h1>
<div class="settings-btn" id="openModalBtn">
<svg viewBox="0 0 24 24">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"/>
</svg>
</div>
</div>
<div class="exams-grid" id="examsGrid"></div>
<div class="empty-state" id="emptyState" style="display: none;">
<div class="empty-icon">π</div>
<p>No exams scheduled yet. Add your first exam to start tracking.</p>
</div>
</div>
<!-- Add Exam Modal -->
<div class="modal" id="modal">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Add New Exam</h2>
<button class="close-btn" id="closeModalBtn">
<svg viewBox="0 0 24 24">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
</svg>
</button>
</div>
<form id="addExamForm">
<div class="form-group">
<label for="examName">Exam Name</label>
<input type="text" id="examName" required placeholder="e.g., Mathematics Final">
</div>
<div class="form-group">
<label for="examDate">Exam Date</label>
<input type="date" id="examDate" required>
</div>
<button type="submit" class="add-btn">Add Exam</button>
</form>
</div>
</div>
<!-- Syllabus Modal -->
<div class="modal" id="syllabusModal">
<div class="modal-content syllabus-modal-content">
<div class="modal-header">
<div>
<h2 class="modal-title" id="syllabusExamName">Exam Syllabus</h2>
<p class="modal-subtitle" id="syllabusExamDate"></p>
</div>
<button class="close-btn" id="closeSyllabusModalBtn">
<svg viewBox="0 0 24 24">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
</svg>
</button>
</div>
<form id="syllabusForm">
<div class="form-group">
<label for="syllabusContent">Syllabus / Topics to Study</label>
<textarea id="syllabusContent" rows="12" placeholder="Enter your syllabus here...
Example:
Chapter 1: Introduction to Calculus
- Limits and Continuity (pg 1-25)
- Derivatives (pg 26-50) β
Chapter 2: Integration
- Definite Integrals (pg 51-75)
- Applications (pg 76-100)
Important Formulas:
- d/dx(x^n) = nx^(n-1)
- β«x^n dx = x^(n+1)/(n+1) + C"></textarea>
</div>
<input type="hidden" id="syllabusExamId">
<button type="submit" class="add-btn">Save Syllabus</button>
<div class="saved-indicator" id="savedIndicator">
<svg viewBox="0 0 24 24">
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
</svg>
Syllabus saved successfully!
</div>
</form>
</div>
</div>
<script type="module">
// Firebase SDK modules
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
import { getDatabase, ref, onValue, push, remove, update } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyCBGYdGdPjYJiKsTMjVYZ9mf9F82ns7g4Q",
authDomain: "pikachu-rxppbp.firebaseapp.com",
databaseURL: "https://pikachu-rxppbp.firebaseio.com",
projectId: "pikachu-rxppbp",
storageBucket: "pikachu-rxppbp.appspot.com",
messagingSenderId: "241970333280",
appId: "1:241970333280:web:704e8930bd591c138d6505"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
const examsRef = ref(database, 'exams');
// Store exams data globally for easy access
let examsData = [];
// DOM Elements
const elements = {
modal: document.getElementById('modal'),
openModalBtn: document.getElementById('openModalBtn'),
closeModalBtn: document.getElementById('closeModalBtn'),
addExamForm: document.getElementById('addExamForm'),
examNameInput: document.getElementById('examName'),
examDateInput: document.getElementById('examDate'),
examsGrid: document.getElementById('examsGrid'),
emptyState: document.getElementById('emptyState'),
particlesContainer: document.getElementById('particles'),
// Syllabus modal elements
syllabusModal: document.getElementById('syllabusModal'),
closeSyllabusModalBtn: document.getElementById('closeSyllabusModalBtn'),
syllabusForm: document.getElementById('syllabusForm'),
syllabusExamName: document.getElementById('syllabusExamName'),
syllabusExamDate: document.getElementById('syllabusExamDate'),
syllabusContent: document.getElementById('syllabusContent'),
syllabusExamId: document.getElementById('syllabusExamId'),
savedIndicator: document.getElementById('savedIndicator')
};
// --- Core Functions ---
const openModal = () => elements.modal.classList.add('active');
const closeModal = () => {
elements.modal.classList.remove('active');
elements.addExamForm.reset();
};
const openSyllabusModal = (examId) => {
const exam = examsData.find(e => e.id === examId);
if (!exam) return;
elements.syllabusExamName.textContent = exam.name;
const dateObject = new Date(exam.date);
elements.syllabusExamDate.textContent = dateObject.toLocaleDateString('en-US', {
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
});
elements.syllabusContent.value = exam.syllabus || '';
elements.syllabusExamId.value = examId;
elements.savedIndicator.classList.remove('show');
elements.syllabusModal.classList.add('active');
};
const closeSyllabusModal = () => {
elements.syllabusModal.classList.remove('active');
elements.savedIndicator.classList.remove('show');
};
const saveSyllabus = (event) => {
event.preventDefault();
const examId = elements.syllabusExamId.value;
const syllabusContent = elements.syllabusContent.value;
// Update the syllabus in Firebase
const examRef = ref(database, `exams/${examId}`);
update(examRef, { syllabus: syllabusContent })
.then(() => {
elements.savedIndicator.classList.add('show');
setTimeout(() => {
elements.savedIndicator.classList.remove('show');
}, 3000);
})
.catch((error) => {
console.error("Error saving syllabus:", error);
alert("Failed to save syllabus. Please try again.");
});
};
const addExam = (event) => {
event.preventDefault();
const newExam = {
name: elements.examNameInput.value,
date: new Date(elements.examDateInput.value).getTime(),
syllabus: ''
};
push(examsRef, newExam);
closeModal();
};
const deleteExam = (id) => remove(ref(database, `exams/${id}`));
// --- Rendering Logic ---
const calculateCountdown = (examDate) => {
const now = new Date();
now.setHours(0, 0, 0, 0);
const targetDate = new Date(examDate);
targetDate.setHours(0, 0, 0, 0);
const diff = targetDate.getTime() - now.getTime();
const days = Math.ceil(diff / (1000 * 60 * 60 * 24));
if (days < 0) {
return { days: 'β', label: 'COMPLETED' };
}
return { days, label: days === 1 ? 'DAY LEFT' : 'DAYS LEFT' };
};
const renderExams = (exams) => {
examsData = exams; // Store for later access
const hasExams = exams && exams.length > 0;
elements.examsGrid.style.display = hasExams ? 'grid' : 'none';
elements.emptyState.style.display = hasExams ? 'none' : 'flex';
if (!hasExams) return;
exams.sort((a, b) => new Date(a.date) - new Date(b.date));
elements.examsGrid.innerHTML = exams.map(exam => {
const countdown = calculateCountdown(exam.date);
const dateObject = new Date(exam.date);
const hasSyllabus = exam.syllabus && exam.syllabus.trim().length > 0;
return `
<div class="exam-card" data-exam-id="${exam.id}">
<button class="delete-btn" data-delete-id="${exam.id}">
<svg viewBox="0 0 24 24">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
</svg>
</button>
<div class="exam-name">${exam.name}</div>
<div class="countdown">${countdown.days}</div>
<div class="countdown-label">${countdown.label}</div>
<div class="exam-date">${dateObject.toLocaleDateString('en-US', {
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
})}</div>
<div class="click-hint">Click to ${hasSyllabus ? 'view' : 'add'} syllabus</div>
</div>`;
}).join('');
};
// --- Visual Effects ---
function createParticles() {
const particleCount = 50;
let particleHtml = '';
for (let i = 0; i < particleCount; i++) {
const delay = Math.random() * 5;
const duration = 5 + Math.random() * 5;
const style = `
left: ${Math.random() * 100}%;
top: ${Math.random() * 100}%;
animation-delay: ${delay}s;
animation-duration: ${duration}s;
`;
particleHtml += `<div class="particle" style="${style}"></div>`;
}
elements.particlesContainer.innerHTML = particleHtml;
}
document.addEventListener('mousemove', (e) => {
document.querySelectorAll('.exam-card').forEach(card => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
card.style.setProperty('--mouse-x', `${x}px`);
card.style.setProperty('--mouse-y', `${y}px`);
});
});
// --- App Initialization & Event Listeners ---
createParticles();
elements.examDateInput.min = new Date().toISOString().split('T')[0];
// Modal Listeners
elements.openModalBtn.addEventListener('click', openModal);
elements.closeModalBtn.addEventListener('click', closeModal);
elements.addExamForm.addEventListener('submit', addExam);
window.addEventListener('click', e => {
if (e.target === elements.modal) closeModal();
if (e.target === elements.syllabusModal) closeSyllabusModal();
});
// Syllabus Modal Listeners
elements.closeSyllabusModalBtn.addEventListener('click', closeSyllabusModal);
elements.syllabusForm.addEventListener('submit', saveSyllabus);
// Exam card click listener (using event delegation)
elements.examsGrid.addEventListener('click', (event) => {
const deleteBtn = event.target.closest('.delete-btn');
if (deleteBtn) {
event.stopPropagation();
deleteExam(deleteBtn.dataset.deleteId);
return;
}
const examCard = event.target.closest('.exam-card');
if (examCard) {
const examId = examCard.dataset.examId;
openSyllabusModal(examId);
}
});
// Firebase real-time data listener
onValue(examsRef, (snapshot) => {
const data = snapshot.val();
const examList = data ? Object.entries(data).map(([id, value]) => ({ id, ...value })) : [];
renderExams(examList);
}, (error) => {
console.error("Firebase read failed:", error);
alert("Could not connect to the database. Please check your configuration.");
});
</script>
</body>
</html> |