`;
}).join('');
plannerOutput.innerHTML = `
Your Personalized Wellness Plan
A weekly guide to support your well-being.
Your Wellness Goals
${goalsHtml}
Your Weekly Therapy Schedule
${planHtml}
`;
plannerButtons.classList.remove('hidden');
};
const downloadPDF = () => {
const pdfContent = document.getElementById('pdf-content');
window.html2canvas(pdfContent, { scale: 2, backgroundColor: '#ffffff' }).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 pdfMargin = 40;
const contentWidth = pdfWidth - (pdfMargin * 2);
const imgHeight = canvas.height * contentWidth / canvas.width;
pdf.addImage(imgData, 'PNG', pdfMargin, pdfMargin, contentWidth, imgHeight);
pdf.save('Alternative_Therapy_Plan.pdf');
});
};
initialize();
});
function switchTab(tabId) {
const tabs = ['goals', 'therapies', 'planner', 'library'];
const buttons = {
next: document.getElementById('next-btn'),
prev: document.getElementById('prev-btn'),
generate: document.getElementById('generate-plan-btn')
};
tabs.forEach(id => {
document.getElementById(`${id}-tab`).style.display = (id === tabId) ? 'block' : 'none';
document.getElementById(`tab-${id}-btn`).classList.toggle('active', id === tabId);
});
buttons.prev.disabled = (tabId === 'goals');
buttons.next.style.display = (tabId === 'therapies' || tabId === 'planner' || tabId === 'library') ? 'none' : 'inline-block';
buttons.generate.style.display = (tabId === 'therapies') ? 'inline-block' : 'none';
if (tabId === 'planner') {
document.getElementById('tab-planner-btn').disabled = false;
}
}
function navigateTabs(direction) {
const currentActive = document.querySelector('.tab-btn.active');
const tabs = ['goals', 'therapies', 'planner', 'library'];
let currentIndex = tabs.findIndex(t => `tab-${t}-btn` === currentActive.id);
// Simple linear navigation for this tool
if (direction === 'next') {
if (currentIndex === 0) switchTab('therapies');
} else if (direction === 'prev') {
if (currentIndex === 1) switchTab('goals');
}
}