Healthy Aging & Cognitive Longevity Planner

Healthy Aging & Cognitive Longevity Planner

Plan Your Weekly Physical Activity

Select activities from each category to build a balanced routine. Aim for at least 150 minutes of moderate activity per week.

Select Your Nutritional Goals

Choose key nutritional habits to focus on for brain and body health.

Choose Brain-Boosting Activities

Engaging your mind helps build cognitive reserve. Select activities you enjoy or would like to try.

Plan Your Social Activities

Strong social ties are linked to better health outcomes. Select ways you'd like to connect with others this week.

Your Personalized Healthy Aging Plan

This is a summary of your selections. Download it as a PDF to print and track your progress.

Go to the previous tabs to build your plan.

'; downloadPdfBtn.disabled = true; return; } downloadPdfBtn.disabled = false; const createSection = (title, items, icon) => { if (items.length === 0) return ''; return `

${icon} ${title}

    ${items.map(item => `
  • ${item}
  • `).join('')}
`; }; const icons = { physical: '', nutrition: '', // Placeholder cognitive: '', social: '' }; container.innerHTML = [ createSection('Physical Activity Goals', selectedPhysical, icons.physical), createSection('Nutrition Goals', selectedNutrition, icons.nutrition), createSection('Cognitive Engagement Goals', selectedCognitive, icons.cognitive), createSection('Social Connection Goals', selectedSocial, icons.social) ].filter(Boolean).join('
'); } // --- PDF Generation --- async function generatePDF() { const { jsPDF } = window.jspdf; const originalButtonText = downloadPdfBtn.textContent; downloadPdfBtn.textContent = 'Generating...'; downloadPdfBtn.disabled = true; const pdfWrapper = document.createElement('div'); pdfWrapper.style.position = 'absolute'; pdfWrapper.style.left = '-9999px'; pdfWrapper.style.top = '0'; pdfWrapper.style.width = '800px'; pdfWrapper.style.backgroundColor = 'white'; pdfWrapper.className = 'p-8'; pdfWrapper.innerHTML = `

Healthy Aging Plan

${new Date().toLocaleDateString()}

Disclaimer:

This plan is for informational purposes only. Consult with a healthcare professional before making changes to your health routine.

`; const planSummaryClone = document.getElementById('plan-summary').cloneNode(true); pdfWrapper.appendChild(planSummaryClone); document.body.appendChild(pdfWrapper); try { const canvas = await html2canvas(pdfWrapper, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgWidth / imgHeight; let finalImgWidth = pdfWidth; let finalImgHeight = pdfWidth / ratio; if (finalImgHeight > pdfHeight) { finalImgHeight = pdfHeight; finalImgWidth = pdfHeight * ratio; } pdf.addImage(imgData, 'PNG', 0, 0, finalImgWidth, finalImgHeight); pdf.save('Healthy-Aging-Plan.pdf'); } catch (error) { console.error("PDF Generation Error:", error); } finally { document.body.removeChild(pdfWrapper); downloadPdfBtn.textContent = 'Download PDF Plan'; downloadPdfBtn.disabled = false; } } // --- Event Listeners --- downloadPdfBtn.addEventListener('click', generatePDF); // --- Initial Call --- initializeChecklists(); showTab(0); });
Scroll to Top