`;
// 2. Log Table
if (logData.length === 0) {
html += '
`;
}
container.innerHTML = html;
}
function telgSwitchTab(tabId) {
document.querySelectorAll('.telg-tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.telg-content').forEach(c => c.classList.remove('active'));
const idx = tabId === 'builder' ? 0 : (tabId === 'entry' ? 1 : 2);
document.querySelectorAll('.telg-tab-btn')[idx].classList.add('active');
document.getElementById('telg-' + tabId).classList.add('active');
if (tabId === 'report') {
telgRenderReport();
}
}
function telgLoadExample() {
if(!confirm("Overwrite current data and load example civil litigation data?")) return;
// Set metadata
document.getElementById('inp-case-name').value = "Acme Corp v. Beta Solutions";
document.getElementById('inp-jurisdiction').value = "US District Court, Northern Division";
document.getElementById('inp-attorney').value = "Robert L. Stern, Esq.";
// Clear and fill log entries
document.getElementById('telg-log-rows-container').innerHTML = '';
telgAddLogRow("P-001", "Master Service Agreement (MSA)", "2022-01-01", "Client File/Box 1A", "Admissible");
telgAddLogRow("P-002", "Invoice #4521", "2023-09-15", "Accounting/Digital Archive", "Admissible");
telgAddLogRow("D-003", "Internal Memo (Dec 2024)", "2024-12-05", "R. Stern's Hard Drive", "Pending");
telgAddLogRow("T-004", "Expert Witness Report (Dr. Chen)", "2025-06-10", "Expert File", "Pending");
telgRenderReport();
telgSwitchTab('report');
}
/* --- PDF Generation --- */
async function telgGeneratePDF() {
telgRenderReport(); // Ensure report is updated
const meta = {
name: document.getElementById('inp-case-name').value || "N/A Case Name",
juris: document.getElementById('inp-jurisdiction').value || "N/A Jurisdiction",
attorney: document.getElementById('inp-attorney').value || "N/A Attorney",
deadline: document.getElementById('inp-deadline').value || "N/A Deadline"
};
const logData = telgGetLogData();
if (logData.length === 0) {
alert("Please add evidence items before generating the PDF.");
return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF('l', 'mm', 'a4'); // Landscape for better table fit
// Styling
const blue = [0, 119, 182]; // Deep Blue
let y = 20;
// Header
doc.setFillColor(...blue);
doc.rect(0, 0, 297, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(16);
doc.text("TRIAL EVIDENCE LOG", 14, 13);
// Meta Data
doc.setTextColor(0, 0, 0);
doc.setFontSize(10);
doc.setFont(undefined, 'bold');
doc.text("CASE NAME:", 14, y + 10);
doc.text("LEAD COUNSEL:", 100, y + 10);
doc.text("DISCOVERY DEADLINE:", 200, y + 10);
doc.setFont(undefined, 'normal');
doc.text(meta.name, 14, y + 15);
doc.text(meta.attorney, 100, y + 15);
doc.text(meta.deadline, 200, y + 15);
y += 30;
// Log Table
doc.setFontSize(14);
doc.text("Detailed Exhibit List", 14, y);
y += 5;
const tableBody = logData.map(item => [
item.id,
item.desc,
item.date,
item.custodian,
item.status
]);
doc.autoTable({
startY: y,
head: [['Exhibit ID', 'Description / Title', 'Date Acquired', 'Custodian / File Ref', 'Status']],
body: tableBody,
theme: 'grid',
headStyles: { fillColor: blue, fontSize: 10 },
styles: { fontSize: 9 },
columnStyles: {
0: { cellWidth: 20, fontStyle: 'bold' },
1: { cellWidth: 70 },
4: { cellWidth: 25, fontStyle: 'bold' }
}
});
// Signature Block (for Chain of Custody record)
let finalY = doc.lastAutoTable.finalY + 20;
if (finalY > 180) { doc.addPage(); finalY = 30; } // Check for page break in landscape
doc.setFontSize(10);
doc.text("Log Prepared By: ___________________________", 14, finalY);
doc.text("Date Reviewed: _______________", 150, finalY);
doc.save(`Evidence_Log_${meta.name.replace(/\s+/g, '_')}.pdf`);
}
No evidence items recorded yet.
'; } else { html += `Detailed Exhibit List
| Exhibit ID | Description | Date Acquired | Custodian / File Ref | Status |
|---|---|---|---|---|
| ${item.id} | ${item.desc} | ${item.date} | ${item.custodian} | ${item.status} |
