Legal Citation Manager

Legal Citation Manager

Enter case details to generate a formatted legal citation.

Create New Citation

Saved Citations

  • No citations have been generated yet.

${citation.full}

`; citationsList.appendChild(li); }); } }; const handleFormSubmit = (event) => { event.preventDefault(); // Get form values const caseName = document.getElementById('case-name').value; const volume = document.getElementById('reporter-volume').value; const reporter = document.getElementById('reporter-abbr').value; const page = document.getElementById('first-page').value; const court = document.getElementById('court').value; const year = document.getElementById('year').value; // Format the citation const fullCitation = `${caseName}, ${volume} ${reporter} ${page} (${court} ${year})`; // Create citation object const newCitation = { full: fullCitation, name: caseName, volume, reporter, page, court, year }; // Add to state citations.push(newCitation); // Update UI generatedCitationText.textContent = fullCitation; generatedCitationArea.classList.remove('hidden'); renderCitationsList(); // Optional: clear form after submission // citationForm.reset(); }; const handleCopy = () => { const textToCopy = generatedCitationText.textContent; navigator.clipboard.writeText(textToCopy).then(() => { copyFeedback.textContent = 'Copied!'; setTimeout(() => copyFeedback.textContent = '', 2000); }).catch(err => { console.error('Failed to copy text: ', err); copyFeedback.textContent = 'Failed to copy!'; setTimeout(() => copyFeedback.textContent = '', 2000); }); }; const handleRemoveCitation = (index) => { citations.splice(index, 1); renderCitationsList(); }; const handleDownloadPdf = () => { if (citations.length === 0) { alert("Please add at least one citation to the list before downloading."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(22); doc.text("Legal Citations List", 105, 20, { align: 'center' }); doc.setFontSize(12); doc.text(`Generated on: ${new Date().toLocaleDateString()}`, 105, 28, { align: 'center' }); const tableData = citations.map(c => [c.name, `${c.volume} ${c.reporter} ${c.page}`, `${c.court} ${c.year}`]); doc.autoTable({ head: [['Case Name', 'Reporter', 'Court & Year']], body: tableData, startY: 40, headStyles: { fillColor: [22, 163, 74] }, // Green color styles: { cellPadding: 3, fontSize: 10 }, }); doc.save('Legal_Citations.pdf'); }; // --- EVENT LISTENERS --- citationForm.addEventListener('submit', handleFormSubmit); copyBtn.addEventListener('click', handleCopy); downloadPdfBtn.addEventListener('click', handleDownloadPdf); // Event delegation for remove buttons citationsList.addEventListener('click', (event) => { if (event.target.classList.contains('remove-btn')) { const index = parseInt(event.target.dataset.index); handleRemoveCitation(index); } }); // --- INITIAL LOAD --- renderCitationsList(); });
Scroll to Top