Online Automated Homework Reminder

Add your assignments and get an automatically sorted dashboard of what's due next.

Your Upcoming Deadlines

Assignments are automatically sorted by the nearest due date. Items marked in red are overdue or due within 24 hours.

${hw.title} (${hw.course})

${formatDateTime(hw.dueDateTime)}

`; manageList.appendChild(item); }); }; const renderAll = () => { renderDashboard(); renderManagerList(); }; // --- TAB NAVIGATION LOGIC --- const switchTab = (tabName) => { currentTab = tabName; const isDashboard = tabName === 'dashboard'; tabDashboard.classList.toggle('active', isDashboard); tabDashboard.classList.toggle('inactive', !isDashboard); tabManager.classList.toggle('active', !isDashboard); tabManager.classList.toggle('inactive', isDashboard); contentDashboard.classList.toggle('hidden', !isDashboard); contentManager.classList.toggle('hidden', isDashboard); prevBtn.disabled = isDashboard; nextBtn.disabled = !isDashboard; }; // --- EVENT HANDLERS (IV.C) --- const handleFormSubmit = (e) => { e.preventDefault(); const course = courseInput.value.trim(); const title = titleInput.value.trim(); const date = dateInput.value; const time = timeInput.value; if (course && title && date && time) { const newAssignment = { id: Date.now(), course, title, dueDateTime: `${date}T${time}` }; assignments.push(newAssignment); renderAll(); homeworkForm.reset(); } }; const handleDelete = (e) => { const deleteButton = e.target.closest('.delete-btn'); if (deleteButton) { const idToDelete = parseInt(deleteButton.dataset.id, 10); assignments = assignments.filter(hw => hw.id !== idToDelete); renderAll(); } }; const handleDownloadPdf = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(18); doc.text("Homework Assignment List", 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Generated on: ${new Date().toLocaleDateString('en-US')}`, 14, 30); const sorted = getSortedAssignments(); const tableData = sorted.map(hw => [ hw.course, hw.title, formatDateTime(hw.dueDateTime) ]); doc.autoTable({ startY: 35, head: [['Course', 'Assignment', 'Due Date & Time']], body: tableData, theme: 'grid', headStyles: { fillColor: [79, 70, 229] }, // Indigo styles: { font: 'Inter', cellPadding: 3 }, }); doc.save('Homework-Schedule.pdf'); }; // --- EVENT LISTENERS ATTACHMENT --- if (homeworkForm) homeworkForm.addEventListener('submit', handleFormSubmit); if (manageList) manageList.addEventListener('click', handleDelete); if (tabDashboard) tabDashboard.addEventListener('click', () => switchTab('dashboard')); if (tabManager) tabManager.addEventListener('click', () => switchTab('manager')); if (prevBtn) prevBtn.addEventListener('click', () => switchTab('dashboard')); if (nextBtn) nextBtn.addEventListener('click', () => switchTab('manager')); if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', handleDownloadPdf); // --- INITIALIZATION --- const initializeWithSampleData = () => { const now = new Date(); const addDays = (date, days) => new Date(date.getTime() + days * 24 * 60 * 60 * 1000); const tomorrow = addDays(now, 1); const nextWeek = addDays(now, 7); const inThreeDays = addDays(now, 3); const formatForInput = (date, timeStr) => { const [hours, minutes] = timeStr.split(':'); date.setHours(hours, minutes, 0, 0); return date.toISOString(); }; // II.D.2 & Other Instructions #7: USA-relevant sample data assignments = [ { id: 1, course: 'HIST-211', title: 'Civil War Essay Outline', dueDateTime: formatForInput(tomorrow, '23:59') }, { id: 2, course: 'MATH-150', title: 'Problem Set 5', dueDateTime: formatForInput(inThreeDays, '17:00') }, { id: 3, course: 'ENG-101', title: 'Final Draft of Research Paper', dueDateTime: formatForInput(nextWeek, '12:00') }, ]; renderAll(); }; initializeWithSampleData(); switchTab('dashboard'); // Start on the dashboard tab });
Scroll to Top