`;
let hasItems = false;
for(const key in guideData) {
const section = guideData[key];
const form = document.getElementById(section.formId);
if (!form) continue;
const checkedItems = [];
for (const item of section.items) {
const checkbox = document.getElementById(item.id);
if (checkbox && checkbox.checked) {
checkedItems.push(item.text);
hasItems = true;
}
}
if (checkedItems.length > 0) {
summaryHTML += `
`;
}
}
if (!hasItems) {
summaryHTML += '
`;
summaryContainer.innerHTML = summaryHTML;
};
const showTab = (tabIndex) => {
currentTab = tabIndex;
tabContents.forEach((tab, index) => tab.classList.toggle('hidden', index !== tabIndex));
tabButtons.forEach((btn, index) => btn.classList.toggle('active', index === tabIndex));
prevBtn.style.visibility = tabIndex === 0 ? 'hidden' : 'visible';
nextBtn.textContent = tabIndex === tabButtons.length - 1 ? 'Start Over' : 'Next';
if (tabIndex === tabButtons.length - 1) { // Summary tab
generateSummary();
}
};
const nextPrev = (direction) => {
if (nextBtn.textContent === 'Start Over' && direction === 1) {
showTab(0);
return;
}
let newTab = currentTab + direction;
if (newTab >= 0 && newTab < tabButtons.length) {
showTab(newTab);
}
};
const downloadPDF = () => {
const { jsPDF } = window.jspdf;
const content = document.getElementById('pdf-content');
if (!content) return;
html2canvas(content, { scale: 2, backgroundColor: '#ffffff', useCORS: true })
.then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const canvasWidth = canvas.width;
const canvasHeight = canvas.height;
const ratio = canvasWidth / canvasHeight;
const imgWidth = pdfWidth - 20;
const imgHeight = imgWidth / ratio;
pdf.addImage(imgData, 'PNG', 10, 10, imgWidth, imgHeight);
pdf.save('Landlord-Tenant-Guide-Summary.pdf');
});
};
// --- EVENT LISTENERS ---
prevBtn.addEventListener('click', () => nextPrev(-1));
nextBtn.addEventListener('click', () => nextPrev(1));
downloadPdfBtn.addEventListener('click', downloadPDF);
tabButtons.forEach(btn => {
btn.addEventListener('click', () => showTab(parseInt(btn.dataset.tab)));
});
// --- INITIALIZATION ---
renderForms();
showTab(currentTab);
});
${section.title}
-
${checkedItems.map(text => `
- ${text} `).join('')}
No items were selected from the checklists. Go back and check the boxes for key points you want to include in this summary.
'; } summaryHTML += `Disclaimer: This guide provides general information for educational purposes only and is not a substitute for professional legal advice. Landlord-tenant law is complex and varies by state and city. Consult with a qualified attorney to address your specific situation.
