Spaces:
Running
Running
Update index.html
Browse files- index.html +82 -73
index.html
CHANGED
|
@@ -19,11 +19,9 @@
|
|
| 19 |
.settings-btn svg { width: 24px; height: 24px; fill: #00D4FF; }
|
| 20 |
.exams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
|
| 21 |
.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; }
|
| 22 |
-
.exam-card::before { content: ''; position: absolute; top: -2px; left: -2px; right: -2px; bottom: -2px; background: linear-gradient(45deg, #00D4FF, #FF0080, #00FF88, #00D4FF); border-radius: 20px; opacity: 0; z-index: -1; transition: opacity 0.3s ease; }
|
| 23 |
.exam-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3); }
|
| 24 |
-
.exam-card:hover::before { opacity: 0.5; }
|
| 25 |
.exam-name { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; color: #fff; }
|
| 26 |
-
.countdown { font-size: 3rem; font-weight: 700;
|
| 27 |
.countdown-label { font-size: 1rem; color: rgba(255, 255, 255, 0.7); }
|
| 28 |
.exam-date { font-size: 0.9rem; color: rgba(255, 255, 255, 0.5); margin-top: 1rem; }
|
| 29 |
.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; }
|
|
@@ -36,15 +34,10 @@
|
|
| 36 |
.modal-title { font-size: 1.5rem; font-weight: 600; }
|
| 37 |
.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; }
|
| 38 |
.close-btn:hover { transform: rotate(90deg); }
|
| 39 |
-
.form-group { margin-bottom: 1.5rem; }
|
| 40 |
-
label { display: block; margin-bottom: 0.5rem; color: rgba(255, 255, 255, 0.8); font-size: 0.9rem; }
|
| 41 |
-
input { width: 100%; padding: 0.75rem 1rem; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 10px; color: #fff; font-size: 1rem; transition: all 0.3s ease; }
|
| 42 |
-
input:focus { outline: none; border-color: #00D4FF; box-shadow: 0 0 10px rgba(0, 212, 255, 0.5); }
|
| 43 |
.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; }
|
| 44 |
.add-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(0, 212, 255, 0.5); }
|
| 45 |
.empty-state { text-align: center; padding: 4rem 2rem; }
|
| 46 |
.empty-state p { font-size: 1.2rem; color: rgba(255, 255, 255, 0.5); margin-bottom: 2rem; }
|
| 47 |
-
@media (max-width: 768px) { h1 { font-size: 2rem; } .exams-grid { grid-template-columns: 1fr; } .countdown { font-size: 2.5rem; } }
|
| 48 |
</style>
|
| 49 |
</head>
|
| 50 |
<body>
|
|
@@ -66,9 +59,11 @@
|
|
| 66 |
</div>
|
| 67 |
|
| 68 |
<script type="module">
|
| 69 |
-
|
| 70 |
-
import {
|
|
|
|
| 71 |
|
|
|
|
| 72 |
const firebaseConfig = {
|
| 73 |
apiKey: "AIzaSyCBGYdGdPjYJiKsTMjVYZ9mf9F82ns7g4Q",
|
| 74 |
authDomain: "pikachu-rxppbp.firebaseapp.com",
|
|
@@ -79,109 +74,123 @@
|
|
| 79 |
appId: "1:241970333280:web:704e8930bd591c138d6505"
|
| 80 |
};
|
| 81 |
|
|
|
|
| 82 |
const app = initializeApp(firebaseConfig);
|
| 83 |
const database = getDatabase(app);
|
| 84 |
const examsRef = ref(database, 'exams');
|
| 85 |
|
| 86 |
-
|
| 87 |
-
const
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
p.className = 'particle';
|
| 99 |
-
p.style.left = `${Math.random() * 100}%`;
|
| 100 |
-
p.style.animationDelay = `${Math.random() * 20}s`;
|
| 101 |
-
p.style.animationDuration = `${15 + Math.random() * 10}s`;
|
| 102 |
-
container.appendChild(p);
|
| 103 |
-
}
|
| 104 |
-
}
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
event.preventDefault();
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
closeModal();
|
| 113 |
-
}
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
|
|
|
|
| 118 |
const today = new Date();
|
| 119 |
-
today.setHours(0, 0, 0, 0);
|
| 120 |
-
return Math.ceil((new Date(examDate) - today) / 86400000);
|
| 121 |
-
}
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
const
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
if (!examsList) return;
|
| 129 |
|
| 130 |
-
|
| 131 |
const daysUntil = calculateDaysUntil(exam.date);
|
| 132 |
const card = document.createElement('div');
|
| 133 |
card.className = 'exam-card';
|
| 134 |
const color = daysUntil <= 3 ? '#FF0080' : (daysUntil <= 7 ? '#00FF88' : '#00D4FF');
|
| 135 |
|
| 136 |
card.innerHTML = `
|
| 137 |
-
<div class="delete-btn"><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>
|
| 138 |
<h3 class="exam-name">${exam.name}</h3>
|
| 139 |
-
<div class="countdown" style="color: ${color};
|
| 140 |
<div class="countdown-label">days remaining</div>
|
| 141 |
<div class="exam-date">${new Date(exam.date).toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}</div>`;
|
| 142 |
|
| 143 |
card.querySelector('.delete-btn').addEventListener('click', () => deleteExam(exam.id));
|
| 144 |
-
|
| 145 |
});
|
| 146 |
-
}
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
// ===================================================================================
|
| 149 |
// START: ONE-TIME MANUAL IMPORT FUNCTION
|
| 150 |
// TO USE: Open developer console (F12) and type `runManualImport()` then press Enter.
|
| 151 |
-
// AFTER RUNNING ONCE, DELETE THIS ENTIRE FUNCTION.
|
| 152 |
// ===================================================================================
|
| 153 |
window.runManualImport = function() {
|
| 154 |
-
const
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
Promise.all(importPromises)
|
| 161 |
-
.then(() => {
|
| 162 |
-
console.log("SUCCESS: All exams have been imported to Firebase.");
|
| 163 |
-
alert("Import complete! Your data is now in Firebase. You can now delete the `runManualImport` function from your code.");
|
| 164 |
-
})
|
| 165 |
-
.catch(error => {
|
| 166 |
-
console.error("IMPORT FAILED:", error);
|
| 167 |
-
alert("An error occurred during import. Check the console for details.");
|
| 168 |
-
});
|
| 169 |
};
|
| 170 |
// ===================================================================================
|
| 171 |
// END OF IMPORT FUNCTION - REMOVE AFTER USE
|
| 172 |
// ===================================================================================
|
| 173 |
|
|
|
|
| 174 |
createParticles();
|
| 175 |
-
examDateInput.min = new Date().toISOString().split('T')[0];
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
|
|
|
|
| 181 |
onValue(examsRef, (snapshot) => {
|
| 182 |
const data = snapshot.val();
|
| 183 |
-
const
|
| 184 |
-
renderExams(
|
|
|
|
|
|
|
|
|
|
| 185 |
});
|
| 186 |
</script>
|
| 187 |
</body>
|
|
|
|
| 19 |
.settings-btn svg { width: 24px; height: 24px; fill: #00D4FF; }
|
| 20 |
.exams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
|
| 21 |
.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; }
|
|
|
|
| 22 |
.exam-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3); }
|
|
|
|
| 23 |
.exam-name { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; color: #fff; }
|
| 24 |
+
.countdown { font-size: 3rem; font-weight: 700; text-shadow: 0 0 20px rgba(0, 212, 255, 0.8); margin-bottom: 0.5rem; }
|
| 25 |
.countdown-label { font-size: 1rem; color: rgba(255, 255, 255, 0.7); }
|
| 26 |
.exam-date { font-size: 0.9rem; color: rgba(255, 255, 255, 0.5); margin-top: 1rem; }
|
| 27 |
.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; }
|
|
|
|
| 34 |
.modal-title { font-size: 1.5rem; font-weight: 600; }
|
| 35 |
.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; }
|
| 36 |
.close-btn:hover { transform: rotate(90deg); }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
.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; }
|
| 38 |
.add-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(0, 212, 255, 0.5); }
|
| 39 |
.empty-state { text-align: center; padding: 4rem 2rem; }
|
| 40 |
.empty-state p { font-size: 1.2rem; color: rgba(255, 255, 255, 0.5); margin-bottom: 2rem; }
|
|
|
|
| 41 |
</style>
|
| 42 |
</head>
|
| 43 |
<body>
|
|
|
|
| 59 |
</div>
|
| 60 |
|
| 61 |
<script type="module">
|
| 62 |
+
// Firebase SDK modules
|
| 63 |
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
|
| 64 |
+
import { getDatabase, ref, onValue, push, remove } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js";
|
| 65 |
|
| 66 |
+
// Your web app's Firebase configuration
|
| 67 |
const firebaseConfig = {
|
| 68 |
apiKey: "AIzaSyCBGYdGdPjYJiKsTMjVYZ9mf9F82ns7g4Q",
|
| 69 |
authDomain: "pikachu-rxppbp.firebaseapp.com",
|
|
|
|
| 74 |
appId: "1:241970333280:web:704e8930bd591c138d6505"
|
| 75 |
};
|
| 76 |
|
| 77 |
+
// Initialize Firebase and Database
|
| 78 |
const app = initializeApp(firebaseConfig);
|
| 79 |
const database = getDatabase(app);
|
| 80 |
const examsRef = ref(database, 'exams');
|
| 81 |
|
| 82 |
+
// DOM Element References
|
| 83 |
+
const elements = {
|
| 84 |
+
openModalBtn: document.getElementById('openModalBtn'),
|
| 85 |
+
closeModalBtn: document.getElementById('closeModalBtn'),
|
| 86 |
+
modal: document.getElementById('modal'),
|
| 87 |
+
addExamForm: document.getElementById('addExamForm'),
|
| 88 |
+
examNameInput: document.getElementById('examName'),
|
| 89 |
+
examDateInput: document.getElementById('examDate'),
|
| 90 |
+
examsGrid: document.getElementById('examsGrid'),
|
| 91 |
+
emptyState: document.getElementById('emptyState'),
|
| 92 |
+
particlesContainer: document.getElementById('particles')
|
| 93 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
// --- Core Functions ---
|
| 96 |
+
const openModal = () => elements.modal.classList.add('active');
|
| 97 |
+
const closeModal = () => {
|
| 98 |
+
elements.modal.classList.remove('active');
|
| 99 |
+
elements.addExamForm.reset();
|
| 100 |
+
};
|
| 101 |
|
| 102 |
+
const addExam = (event) => {
|
| 103 |
event.preventDefault();
|
| 104 |
+
const newExam = {
|
| 105 |
+
name: elements.examNameInput.value,
|
| 106 |
+
date: elements.examDateInput.value
|
| 107 |
+
};
|
| 108 |
+
push(examsRef, newExam).catch(err => console.error("Failed to add exam:", err));
|
| 109 |
closeModal();
|
| 110 |
+
};
|
| 111 |
|
| 112 |
+
const deleteExam = (id) => {
|
| 113 |
+
if (!id) return;
|
| 114 |
+
remove(ref(database, `exams/${id}`)).catch(err => console.error("Failed to delete exam:", err));
|
| 115 |
+
};
|
| 116 |
|
| 117 |
+
// --- Rendering ---
|
| 118 |
+
const calculateDaysUntil = (examDate) => {
|
| 119 |
const today = new Date();
|
| 120 |
+
today.setHours(0, 0, 0, 0); // Normalize to midnight
|
| 121 |
+
return Math.ceil((new Date(examDate) - today) / 86400000); // 1000*60*60*24
|
| 122 |
+
};
|
| 123 |
|
| 124 |
+
const renderExams = (exams) => {
|
| 125 |
+
elements.examsGrid.innerHTML = '';
|
| 126 |
+
const hasExams = exams && exams.length > 0;
|
| 127 |
+
elements.emptyState.style.display = hasExams ? 'none' : 'block';
|
| 128 |
+
if (!hasExams) return;
|
|
|
|
| 129 |
|
| 130 |
+
exams.sort((a, b) => new Date(a.date) - new Date(b.date)).forEach(exam => {
|
| 131 |
const daysUntil = calculateDaysUntil(exam.date);
|
| 132 |
const card = document.createElement('div');
|
| 133 |
card.className = 'exam-card';
|
| 134 |
const color = daysUntil <= 3 ? '#FF0080' : (daysUntil <= 7 ? '#00FF88' : '#00D4FF');
|
| 135 |
|
| 136 |
card.innerHTML = `
|
| 137 |
+
<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>
|
| 138 |
<h3 class="exam-name">${exam.name}</h3>
|
| 139 |
+
<div class="countdown" style="color: ${color};">${daysUntil}</div>
|
| 140 |
<div class="countdown-label">days remaining</div>
|
| 141 |
<div class="exam-date">${new Date(exam.date).toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}</div>`;
|
| 142 |
|
| 143 |
card.querySelector('.delete-btn').addEventListener('click', () => deleteExam(exam.id));
|
| 144 |
+
elements.examsGrid.appendChild(card);
|
| 145 |
});
|
| 146 |
+
};
|
| 147 |
|
| 148 |
+
// --- Particle Effect ---
|
| 149 |
+
const createParticles = () => {
|
| 150 |
+
if (elements.particlesContainer.children.length > 0) return;
|
| 151 |
+
let particleHtml = '';
|
| 152 |
+
for (let i = 0; i < 50; i++) {
|
| 153 |
+
const style = `left:${Math.random()*100}%;animation-delay:${Math.random()*20}s;animation-duration:${15+Math.random()*10}s;`;
|
| 154 |
+
particleHtml += `<div class="particle" style="${style}"></div>`;
|
| 155 |
+
}
|
| 156 |
+
elements.particlesContainer.innerHTML = particleHtml;
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
// ===================================================================================
|
| 160 |
// START: ONE-TIME MANUAL IMPORT FUNCTION
|
| 161 |
// TO USE: Open developer console (F12) and type `runManualImport()` then press Enter.
|
| 162 |
+
// AFTER RUNNING ONCE, DELETE THIS ENTIRE FUNCTION FROM YOUR CODE.
|
| 163 |
// ===================================================================================
|
| 164 |
window.runManualImport = function() {
|
| 165 |
+
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"}];
|
| 166 |
+
console.log(`Starting import of ${data.length} exams...`);
|
| 167 |
+
const promises = data.map(exam => push(examsRef, { name: exam.name, date: exam.date }));
|
| 168 |
+
Promise.all(promises)
|
| 169 |
+
.then(() => alert(`Successfully imported ${data.length} exams to Firebase.`))
|
| 170 |
+
.catch(err => console.error("IMPORT FAILED:", err));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
};
|
| 172 |
// ===================================================================================
|
| 173 |
// END OF IMPORT FUNCTION - REMOVE AFTER USE
|
| 174 |
// ===================================================================================
|
| 175 |
|
| 176 |
+
// --- App Initialization ---
|
| 177 |
createParticles();
|
| 178 |
+
elements.examDateInput.min = new Date().toISOString().split('T')[0];
|
| 179 |
+
|
| 180 |
+
// Event Listeners
|
| 181 |
+
elements.openModalBtn.addEventListener('click', openModal);
|
| 182 |
+
elements.closeModalBtn.addEventListener('click', closeModal);
|
| 183 |
+
elements.addExamForm.addEventListener('submit', addExam);
|
| 184 |
+
window.addEventListener('click', e => { if (e.target === elements.modal) closeModal(); });
|
| 185 |
|
| 186 |
+
// Firebase real-time data listener
|
| 187 |
onValue(examsRef, (snapshot) => {
|
| 188 |
const data = snapshot.val();
|
| 189 |
+
const examList = data ? Object.entries(data).map(([id, value]) => ({ id, ...value })) : [];
|
| 190 |
+
renderExams(examList);
|
| 191 |
+
}, (error) => {
|
| 192 |
+
console.error("Firebase read failed:", error);
|
| 193 |
+
alert("Could not connect to the database. Check console for errors and verify database rules.");
|
| 194 |
});
|
| 195 |
</script>
|
| 196 |
</body>
|