Download script.js from Compass79/legaleagle-casesync-portal: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/spaces/Compass79/legaleagle-casesync-portal/resolve/main/script.js
- Command line
-
hf download hf://spaces/Compass79/legaleagle-casesync-portal/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Compass79/legaleagle-casesync-portal/resolve/main/script.js
4.14 kB
| // Main application script | |
| document.addEventListener('DOMContentLoaded', function() { | |
| console.log('LegalEagle CaseSync Portal initialized'); | |
| // Initialize bottom sheet behavior | |
| const contextPanel = document.querySelector('.context-panel'); | |
| if (contextPanel) { | |
| const handle = contextPanel.querySelector('.bottom-sheet-handle'); | |
| if (handle) { | |
| handle.addEventListener('click', () => { | |
| contextPanel.classList.toggle('expanded'); | |
| }); | |
| } | |
| } | |
| // Initialize bottom nav active state | |
| const navItems = document.querySelectorAll('custom-bottom-nav .nav-item'); | |
| navItems.forEach(item => { | |
| item.addEventListener('click', function() { | |
| navItems.forEach(i => i.classList.remove('active')); | |
| this.classList.add('active'); | |
| }); | |
| }); | |
| // Mobile panel toggles | |
| document.querySelectorAll('.panel-toggle').forEach(toggle => { | |
| toggle.addEventListener('click', () => { | |
| const panel = toggle.nextElementSibling; | |
| panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; | |
| toggle.querySelector('i').setAttribute('data-feather', | |
| panel.style.display === 'none' ? 'chevron-down' : 'chevron-up'); | |
| feather.replace(); | |
| }); | |
| }); | |
| // Document preview handler | |
| document.querySelectorAll('[data-preview]').forEach(el => { | |
| el.addEventListener('click', async (e) => { | |
| const fileUrl = e.target.dataset.preview; | |
| if(fileUrl.endsWith('.pdf')) { | |
| // Use PDF.js for PDF preview | |
| window.open(`/pdf-viewer.html?file=${encodeURIComponent(fileUrl)}`, '_blank'); | |
| } else { | |
| // Fetch and display text-based files | |
| const res = await fetch(fileUrl); | |
| const content = await res.text(); | |
| // Show in modal | |
| showPreviewModal(content); | |
| } | |
| }); | |
| }); | |
| }); | |
| function showPreviewModal(content) { | |
| // Implementation for preview modal | |
| const modal = document.createElement('div'); | |
| modal.className = 'fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4'; | |
| modal.innerHTML = ` | |
| <div class="bg-white rounded-lg max-w-full max-h-full w-full md:w-3/4 h-3/4 overflow-auto p-4"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-bold">Document Preview</h3> | |
| <button class="text-gray-500" onclick="this.parentElement.parentElement.parentElement.remove()"> | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| <pre class="whitespace-pre-wrap font-sans">${content}</pre> | |
| </div> | |
| `; | |
| document.body.appendChild(modal); | |
| feather.replace(); | |
| } | |
| // Document preview handlers | |
| function setupDocumentPreview() { | |
| document.querySelectorAll('[data-preview]').forEach(el => { | |
| el.addEventListener('click', async (e) => { | |
| const fileUrl = e.target.dataset.preview; | |
| if(fileUrl.endsWith('.pdf')) { | |
| // Use PDF.js for PDF preview | |
| window.open(`/pdf-viewer.html?file=${encodeURIComponent(fileUrl)}`, '_blank'); | |
| } else if(fileUrl.endsWith('.docx')) { | |
| // Use Mammoth.js for DOCX preview | |
| const res = await fetch(fileUrl); | |
| const arrayBuffer = await res.arrayBuffer(); | |
| const result = await mammoth.extractRawText({arrayBuffer}); | |
| showPreviewModal(result.value); | |
| } else { | |
| // Plain text files | |
| const res = await fetch(fileUrl); | |
| const content = await res.text(); | |
| showPreviewModal(content); | |
| } | |
| }); | |
| }); | |
| } | |
| // Helper functions | |
| function formatDate(dateString) { | |
| const options = { year: 'numeric', month: 'short', day: 'numeric' }; | |
| return new Date(dateString).toLocaleDateString('en-US', options); | |
| } | |
| function calculateDaysUntil(dateString) { | |
| const today = new Date(); | |
| const targetDate = new Date(dateString); | |
| const diffTime = targetDate - today; | |
| return Math.ceil(diffTime / (1000 * 60 * 60 * 24)); | |
| } |