Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Exam Countdown</title> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700;800&family=Poppins:wght@200;300;400;500;600;700;800&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); | |
| --accent: #ffffff; | |
| } | |
| body { | |
| font-family: 'Inter', 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); } | |
| } | |
| .container { | |
| max-width: 1200px; | |
| 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: 'Poppins', sans-serif; | |
| font-size: 2.5rem; | |
| font-weight: 200; | |
| 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 */ | |
| .exams-grid { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); | |
| gap: 2rem; | |
| } | |
| /* 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; | |
| } | |
| .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 { | |
| opacity: 1; | |
| } | |
| .exam-card:hover::after { | |
| opacity: 1; | |
| } | |
| .exam-name { | |
| font-family: 'Poppins', sans-serif; | |
| font-size: 1.4rem; | |
| font-weight: 300; | |
| margin-bottom: 2rem; | |
| color: var(--text-primary); | |
| letter-spacing: -0.5px; | |
| } | |
| .countdown { | |
| font-size: 3.5rem; | |
| font-weight: 200; | |
| margin-bottom: 0.5rem; | |
| letter-spacing: -2px; | |
| 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); | |
| } | |
| /* 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; | |
| } | |
| .exam-card:hover .delete-btn { | |
| opacity: 1; | |
| } | |
| .delete-btn:hover { | |
| background: rgba(255, 255, 255, 0.08); | |
| border-color: rgba(255, 255, 255, 0.2); | |
| transform: scale(1.1); | |
| } | |
| .delete-btn svg { | |
| width: 16px; | |
| height: 16px; | |
| fill: var(--text-secondary); | |
| transition: fill 0.3s ease; | |
| pointer-events: none; /* Important for event delegation */ | |
| } | |
| .delete-btn:hover svg { | |
| fill: var(--text-primary); | |
| } | |
| /* 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); | |
| } | |
| @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: 'Poppins', sans-serif; | |
| font-size: 1.5rem; | |
| font-weight: 300; | |
| letter-spacing: -0.5px; | |
| } | |
| .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; | |
| } | |
| .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 { | |
| 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: 'Inter', sans-serif; | |
| } | |
| .form-group input: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 { | |
| color: var(--text-muted); | |
| } | |
| /* 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); | |
| } | |
| /* 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 date styling for webkit browsers */ | |
| input[type="date"]::-webkit-calendar-picker-indicator { | |
| filter: invert(1); | |
| cursor: pointer; | |
| } | |
| /* Responsive */ | |
| @media (max-width: 768px) { | |
| h1 { font-size: 2rem; } | |
| .countdown { font-size: 2.5rem; } | |
| .exams-grid { grid-template-columns: 1fr; } | |
| .container { padding: 2rem 1rem; } | |
| } | |
| </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> | |
| <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> | |
| <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 } 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'); | |
| // 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') | |
| }; | |
| // --- Core Functions --- | |
| const openModal = () => elements.modal.classList.add('active'); | |
| const closeModal = () => { | |
| elements.modal.classList.remove('active'); | |
| elements.addExamForm.reset(); | |
| }; | |
| const addExam = (event) => { | |
| event.preventDefault(); | |
| // Save the date as a numeric timestamp for consistency and accuracy | |
| const newExam = { | |
| name: elements.examNameInput.value, | |
| date: new Date(elements.examDateInput.value).getTime() | |
| }; | |
| 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); // Set to midnight for accurate day comparison | |
| // This constructor handles both numbers (timestamps) and "YYYY-MM-DD" strings | |
| 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) => { | |
| const hasExams = exams && exams.length > 0; | |
| elements.examsGrid.style.display = hasExams ? 'grid' : 'none'; | |
| elements.emptyState.style.display = hasExams ? 'none' : 'flex'; | |
| if (!hasExams) return; | |
| // Sort by date so the soonest exam is first | |
| 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); // Works for both old and new data | |
| return ` | |
| <div class="exam-card"> | |
| <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>`; | |
| }).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(); }); | |
| // Delete button listener (using event delegation) | |
| elements.examsGrid.addEventListener('click', (event) => { | |
| const deleteBtn = event.target.closest('.delete-btn'); | |
| if (deleteBtn) { | |
| deleteExam(deleteBtn.dataset.deleteId); | |
| } | |
| }); | |
| // 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> |