`).join('') : '
`;
guideButtons.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(`${userSelections.name.replace(/\s/g, '_')}_Minimalist_Guide.pdf`);
});
};
generateGuideBtn.addEventListener('click', generateGuide);
document.getElementById('download-pdf-btn').addEventListener('click', downloadPDF);
});
function switchTab(tabId) {
const tabs = ['goals', 'focus', 'mindset', 'guide'];
const buttons = {
next: document.getElementById('next-btn'),
prev: document.getElementById('prev-btn'),
generate: document.getElementById('generate-guide-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 === 'mindset' || tabId === 'guide') ? 'none' : 'inline-block';
buttons.generate.style.display = (tabId === 'mindset') ? 'inline-block' : 'none';
if (tabId === 'guide') {
document.getElementById('tab-guide-btn').disabled = false;
}
}
function navigateTabs(direction) {
const currentActive = document.querySelector('.tab-btn.active');
const tabs = ['goals', 'focus', 'mindset', 'guide'];
let currentIndex = tabs.findIndex(t => `tab-${t}-btn` === currentActive.id);
if (direction === 'next' && currentIndex < tabs.length - 1) {
switchTab(tabs[currentIndex + 1]);
} else if (direction === 'prev' && currentIndex > 0) {
switchTab(tabs[currentIndex - 1]);
}
}
No new habits selected. Consider adopting one to support your journey!
'; guideOutput.innerHTML = `${name} Personalized Minimalist Guide
Your roadmap to a simpler, more intentional life.
Your Core Motivations
- ${motivationsHtml}
Your Action Plan
Your Pace: ${pace} - ${guideContent.pace[pace]}
${areasHtml}
Mindset & Habits to Cultivate
${habitsHtml}
