Diaper Changing & Feeding Log

Diaper Changing & Feeding Log

Add a New Log

Quickly add an entry for a diaper change or feeding.

Log Type

Today's Log

No activities logged for today yet.

No activities logged for today yet.

'; return; } logHistoryContainer.innerHTML = todaysEntries.map(entry => { const dt = new Date(entry.datetime); const time = dt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); let icon = ''; let text = ''; if (entry.type === 'diaper') { icon = `💧`; text = `Diaper: ${entry.details.type}`; } else { icon = `🍼`; text = `Feeding: ${entry.details.type} ${entry.details.notes || ''}`; } return `
${icon}
${text}
${time}
`; }).join(''); }; const downloadPDF = () => { const today = new Date().toISOString().split('T')[0]; const todaysEntries = dailyLogData.filter(entry => entry.datetime.startsWith(today)); if (todaysEntries.length === 0) { alert('No logs for today to generate a report.'); return; } const pdfContainer = document.createElement('div'); pdfContainer.style.position = 'absolute'; pdfContainer.style.left = '-9999px'; pdfContainer.style.width = '700px'; pdfContainer.style.backgroundColor = '#ffffff'; pdfContainer.style.fontFamily = "'Inter', sans-serif"; const logHtml = todaysEntries.map(entry => { const dt = new Date(entry.datetime); const time = dt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); let icon = entry.type === 'diaper' ? '💧' : '🍼'; let text = entry.type === 'diaper' ? `Diaper: ${entry.details.type}` : `Feeding: ${entry.details.type} - ${entry.details.notes || 'N/A'}`; return `${time}${icon}${text}`; }).join(''); pdfContainer.innerHTML = `

Daily Log Report

${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}

${logHtml}
`; document.body.appendChild(pdfContainer); window.html2canvas(pdfContainer, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const contentWidth = pdfWidth - 80; const imgHeight = canvas.height * contentWidth / canvas.width; pdf.addImage(imgData, 'PNG', 40, 40, contentWidth, imgHeight); pdf.save('Daily_Log_Report.pdf'); document.body.removeChild(pdfContainer); }); }; const setDateTimeToNow = () => { const now = new Date(); logDateInput.valueAsDate = now; logTimeInput.value = now.toTimeString().substring(0, 5); }; // --- Initialization --- const initialize = () => { loadData(); renderLogHistory(); dailyLogForm.addEventListener('submit', addLogEntry); downloadPdfBtn.addEventListener('click', downloadPDF); setDateTimeToNow(); }; initialize(); }); function toggleLogDetails() { const logType = document.querySelector('input[name="log-type"]:checked').value; document.getElementById('diaper-details').style.display = (logType === 'diaper') ? 'block' : 'none'; document.getElementById('feeding-details').style.display = (logType === 'feeding') ? 'block' : 'none'; }
Scroll to Top