`;
});
} else {
breakdownHtml += ``
).join('');
if (recommendations.length === 0) {
recommendationsHtml = "
`;
document.getElementById('pdf-container').innerHTML = pdfContentHtml;
const contentToPrint = document.getElementById('pdf-report-container');
try {
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'letter' });
await pdf.html(contentToPrint, {
callback: function(pdf) {
pdf.save(`saas_risk_report_${saasName.replace(/ /g, '_') || 'analysis'}.pdf`);
},
margin: [60, 60, 60, 60],
autoPaging: 'text',
width: 495,
windowWidth: 700
});
} catch (error) {
console.error("Error generating PDF:", error);
} finally {
btn.textContent = 'Download Risk Report';
btn.disabled = false;
}
};
// --- EVENT LISTENERS ---
tabs.forEach(tab => tab.addEventListener('click', () => showTab(parseInt(tab.dataset.tab, 10))));
nextBtn.addEventListener('click', () => { if (currentTab < totalTabs) showTab(currentTab + 1); });
prevBtn.addEventListener('click', () => { if (currentTab > 1) showTab(currentTab - 1); });
if(downloadPdfBtn) downloadPdfBtn.addEventListener('click', downloadPDF);
// --- Initial Setup ---
showTab(1);
});
No high-priority recommendations based on your answers. Well done!
`; } breakdownReport.innerHTML = breakdownHtml; }; // --- PDF DOWNLOAD --- const downloadPDF = async () => { if (typeof window.jspdf === 'undefined') { console.error("jsPDF is not loaded."); return; } const { jsPDF } = window.jspdf; const btn = document.getElementById('pdf-download-btn'); btn.textContent = 'Generating...'; btn.disabled = true; const saasName = document.getElementById('saas-name').value || 'N/A'; const { score, recommendations } = riskReportData; let level; if (score <= 30) level = 'Low'; else if (score <= 60) level = 'Medium'; else level = 'High'; let recommendationsHtml = recommendations.map(rec => `Area: ${rec.question}
${rec.recommendation}
No high-priority recommendations identified.
"; } const pdfContentHtml = `SaaS Legal Compliance Risk Report
For: ${saasName} | Date: ${new Date().toLocaleDateString('en-US')}
Overall Risk Analysis
Calculated Risk Score:${score} / 100
Assessed Risk Level:${level}
