Automated Contract Review & Risk Assessment Tool
Contract Input
Assessment Report
The risk assessment report will be displayed here.
Reviewed Text:
Manage Risk Keywords
Add keywords or phrases that indicate potential risk. The check is case-insensitive.
Current Risk Keyword List
Overall Risk Level: ${riskLevel}
${riskCount} potentially risky clause(s) identified.
`; reviewOutputDisplay.innerHTML = highlightedHtml; }; const handlePdfDownload = () => { const { jsPDF } = window.jspdf; const content = document.getElementById('pdf-content'); if (!content || riskSummary.textContent.includes('will be displayed here')) { alert("Please review a contract first to generate a report."); return; } html2canvas(content, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; let newWidth = pdfWidth - 40; // with margin let newHeight = newWidth / ratio; if (newHeight > pdfHeight - 40) { newHeight = pdfHeight - 40; newWidth = newHeight * ratio; } pdf.addImage(imgData, 'PNG', 20, 20, newWidth, newHeight); pdf.save('contract-risk-report.pdf'); }); }; // --- Event Listeners --- tabs.dashboard.addEventListener('click', () => { currentTab = 'dashboard'; updateTabs(); }); tabs.config.addEventListener('click', () => { currentTab = 'config'; updateTabs(); }); navButtons.next.addEventListener('click', () => { currentTab = 'config'; updateTabs(); }); navButtons.prev.addEventListener('click', () => { currentTab = 'dashboard'; updateTabs(); }); reviewBtn.addEventListener('click', performReview); addKeywordForm.addEventListener('submit', handleAddKeyword); keywordListDisplay.addEventListener('click', handleDeleteKeyword); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- Initializations --- updateTabs(); renderKeywordList(); });