Key Terms Identified in Top Category
Confidence Score Breakdown
${Object.entries(analysisResult.scores).map(([category, score]) => `
${category}
`).join('')}
No document has been analyzed yet. Please run an analysis first.
`; return; } container.innerHTML = `Keyword Matches by Category
${Object.entries(analysisResult.keywords).map(([category, keywords]) => `
`).join('')}
`;
};
const renderAll = () => {
renderDashboard();
renderInput();
renderDetailedAnalysis();
};
// --- TAB NAVIGATION ---
window.changeTab = (tabIndex) => {
currentTab = tabIndex;
renderAll(); // Always refresh data on tab change
const tabs = document.querySelectorAll('.tab');
const tabContents = document.querySelectorAll('.tab-content');
tabs.forEach((tab, i) => {
tab.classList.toggle('tab-active', i === tabIndex);
tab.classList.toggle('tab-inactive', i !== tabIndex);
});
tabContents.forEach((content, i) => {
content.style.display = i === tabIndex ? 'block' : 'none';
});
};
window.navigateTab = (direction) => {
const numTabs = document.querySelectorAll('.tab').length;
let newTab = currentTab + direction;
if (newTab < 0) newTab = 0;
if (newTab >= numTabs) newTab = numTabs - 1;
changeTab(newTab);
};
// --- PDF DOWNLOAD FUNCTIONALITY ---
window.downloadPDF = () => {
if (!analysisResult) return;
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
// Header
doc.setFontSize(18);
doc.setFont(undefined, 'bold');
doc.text('Regulatory Document Classification Report', 105, 22, { align: 'center' });
// Summary Table
doc.autoTable({
startY: 30,
body: [
['Primary Classification', analysisResult.primary.name],
['Confidence Score', `${analysisResult.primary.score}%`],
],
theme: 'plain',
styles: { fontSize: 11, cellPadding: 2 },
columnStyles: { 0: { fontStyle: 'bold' } }
});
// Breakdown Table
doc.setFontSize(14);
doc.setFont(undefined, 'bold');
doc.text('Confidence Score Breakdown', 14, doc.autoTable.previous.finalY + 15);
const breakdownBody = Object.entries(analysisResult.scores).map(([category, score]) => [category, `${score}%`]);
doc.autoTable({
startY: doc.autoTable.previous.finalY + 18,
head: [['Category', 'Confidence']],
body: breakdownBody,
theme: 'striped',
headStyles: { fillColor: [29, 78, 216] } // blue-700
});
// Keywords Table
doc.setFontSize(14);
doc.setFont(undefined, 'bold');
doc.text('Identified Keywords', 14, doc.autoTable.previous.finalY + 15);
const keywordsBody = Object.entries(analysisResult.keywords).map(([category, keywords]) => [
category,
keywords.join(', ') || 'N/A'
]);
doc.autoTable({
startY: doc.autoTable.previous.finalY + 18,
head: [['Category', 'Keywords Found']],
body: keywordsBody,
theme: 'grid',
headStyles: { fillColor: [100, 116, 139] } // slate-500
});
doc.save('Classification_Report.pdf');
};
// --- INITIAL RENDER ---
renderAll();
changeTab(0);
});
${category}
${keywords.length > 0 ? `Found ${keywords.length} keyword(s): ${keywords.join(', ')}
` : `No relevant keywords were identified for this category.
` }