Spaces:
Running
Running
Make a cool website to keep track of your tests and also when to start studying for them - Initial Deployment
e131a76 verified Download index.html from Administrator4321/test-tracker: direct link, hf CLI and curl.
- Browser
- Download file 38.8 kB
-
https://huggingface.co/spaces/Administrator4321/test-tracker/resolve/main/index.html
- Command line
-
hf download hf://spaces/Administrator4321/test-tracker/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Administrator4321/test-tracker/resolve/main/index.html
38.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ExamTrack - Test Tracker</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: '#4F46E5', | |
| secondary: '#10B981', | |
| danger: '#EF4444', | |
| warning: '#F59E0B' | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #4F46E5 0%, #10B981 100%); | |
| } | |
| .progress-bar { | |
| transition: width 0.5s ease-in-out; | |
| } | |
| .fade-in { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .card-hover:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen"> | |
| <!-- Header --> | |
| <header class="gradient-bg text-white shadow-lg"> | |
| <div class="container mx-auto px-4 py-6"> | |
| <div class="flex justify-between items-center"> | |
| <div class="flex items-center space-x-2"> | |
| <i class="fas fa-book-open text-2xl"></i> | |
| <h1 class="text-2xl font-bold">ExamTrack</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button id="theme-toggle" class="p-2 rounded-full bg-white bg-opacity-10 hover:bg-opacity-20 transition"> | |
| <i class="fas fa-moon"></i> | |
| </button> | |
| <div class="relative"> | |
| <img src="https://ui-avatars.com/api/?name=User&background=random" alt="User" class="w-10 h-10 rounded-full cursor-pointer"> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-8"> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-8"> | |
| <!-- Left Column --> | |
| <div class="lg:col-span-2 space-y-6"> | |
| <!-- Add Test Form --> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300 card-hover"> | |
| <div class="p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4">Add New Test</h2> | |
| <form id="add-test-form" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="test-name" class="block text-sm font-medium text-gray-700 mb-1">Test Name</label> | |
| <input type="text" id="test-name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="e.g. Biology Midterm" required> | |
| </div> | |
| <div> | |
| <label for="test-subject" class="block text-sm font-medium text-gray-700 mb-1">Subject</label> | |
| <input type="text" id="test-subject" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="e.g. Biology" required> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="test-date" class="block text-sm font-medium text-gray-700 mb-1">Test Date</label> | |
| <input type="date" id="test-date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" required> | |
| </div> | |
| <div> | |
| <label for="study-days" class="block text-sm font-medium text-gray-700 mb-1">Days Needed to Study</label> | |
| <input type="number" id="study-days" min="1" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="e.g. 14" required> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="test-notes" class="block text-sm font-medium text-gray-700 mb-1">Notes</label> | |
| <textarea id="test-notes" rows="2" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="Any important details..."></textarea> | |
| </div> | |
| <div class="flex justify-end"> | |
| <button type="submit" class="px-6 py-2 bg-primary text-white font-medium rounded-lg hover:bg-opacity-90 transition flex items-center space-x-2"> | |
| <i class="fas fa-plus"></i> | |
| <span>Add Test</span> | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Upcoming Tests --> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300 card-hover"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-semibold text-gray-800">Upcoming Tests</h2> | |
| <div class="flex space-x-2"> | |
| <button id="sort-date" class="px-3 py-1 text-sm bg-gray-100 rounded-lg hover:bg-gray-200 transition">Sort by Date</button> | |
| <button id="sort-priority" class="px-3 py-1 text-sm bg-gray-100 rounded-lg hover:bg-gray-200 transition">Sort by Priority</button> | |
| </div> | |
| </div> | |
| <div id="upcoming-tests" class="space-y-4"> | |
| <!-- Test items will be added here dynamically --> | |
| <div class="text-center py-8 text-gray-500" id="no-tests-message"> | |
| <i class="fas fa-calendar-check text-4xl mb-3"></i> | |
| <p>No upcoming tests. Add a test to get started!</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Right Column --> | |
| <div class="space-y-6"> | |
| <!-- Study Timeline --> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300 card-hover"> | |
| <div class="p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4">Study Timeline</h2> | |
| <div id="study-timeline" class="space-y-4"> | |
| <div class="text-center py-8 text-gray-500"> | |
| <i class="fas fa-clock text-4xl mb-3"></i> | |
| <p>Add a test to see your study timeline</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Progress Stats --> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300 card-hover"> | |
| <div class="p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4">Your Progress</h2> | |
| <div class="space-y-4"> | |
| <div> | |
| <div class="flex justify-between mb-1"> | |
| <span class="text-sm font-medium text-gray-700">Tests Completed</span> | |
| <span class="text-sm font-medium text-gray-700" id="completed-count">0</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5"> | |
| <div id="completed-bar" class="bg-secondary h-2.5 rounded-full progress-bar" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="flex justify-between mb-1"> | |
| <span class="text-sm font-medium text-gray-700">Tests Pending</span> | |
| <span class="text-sm font-medium text-gray-700" id="pending-count">0</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5"> | |
| <div id="pending-bar" class="bg-warning h-2.5 rounded-full progress-bar" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="flex justify-between mb-1"> | |
| <span class="text-sm font-medium text-gray-700">Study Days Remaining</span> | |
| <span class="text-sm font-medium text-gray-700" id="study-days-remaining">0</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5"> | |
| <div id="study-days-bar" class="bg-primary h-2.5 rounded-full progress-bar" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Quick Actions --> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden transition-all duration-300 card-hover"> | |
| <div class="p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4">Quick Actions</h2> | |
| <div class="grid grid-cols-2 gap-3"> | |
| <button id="mark-completed" class="p-3 bg-green-50 text-green-700 rounded-lg hover:bg-green-100 transition flex flex-col items-center"> | |
| <i class="fas fa-check-circle text-2xl mb-1"></i> | |
| <span class="text-sm">Mark Completed</span> | |
| </button> | |
| <button id="add-reminder" class="p-3 bg-blue-50 text-blue-700 rounded-lg hover:bg-blue-100 transition flex flex-col items-center"> | |
| <i class="fas fa-bell text-2xl mb-1"></i> | |
| <span class="text-sm">Add Reminder</span> | |
| </button> | |
| <button id="export-data" class="p-3 bg-purple-50 text-purple-700 rounded-lg hover:bg-purple-100 transition flex flex-col items-center"> | |
| <i class="fas fa-file-export text-2xl mb-1"></i> | |
| <span class="text-sm">Export Data</span> | |
| </button> | |
| <button id="import-data" class="p-3 bg-yellow-50 text-yellow-700 rounded-lg hover:bg-yellow-100 transition flex flex-col items-center"> | |
| <i class="fas fa-file-import text-2xl mb-1"></i> | |
| <span class="text-sm">Import Data</span> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Modal --> | |
| <div id="test-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4 fade-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 id="modal-title" class="text-xl font-semibold text-gray-800">Test Details</h3> | |
| <button id="close-modal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div id="modal-content" class="space-y-4"> | |
| <!-- Content will be filled dynamically --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Sample data structure | |
| let tests = JSON.parse(localStorage.getItem('tests')) || []; | |
| let completedTests = JSON.parse(localStorage.getItem('completedTests')) || []; | |
| // DOM Elements | |
| const addTestForm = document.getElementById('add-test-form'); | |
| const upcomingTestsContainer = document.getElementById('upcoming-tests'); | |
| const noTestsMessage = document.getElementById('no-tests-message'); | |
| const studyTimelineContainer = document.getElementById('study-timeline'); | |
| const completedCount = document.getElementById('completed-count'); | |
| const pendingCount = document.getElementById('pending-count'); | |
| const studyDaysRemaining = document.getElementById('study-days-remaining'); | |
| const completedBar = document.getElementById('completed-bar'); | |
| const pendingBar = document.getElementById('pending-bar'); | |
| const studyDaysBar = document.getElementById('study-days-bar'); | |
| const testModal = document.getElementById('test-modal'); | |
| const closeModal = document.getElementById('close-modal'); | |
| const modalTitle = document.getElementById('modal-title'); | |
| const modalContent = document.getElementById('modal-content'); | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| const sortDateBtn = document.getElementById('sort-date'); | |
| const sortPriorityBtn = document.getElementById('sort-priority'); | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', () => { | |
| renderTests(); | |
| updateStats(); | |
| checkDarkModePreference(); | |
| // Set minimum date to today | |
| const today = new Date().toISOString().split('T')[0]; | |
| document.getElementById('test-date').min = today; | |
| }); | |
| // Event Listeners | |
| addTestForm.addEventListener('submit', handleAddTest); | |
| closeModal.addEventListener('click', () => testModal.classList.add('hidden')); | |
| themeToggle.addEventListener('click', toggleDarkMode); | |
| sortDateBtn.addEventListener('click', () => sortTests('date')); | |
| sortPriorityBtn.addEventListener('click', () => sortTests('priority')); | |
| // Functions | |
| function handleAddTest(e) { | |
| e.preventDefault(); | |
| const testName = document.getElementById('test-name').value; | |
| const testSubject = document.getElementById('test-subject').value; | |
| const testDate = document.getElementById('test-date').value; | |
| const studyDays = parseInt(document.getElementById('study-days').value); | |
| const testNotes = document.getElementById('test-notes').value; | |
| const studyStartDate = calculateStudyStartDate(testDate, studyDays); | |
| const newTest = { | |
| id: Date.now(), | |
| name: testName, | |
| subject: testSubject, | |
| date: testDate, | |
| studyDays: studyDays, | |
| studyStartDate: studyStartDate, | |
| notes: testNotes, | |
| priority: calculatePriority(testDate, studyDays), | |
| completed: false | |
| }; | |
| tests.push(newTest); | |
| saveTests(); | |
| renderTests(); | |
| updateStats(); | |
| // Reset form | |
| addTestForm.reset(); | |
| // Show success message | |
| showToast('Test added successfully!', 'success'); | |
| } | |
| function calculateStudyStartDate(testDate, studyDays) { | |
| const date = new Date(testDate); | |
| date.setDate(date.getDate() - studyDays); | |
| return date.toISOString().split('T')[0]; | |
| } | |
| function calculatePriority(testDate, studyDays) { | |
| const today = new Date(); | |
| const testDateObj = new Date(testDate); | |
| const daysUntilTest = Math.ceil((testDateObj - today) / (1000 * 60 * 60 * 24)); | |
| if (daysUntilTest <= studyDays) { | |
| return 'high'; // Should have started studying already | |
| } else if (daysUntilTest <= studyDays + 7) { | |
| return 'medium'; // Should start studying soon | |
| } else { | |
| return 'low'; // Plenty of time | |
| } | |
| } | |
| function renderTests() { | |
| if (tests.length === 0) { | |
| noTestsMessage.classList.remove('hidden'); | |
| upcomingTestsContainer.innerHTML = ''; | |
| upcomingTestsContainer.appendChild(noTestsMessage); | |
| renderStudyTimeline(); | |
| return; | |
| } | |
| noTestsMessage.classList.add('hidden'); | |
| upcomingTestsContainer.innerHTML = ''; | |
| // Sort tests by date (soonest first) | |
| const sortedTests = [...tests].sort((a, b) => new Date(a.date) - new Date(b.date)); | |
| sortedTests.forEach(test => { | |
| const testElement = createTestElement(test); | |
| upcomingTestsContainer.appendChild(testElement); | |
| }); | |
| renderStudyTimeline(); | |
| } | |
| function createTestElement(test) { | |
| const today = new Date(); | |
| const testDate = new Date(test.date); | |
| const daysUntilTest = Math.ceil((testDate - today) / (1000 * 60 * 60 * 24)); | |
| const studyStartDate = new Date(test.studyStartDate); | |
| const daysUntilStudy = Math.ceil((studyStartDate - today) / (1000 * 60 * 60 * 24)); | |
| const testElement = document.createElement('div'); | |
| testElement.className = 'bg-gray-50 rounded-lg p-4 border border-gray-200 fade-in'; | |
| testElement.dataset.id = test.id; | |
| let priorityBadge = ''; | |
| if (test.priority === 'high') { | |
| priorityBadge = '<span class="px-2 py-1 text-xs font-semibold bg-danger text-white rounded-full">High Priority</span>'; | |
| } else if (test.priority === 'medium') { | |
| priorityBadge = '<span class="px-2 py-1 text-xs font-semibold bg-warning text-white rounded-full">Medium Priority</span>'; | |
| } else { | |
| priorityBadge = '<span class="px-2 py-1 text-xs font-semibold bg-secondary text-white rounded-full">Low Priority</span>'; | |
| } | |
| testElement.innerHTML = ` | |
| <div class="flex justify-between items-start mb-2"> | |
| <h3 class="font-semibold text-gray-800">${test.name}</h3> | |
| ${priorityBadge} | |
| </div> | |
| <div class="flex items-center text-sm text-gray-600 mb-2"> | |
| <i class="fas fa-book mr-2"></i> | |
| <span>${test.subject}</span> | |
| </div> | |
| <div class="flex items-center text-sm text-gray-600 mb-3"> | |
| <i class="fas fa-calendar-day mr-2"></i> | |
| <span>${formatDate(test.date)} (${daysUntilTest} ${daysUntilTest === 1 ? 'day' : 'days'} away)</span> | |
| </div> | |
| <div class="flex justify-between items-center"> | |
| <button class="view-details px-3 py-1 text-sm bg-primary text-white rounded-lg hover:bg-opacity-90 transition"> | |
| View Details | |
| </button> | |
| <div class="flex space-x-2"> | |
| <button class="edit-test p-2 text-gray-500 hover:text-primary transition"> | |
| <i class="fas fa-edit"></i> | |
| </button> | |
| <button class="delete-test p-2 text-gray-500 hover:text-danger transition"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| // Add event listeners to buttons | |
| testElement.querySelector('.view-details').addEventListener('click', () => showTestDetails(test)); | |
| testElement.querySelector('.edit-test').addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| editTest(test.id); | |
| }); | |
| testElement.querySelector('.delete-test').addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| deleteTest(test.id); | |
| }); | |
| return testElement; | |
| } | |
| function renderStudyTimeline() { | |
| if (tests.length === 0) { | |
| studyTimelineContainer.innerHTML = ` | |
| <div class="text-center py-8 text-gray-500"> | |
| <i class="fas fa-clock text-4xl mb-3"></i> | |
| <p>Add a test to see your study timeline</p> | |
| </div> | |
| `; | |
| return; | |
| } | |
| // Sort tests by study start date (earliest first) | |
| const sortedTests = [...tests].sort((a, b) => new Date(a.studyStartDate) - new Date(b.studyStartDate)); | |
| studyTimelineContainer.innerHTML = ''; | |
| sortedTests.forEach(test => { | |
| const today = new Date(); | |
| const studyStartDate = new Date(test.studyStartDate); | |
| const daysUntilStudy = Math.ceil((studyStartDate - today) / (1000 * 60 * 60 * 24)); | |
| const timelineItem = document.createElement('div'); | |
| timelineItem.className = 'fade-in'; | |
| timelineItem.innerHTML = ` | |
| <div class="flex items-start"> | |
| <div class="flex flex-col items-center mr-3"> | |
| <div class="w-8 h-8 rounded-full bg-primary flex items-center justify-center text-white"> | |
| <i class="fas fa-book text-sm"></i> | |
| </div> | |
| <div class="w-0.5 h-12 bg-gray-200 mt-1"></div> | |
| </div> | |
| <div class="flex-1 pt-1"> | |
| <h4 class="font-medium text-gray-800">${test.name}</h4> | |
| <p class="text-sm text-gray-600 mb-1">${test.subject}</p> | |
| <div class="flex items-center text-sm ${daysUntilStudy <= 0 ? 'text-danger' : 'text-gray-500'}"> | |
| <i class="fas fa-calendar-day mr-1"></i> | |
| <span>Start studying ${formatDate(test.studyStartDate)} (${daysUntilStudy <= 0 ? 'Start now!' : daysUntilStudy + ' days'})</span> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| studyTimelineContainer.appendChild(timelineItem); | |
| }); | |
| } | |
| function showTestDetails(test) { | |
| const today = new Date(); | |
| const testDate = new Date(test.date); | |
| const daysUntilTest = Math.ceil((testDate - today) / (1000 * 60 * 60 * 24)); | |
| const studyStartDate = new Date(test.studyStartDate); | |
| const daysUntilStudy = Math.ceil((studyStartDate - today) / (1000 * 60 * 60 * 24)); | |
| modalTitle.textContent = test.name; | |
| let priorityText = ''; | |
| if (test.priority === 'high') { | |
| priorityText = 'High Priority - Start studying now!'; | |
| } else if (test.priority === 'medium') { | |
| priorityText = 'Medium Priority - Start studying soon'; | |
| } else { | |
| priorityText = 'Low Priority - You have plenty of time'; | |
| } | |
| modalContent.innerHTML = ` | |
| <div class="space-y-4"> | |
| <div class="flex items-center text-gray-700"> | |
| <i class="fas fa-book mr-3 w-5 text-center"></i> | |
| <span>Subject: ${test.subject}</span> | |
| </div> | |
| <div class="flex items-center text-gray-700"> | |
| <i class="fas fa-calendar-day mr-3 w-5 text-center"></i> | |
| <span>Test Date: ${formatDate(test.date)} (${daysUntilTest} ${daysUntilTest === 1 ? 'day' : 'days'} away)</span> | |
| </div> | |
| <div class="flex items-center text-gray-700"> | |
| <i class="fas fa-clock mr-3 w-5 text-center"></i> | |
| <span>Study Days Needed: ${test.studyDays}</span> | |
| </div> | |
| <div class="flex items-center ${test.priority === 'high' ? 'text-danger' : test.priority === 'medium' ? 'text-warning' : 'text-secondary'}"> | |
| <i class="fas fa-exclamation-circle mr-3 w-5 text-center"></i> | |
| <span>${priorityText}</span> | |
| </div> | |
| <div class="flex items-center text-gray-700"> | |
| <i class="fas fa-calendar-check mr-3 w-5 text-center"></i> | |
| <span>Start Studying: ${formatDate(test.studyStartDate)} (${daysUntilStudy <= 0 ? 'Start now!' : daysUntilStudy + ' days'})</span> | |
| </div> | |
| ${test.notes ? ` | |
| <div> | |
| <h4 class="font-medium text-gray-800 mb-1">Notes:</h4> | |
| <p class="text-gray-700 bg-gray-50 p-3 rounded-lg">${test.notes}</p> | |
| </div> | |
| ` : ''} | |
| <div class="pt-4 flex justify-between"> | |
| <button id="mark-as-completed" class="px-4 py-2 bg-secondary text-white rounded-lg hover:bg-opacity-90 transition"> | |
| Mark as Completed | |
| </button> | |
| <button id="add-reminder-btn" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-opacity-90 transition"> | |
| <i class="fas fa-bell mr-1"></i> Add Reminder | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| // Add event listeners to modal buttons | |
| document.getElementById('mark-as-completed').addEventListener('click', () => { | |
| markTestAsCompleted(test.id); | |
| testModal.classList.add('hidden'); | |
| }); | |
| document.getElementById('add-reminder-btn').addEventListener('click', () => { | |
| addReminderForTest(test); | |
| testModal.classList.add('hidden'); | |
| }); | |
| testModal.classList.remove('hidden'); | |
| } | |
| function editTest(testId) { | |
| const test = tests.find(t => t.id === testId); | |
| if (!test) return; | |
| modalTitle.textContent = `Edit ${test.name}`; | |
| modalContent.innerHTML = ` | |
| <form id="edit-test-form" class="space-y-4"> | |
| <div> | |
| <label for="edit-test-name" class="block text-sm font-medium text-gray-700 mb-1">Test Name</label> | |
| <input type="text" id="edit-test-name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" value="${test.name}" required> | |
| </div> | |
| <div> | |
| <label for="edit-test-subject" class="block text-sm font-medium text-gray-700 mb-1">Subject</label> | |
| <input type="text" id="edit-test-subject" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" value="${test.subject}" required> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="edit-test-date" class="block text-sm font-medium text-gray-700 mb-1">Test Date</label> | |
| <input type="date" id="edit-test-date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" value="${test.date}" required> | |
| </div> | |
| <div> | |
| <label for="edit-study-days" class="block text-sm font-medium text-gray-700 mb-1">Days Needed to Study</label> | |
| <input type="number" id="edit-study-days" min="1" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" value="${test.studyDays}" required> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="edit-test-notes" class="block text-sm font-medium text-gray-700 mb-1">Notes</label> | |
| <textarea id="edit-test-notes" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">${test.notes || ''}</textarea> | |
| </div> | |
| <div class="flex justify-between pt-2"> | |
| <button type="button" id="cancel-edit" class="px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-100 transition"> | |
| Cancel | |
| </button> | |
| <button type="submit" class="px-6 py-2 bg-primary text-white font-medium rounded-lg hover:bg-opacity-90 transition"> | |
| Save Changes | |
| </button> | |
| </div> | |
| </form> | |
| `; | |
| const editForm = document.getElementById('edit-test-form'); | |
| const cancelEdit = document.getElementById('cancel-edit'); | |
| editForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| test.name = document.getElementById('edit-test-name').value; | |
| test.subject = document.getElementById('edit-test-subject').value; | |
| test.date = document.getElementById('edit-test-date').value; | |
| test.studyDays = parseInt(document.getElementById('edit-study-days').value); | |
| test.notes = document.getElementById('edit-test-notes').value; | |
| test.studyStartDate = calculateStudyStartDate(test.date, test.studyDays); | |
| test.priority = calculatePriority(test.date, test.studyDays); | |
| saveTests(); | |
| renderTests(); | |
| updateStats(); | |
| testModal.classList.add('hidden'); | |
| showToast('Test updated successfully!', 'success'); | |
| }); | |
| cancelEdit.addEventListener('click', () => { | |
| testModal.classList.add('hidden'); | |
| }); | |
| testModal.classList.remove('hidden'); | |
| } | |
| function deleteTest(testId) { | |
| if (confirm('Are you sure you want to delete this test?')) { | |
| tests = tests.filter(test => test.id !== testId); | |
| saveTests(); | |
| renderTests(); | |
| updateStats(); | |
| showToast('Test deleted successfully!', 'success'); | |
| } | |
| } | |
| function markTestAsCompleted(testId) { | |
| const testIndex = tests.findIndex(t => t.id === testId); | |
| if (testIndex === -1) return; | |
| const completedTest = tests[testIndex]; | |
| completedTest.completed = true; | |
| completedTest.completedDate = new Date().toISOString().split('T')[0]; | |
| tests.splice(testIndex, 1); | |
| completedTests.push(completedTest); | |
| saveTests(); | |
| saveCompletedTests(); | |
| renderTests(); | |
| updateStats(); | |
| showToast('Test marked as completed!', 'success'); | |
| } | |
| function addReminderForTest(test) { | |
| // In a real app, this would integrate with a calendar API | |
| alert(`Reminder added for ${test.name} on ${formatDate(test.studyStartDate)}`); | |
| showToast('Reminder added to your calendar!', 'success'); | |
| } | |
| function sortTests(criteria) { | |
| if (criteria === 'date') { | |
| tests.sort((a, b) => new Date(a.date) - new Date(b.date)); | |
| showToast('Tests sorted by date', 'info'); | |
| } else if (criteria === 'priority') { | |
| const priorityOrder = { 'high': 1, 'medium': 2, 'low': 3 }; | |
| tests.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority]); | |
| showToast('Tests sorted by priority', 'info'); | |
| } | |
| renderTests(); | |
| } | |
| function updateStats() { | |
| const totalTests = tests.length + completedTests.length; | |
| const completedPercentage = totalTests > 0 ? Math.round((completedTests.length / totalTests) * 100) : 0; | |
| const pendingPercentage = totalTests > 0 ? Math.round((tests.length / totalTests) * 100) : 0; | |
| // Calculate total study days remaining across all tests | |
| const today = new Date(); | |
| let totalStudyDaysRemaining = 0; | |
| let activeStudyDays = 0; | |
| tests.forEach(test => { | |
| const studyStartDate = new Date(test.studyStartDate); | |
| const daysUntilStudy = Math.ceil((studyStartDate - today) / (1000 * 60 * 60 * 24)); | |
| if (daysUntilStudy <= 0) { | |
| activeStudyDays += test.studyDays; | |
| } else { | |
| totalStudyDaysRemaining += daysUntilStudy; | |
| } | |
| }); | |
| // Calculate a progress percentage for study days | |
| const totalStudyDays = activeStudyDays + totalStudyDaysRemaining; | |
| const studyDaysPercentage = totalStudyDays > 0 ? Math.round((activeStudyDays / totalStudyDays) * 100) : 0; | |
| // Update DOM | |
| completedCount.textContent = `${completedTests.length} / ${totalTests}`; | |
| pendingCount.textContent = `${tests.length} / ${totalTests}`; | |
| studyDaysRemaining.textContent = `${totalStudyDaysRemaining} days`; | |
| // Animate progress bars | |
| setTimeout(() => { | |
| completedBar.style.width = `${completedPercentage}%`; | |
| pendingBar.style.width = `${pendingPercentage}%`; | |
| studyDaysBar.style.width = `${studyDaysPercentage}%`; | |
| }, 100); | |
| } | |
| function saveTests() { | |
| localStorage.setItem('tests', JSON.stringify(tests)); | |
| } | |
| function saveCompletedTests() { | |
| localStorage.setItem('completedTests', JSON.stringify(completedTests)); | |
| } | |
| function formatDate(dateString) { | |
| const options = { year: 'numeric', month: 'short', day: 'numeric' }; | |
| return new Date(dateString).toLocaleDateString(undefined, options); | |
| } | |
| function showToast(message, type) { | |
| const toast = document.createElement('div'); | |
| toast.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg text-white font-medium flex items-center space-x-2 fade-in ${ | |
| type === 'success' ? 'bg-secondary' : | |
| type === 'error' ? 'bg-danger' : | |
| 'bg-primary' | |
| }`; | |
| toast.innerHTML = ` | |
| <i class="fas ${type === 'success' ? 'fa-check-circle' : type === 'error' ? 'fa-exclamation-circle' : 'fa-info-circle'}"></i> | |
| <span>${message}</span> | |
| `; | |
| document.body.appendChild(toast); | |
| setTimeout(() => { | |
| toast.classList.add('opacity-0', 'transition-opacity', 'duration-300'); | |
| setTimeout(() => toast.remove(), 300); | |
| }, 3000); | |
| } | |
| function toggleDarkMode() { | |
| const html = document.documentElement; | |
| const isDark = html.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', isDark); | |
| if (isDark) { | |
| themeToggle.innerHTML = '<i class="fas fa-sun"></i>'; | |
| } else { | |
| themeToggle.innerHTML = '<i class="fas fa-moon"></i>'; | |
| } | |
| } | |
| function checkDarkModePreference() { | |
| const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| const storedPreference = localStorage.getItem('darkMode'); | |
| if (storedPreference === 'true' || (storedPreference === null && prefersDark)) { | |
| document.documentElement.classList.add('dark'); | |
| themeToggle.innerHTML = '<i class="fas fa-sun"></i>'; | |
| } | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Administrator4321/test-tracker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |