Self-Care Planner Generator

Self-Care Planner Generator

Self-Care Planner Generator

Structure your weekly wellness routine across four essential domains.

Your weekly plan is shown below. Each activity is color-coded by the self-care domain it supports.

Weekly Self-Care Schedule

Generated: ${date}

Schedule Matrix

${scheduleHTML}

Domain Key

  • Physical (Movement, Nutrition)
  • Mental (Rest, Learning, Mindfulness)
  • Social (Connection, Quality Time)
  • Spiritual (Purpose, Values, Nature)
`; } /** * Generates and downloads a PDF of the plan */ async function scpg_downloadPDF() { if (scpg_data.activities.length === 0) { alert("The planner is empty. Please add activities before downloading."); return; } if (typeof jspdf === 'undefined' || typeof html2canvas === 'undefined') { alert("Error: PDF libraries failed to load."); return; } scpg_renderPdfClone(); const { jsPDF } = window.jspdf; try { const contentDiv = scpg_pdfRenderClone.querySelector('.pdf-content'); if (!contentDiv) return; const canvas = await html2canvas(contentDiv, { scale: 1.5, useCORS: true }); const imgData = canvas.toDataURL('image/png'); const imgProps = { width: canvas.width, height: canvas.height }; const pdf = new jsPDF({ orientation: 'l', unit: 'pt', format: 'a4' }); // Landscape for better schedule fit const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 40; const contentWidth = pdfWidth - (margin * 2); const contentHeight = (contentWidth * imgProps.height) / imgProps.width; let heightLeft = contentHeight; let position = 0; pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); while (heightLeft > 0) { position -= (pdfHeight - margin * 2); pdf.addPage(); pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); } pdf.save('Weekly_Self_Care_Plan.pdf'); } catch (error) { console.error("PDF generation failed:", error); alert("An error occurred while generating the PDF."); } } // --- EVENT LISTENERS --- // Tab link clicks scpg_tabLinks.forEach((link, index) => { link.addEventListener('click', () => scpg_switchTab(index)); }); // Next/Prev button clicks if (scpg_prevButton) { scpg_prevButton.addEventListener('click', () => { if (scpg_currentTab > 0) scpg_switchTab(scpg_currentTab - 1); }); } if (scpg_nextButton) { scpg_nextButton.addEventListener('click', () => { if (scpg_currentTab === scpg_tabLinks.length - 1) { scpg_updateDataFromConfig(); scpg_switchTab(0); } else { if (scpg_currentTab < scpg_tabLinks.length - 1) scpg_switchTab(scpg_currentTab + 1); } }); } // PDF download if (scpg_downloadPdfButton) { scpg_downloadPdfButton.addEventListener('click', scpg_downloadPDF); } // --- Config Tab Listeners --- if (scpg_addActivityButton) { scpg_addActivityButton.addEventListener('click', () => { scpg_activitiesContainer.appendChild(scpg_createActivityInput()); }); } if (scpg_configTab) { // Handle removal scpg_configTab.addEventListener('click', (e) => { const removeButton = e.target.closest('.scpg-remove-item'); if (removeButton) { removeButton.closest('.p-4[data-id]').remove(); } }); } // --- INITIALIZATION --- // Initialize sample data and render on first load scpg_renderConfig(); scpg_renderDashboard(); // Set initial tab state scpg_tabPanes.forEach((pane, index) => { pane.classList.toggle('hidden', index !== 0); pane.classList.toggle('scpg-active', index === 0); }); scpg_tabLinks.forEach((link, index) => { TAB_CLASSES.active.forEach(cls => link.classList.remove(cls)); TAB_CLASSES.inactive.forEach(cls => link.classList.remove(cls)); if (index === 0) { TAB_CLASSES.active.forEach(cls => link.classList.add(cls)); } else { TAB_CLASSES.inactive.forEach(cls => link.classList.add(cls)); } }); });
Scroll to Top