Online Time Management & Study Planner

Time Management & Study Planner

Organize your schedule, tasks, and goals all in one place.

This Week's Schedule

Your tasks will appear here.

'; return; } tasks.forEach((task, index) => { const taskEl = document.createElement('div'); taskEl.className = `task-item flex items-center justify-between p-2 bg-white rounded shadow-sm priority-${task.priority}`; if (task.completed) { taskEl.classList.add('completed'); } taskEl.innerHTML = ` ${task.text}
`; taskList.appendChild(taskEl); }); }; addTaskBtn.addEventListener('click', () => { const text = taskInput.value.trim(); if (!text) return; tasks.push({ text, priority: taskPriority.value, completed: false }); taskInput.value = ''; renderTasks(); }); taskList.addEventListener('click', (e) => { const index = e.target.dataset.index; if (e.target.classList.contains('toggle-complete-btn')) { tasks[index].completed = !tasks[index].completed; } if (e.target.classList.contains('delete-task-btn')) { tasks.splice(index, 1); } renderTasks(); }); // --- STUDY GOALS LOGIC --- const renderGoals = () => { goalList.innerHTML = ''; if (goals.length === 0) { goalList.innerHTML = '

Your goals will appear here.

'; return; } goals.forEach((goal, index) => { const goalEl = document.createElement('div'); goalEl.className = 'p-3 bg-white rounded shadow-sm border-l-4 border-purple-500'; goalEl.innerHTML = `

${goal.title}

${goal.desc}

Target: ${goal.date}

`; goalList.appendChild(goalEl); }); }; addGoalBtn.addEventListener('click', () => { const title = goalTitleInput.value.trim(); const desc = goalDescInput.value.trim(); const date = goalDateInput.value; if (!title || !desc || !date) return; goals.push({ title, desc, date }); goalTitleInput.value = ''; goalDescInput.value = ''; goalDateInput.value = ''; renderGoals(); }); goalList.addEventListener('click', (e) => { if (e.target.classList.contains('delete-goal-btn')) { goals.splice(e.target.dataset.index, 1); renderGoals(); } }); // --- PDF DOWNLOAD LOGIC --- downloadPdfBtn.addEventListener('click', () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'l' }); // landscape // Title doc.setFontSize(22); doc.text('My Study Plan', 14, 20); // 1. Schedule doc.setFontSize(16); doc.text('Weekly Schedule', 14, 35); doc.autoTable({ html: '#schedule-table', startY: 40, theme: 'grid', styles: { fontSize: 7, cellPadding: 1 }, headStyles: { fillColor: [45, 55, 72] } }); let finalY = doc.lastAutoTable ? doc.lastAutoTable.finalY + 15 : 40; doc.addPage(); // 2. To-Do List doc.setFontSize(16); doc.text('To-Do List', 14, 20); const taskData = tasks.map(t => [t.text, t.priority, t.completed ? 'Yes' : 'No']); if (taskData.length > 0) { doc.autoTable({ head: [['Task', 'Priority', 'Completed']], body: taskData, startY: 25, theme: 'striped' }); finalY = doc.lastAutoTable.finalY + 15; } else { doc.setFontSize(10); doc.text('No tasks added.', 14, 25); finalY = 35; } // 3. Study Goals doc.setFontSize(16); doc.text('Study Goals', 14, finalY); const goalData = goals.map(g => [g.title, g.desc, g.date]); if (goalData.length > 0) { doc.autoTable({ head: [['Goal', 'Description', 'Target Date']], body: goalData, startY: finalY + 5, theme: 'striped' }); } else { doc.setFontSize(10); doc.text('No goals added.', 14, finalY + 5); } doc.save('study-plan.pdf'); }); // --- INITIALIZATION --- generateSchedule(); renderTasks(); renderGoals(); });
Scroll to Top