Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Neon Exam Countdown</title> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet"> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { font-family: 'Inter', sans-serif; background: linear-gradient(135deg, #0A0A0B 0%, #141419 100%); min-height: 100vh; color: #fff; overflow-x: hidden; position: relative; } | |
| .particles { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: 1; } | |
| .particle { position: absolute; width: 4px; height: 4px; background: radial-gradient(circle, rgba(0, 212, 255, 0.5) 0%, transparent 70%); border-radius: 50%; animation: float 20s infinite linear; } | |
| @keyframes float { from { transform: translateY(100vh) translateX(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } to { transform: translateY(-100vh) translateX(100px); opacity: 0; } } | |
| .container { max-width: 1200px; margin: 0 auto; padding: 2rem; position: relative; z-index: 2; } | |
| .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3rem; } | |
| h1 { font-size: 2.5rem; font-weight: 700; background: linear-gradient(135deg, #00D4FF 0%, #FF0080 50%, #00FF88 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-shadow: 0 0 30px rgba(0, 212, 255, 0.5); } | |
| .settings-btn { width: 50px; height: 50px; background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; } | |
| .settings-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: #00D4FF; box-shadow: 0 0 20px rgba(0, 212, 255, 0.5); transform: scale(1.05); } | |
| .settings-btn svg { width: 24px; height: 24px; fill: #00D4FF; } | |
| .exams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; } | |
| .exam-card { background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 2rem; text-align: center; transition: all 0.3s ease; position: relative; overflow: hidden; } | |
| .exam-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3); } | |
| .exam-name { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; color: #fff; } | |
| .countdown { font-size: 3rem; font-weight: 700; text-shadow: 0 0 20px rgba(0, 212, 255, 0.8); margin-bottom: 0.5rem; } | |
| .countdown-label { font-size: 1rem; color: rgba(255, 255, 255, 0.7); } | |
| .exam-date { font-size: 0.9rem; color: rgba(255, 255, 255, 0.5); margin-top: 1rem; } | |
| .delete-btn { position: absolute; top: 1rem; right: 1rem; width: 30px; height: 30px; background: rgba(255, 0, 128, 0.2); border: 1px solid rgba(255, 0, 128, 0.5); border-radius: 8px; 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, 0, 128, 0.4); transform: scale(1.1); } | |
| .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 1000; align-items: center; justify-content: center; padding: 2rem; } | |
| .modal.active { display: flex; } | |
| .modal-content { background: rgba(20, 20, 25, 0.95); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); } | |
| .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; } | |
| .modal-title { font-size: 1.5rem; font-weight: 600; } | |
| .close-btn { width: 30px; height: 30px; background: transparent; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.3s ease; } | |
| .close-btn:hover { transform: rotate(90deg); } | |
| .add-btn { width: 100%; padding: 1rem; background: linear-gradient(135deg, #00D4FF 0%, #FF0080 100%); border: none; border-radius: 10px; color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; } | |
| .add-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(0, 212, 255, 0.5); } | |
| .empty-state { text-align: center; padding: 4rem 2rem; } | |
| .empty-state p { font-size: 1.2rem; color: rgba(255, 255, 255, 0.5); margin-bottom: 2rem; } | |
| </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;"><p>No exams scheduled yet. Click the + button to add your first exam!</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 width="24" height="24" viewBox="0 0 24 24" fill="#fff"><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., Physics 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 and Database | |
| const app = initializeApp(firebaseConfig); | |
| const database = getDatabase(app); | |
| const examsRef = ref(database, 'exams'); | |
| // DOM Element References | |
| const elements = { | |
| openModalBtn: document.getElementById('openModalBtn'), | |
| closeModalBtn: document.getElementById('closeModalBtn'), | |
| modal: document.getElementById('modal'), | |
| 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(); | |
| const newExam = { | |
| name: elements.examNameInput.value, | |
| date: elements.examDateInput.value | |
| }; | |
| push(examsRef, newExam).catch(err => console.error("Failed to add exam:", err)); | |
| closeModal(); | |
| }; | |
| const deleteExam = (id) => { | |
| if (!id) return; | |
| remove(ref(database, `exams/${id}`)).catch(err => console.error("Failed to delete exam:", err)); | |
| }; | |
| // --- Rendering --- | |
| const calculateDaysUntil = (examDate) => { | |
| const today = new Date(); | |
| today.setHours(0, 0, 0, 0); // Normalize to midnight | |
| return Math.ceil((new Date(examDate) - today) / 86400000); // 1000*60*60*24 | |
| }; | |
| const renderExams = (exams) => { | |
| elements.examsGrid.innerHTML = ''; | |
| const hasExams = exams && exams.length > 0; | |
| elements.emptyState.style.display = hasExams ? 'none' : 'block'; | |
| if (!hasExams) return; | |
| exams.sort((a, b) => new Date(a.date) - new Date(b.date)).forEach(exam => { | |
| const daysUntil = calculateDaysUntil(exam.date); | |
| const card = document.createElement('div'); | |
| card.className = 'exam-card'; | |
| const color = daysUntil <= 3 ? '#FF0080' : (daysUntil <= 7 ? '#00FF88' : '#00D4FF'); | |
| card.innerHTML = ` | |
| <div class="delete-btn" title="Delete Exam"><svg width="16" height="16" viewBox="0 0 24 24" fill="#FF0080"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg></div> | |
| <h3 class="exam-name">${exam.name}</h3> | |
| <div class="countdown" style="color: ${color};">${daysUntil}</div> | |
| <div class="countdown-label">days remaining</div> | |
| <div class="exam-date">${new Date(exam.date).toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}</div>`; | |
| card.querySelector('.delete-btn').addEventListener('click', () => deleteExam(exam.id)); | |
| elements.examsGrid.appendChild(card); | |
| }); | |
| }; | |
| // --- Particle Effect --- | |
| const createParticles = () => { | |
| if (elements.particlesContainer.children.length > 0) return; | |
| let particleHtml = ''; | |
| for (let i = 0; i < 50; i++) { | |
| const style = `left:${Math.random()*100}%;animation-delay:${Math.random()*20}s;animation-duration:${15+Math.random()*10}s;`; | |
| particleHtml += `<div class="particle" style="${style}"></div>`; | |
| } | |
| elements.particlesContainer.innerHTML = particleHtml; | |
| }; | |
| // =================================================================================== | |
| // START: ONE-TIME MANUAL IMPORT FUNCTION | |
| // TO USE: Open developer console (F12) and type `runManualImport()` then press Enter. | |
| // AFTER RUNNING ONCE, DELETE THIS ENTIRE FUNCTION FROM YOUR CODE. | |
| // =================================================================================== | |
| window.runManualImport = function() { | |
| const data = [{"name":"NSEA","date":"2025-11-22"},{"name":"NSEP","date":"2025-11-23"},{"name":"IMO ","date":"2025-11-28"},{"name":"NSO ","date":"2025-12-11"},{"name":"IEO ","date":"2025-11-26"},{"name":"Mathematics Boards","date":"2026-02-17"},{"name":"Science Boards","date":"2026-02-25"},{"name":"ISSO ","date":"2025-11-20"},{"name":"Periodic Test 2","date":"2025-11-03"},{"name":"Pre-Boards 2 ","date":"2026-01-19"},{"name":"Pre-Boards 1","date":"2025-12-29"},{"name":"English Boards","date":"2026-02-21"},{"name":"IT Boards","date":"2026-02-27"},{"name":"Hindi Boards","date":"2026-03-02"},{"name":"Social Science Boards","date":"2026-03-07"}]; | |
| console.log(`Starting import of ${data.length} exams...`); | |
| const promises = data.map(exam => push(examsRef, { name: exam.name, date: exam.date })); | |
| Promise.all(promises) | |
| .then(() => alert(`Successfully imported ${data.length} exams to Firebase.`)) | |
| .catch(err => console.error("IMPORT FAILED:", err)); | |
| }; | |
| // =================================================================================== | |
| // END OF IMPORT FUNCTION - REMOVE AFTER USE | |
| // =================================================================================== | |
| // --- App Initialization --- | |
| createParticles(); | |
| elements.examDateInput.min = new Date().toISOString().split('T')[0]; | |
| // Event 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(); }); | |
| // 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. Check console for errors and verify database rules."); | |
| }); | |
| </script> | |
| </body> | |
| </html> |