Work Session Timer
Focus on your tasks using a customizable timer.
25:00
Settings
Session Log
No sessions logged yet.
'; return; } sessionLog.forEach(entry => { const logEl = document.createElement('div'); logEl.className = 'flex justify-between items-center p-2 bg-gray-50 border-b'; logEl.innerHTML = `${entry.type} Session
${entry.date}
${entry.duration} min
`; sessionLogContainer.appendChild(logEl); }); }; downloadPdfBtn.addEventListener('click', () => { if (sessionLog.length === 0) { showMessage('Session log is empty. Nothing to export.'); return; } showMessage('Preparing PDF...', false); const { jsPDF } = window.jspdf; const element = document.getElementById('pdf-export-area'); html2canvas(element, { scale: 2, useCORS: true }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'in', format: 'letter' }); const pdfWidth = pdf.internal.pageSize.getWidth() - 1; const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.text('Work Session Log', 0.5, 0.5); pdf.addImage(imgData, 'PNG', 0.5, 0.8, pdfWidth, pdfHeight); pdf.save('Work_Session_Log.pdf'); showMessage('PDF downloaded successfully!', false); }).catch(err => { console.error("PDF Generation Error:", err); showMessage("An error occurred during PDF generation."); }); }); // --- INITIALIZATION --- const initializeApp = () => { loadData(); applySettings(); renderSessionLog(); updateDisplay(); }; initializeApp(); });