Overall Risk Profile
${riskLevel.label}
Key Risk Factors Identified
${explanations.length > 0 ? `
` : `
No significant immediate risk factors were identified based on your answers. Continue to follow best practices.
`}
Summary of Your Inputs
${inputsSummary.join('')}
Disclaimer: This tool provides a simplified, educational estimate of potential legal risks for informational purposes only. It is not a substitute for professional legal advice. Consult with a qualified attorney to assess your specific business situation and ensure compliance with all applicable laws.
`;
return true;
};
const nextPrev = (direction) => {
if (direction === 1 && currentTab === 0) {
if (!generateReport()) return; // Stop if validation fails
}
if (nextBtn.textContent === 'Start Over' && direction === 1) {
questionnaireForm.reset();
currentTab = 0;
showTab(0);
return;
}
const newTab = currentTab + direction;
if (newTab >= 0 && newTab < tabs.length) {
currentTab = newTab;
showTab(currentTab);
}
};
const downloadPDF = () => {
const { jsPDF } = window.jspdf;
if (!pdfContent) return;
html2canvas(pdfContent, { 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('Business-Legal-Risk-Report.pdf');
});
};
// --- EVENT LISTENERS ---
prevBtn.addEventListener('click', () => nextPrev(-1));
nextBtn.addEventListener('click', () => nextPrev(1));
downloadPdfBtn.addEventListener('click', downloadPDF);
tabNavs.forEach((nav, index) => nav.addEventListener('click', () => {
if(index < currentTab) {
currentTab = index;
showTab(index);
} else if(index > currentTab) {
nextPrev(1);
}
}));
// --- INITIALIZATION ---
showTab(currentTab);
});