Virtual Data Room for Legal Documents

Virtual Data Room for Legal Documents

Organize, manage, and export your sensitive legal documents.

No categories found. Add a category in the 'Upload & Manage' tab to get started.

`; return; } dataRoom.categories.forEach(category => { const categoryDocs = dataRoom.documents.filter(doc => doc.category === category); const categoryEl = document.createElement('div'); let docsHtml = ''; if (categoryDocs.length > 0) { docsHtml = categoryDocs.map(doc => `
${fileIcon} ${doc.name}
`).join(''); } else { docsHtml = `

No documents in this category.

`; } categoryEl.innerHTML = `
${folderIcon} ${category}
${docsHtml}
`; dataRoomView.appendChild(categoryEl); }); }; const renderCategoryManager = () => { categoryManagerList.innerHTML = dataRoom.categories.map(cat => `
${cat}
`).join(''); }; const updateCategoryDropdown = () => { docCategorySelect.innerHTML = dataRoom.categories.map(cat => ``).join(''); }; // --- UI & NAVIGATION LOGIC --- const showTab = (tabIndex) => { tabContents.forEach(content => content.classList.add('hidden')); tabButtons.forEach(button => button.classList.replace('active', 'inactive')); document.getElementById(`tab-content-${tabIndex}`).classList.remove('hidden'); document.querySelector(`.tab-button[data-tab='${tabIndex}']`).classList.replace('inactive', 'active'); updateNavButtons(); currentTab = tabIndex; }; const updateNavButtons = () => { prevBtn.style.visibility = currentTab === 0 ? 'hidden' : 'visible'; nextBtn.style.visibility = currentTab === totalTabs - 1 ? 'hidden' : 'visible'; nextBtn.textContent = 'Next'; }; const navigateTabs = (direction) => { const nextTabIndex = currentTab + direction; if (nextTabIndex >= 0 && nextTabIndex < totalTabs) { showTab(nextTabIndex); } }; // --- DATA MANIPULATION LOGIC --- const addDocument = () => { const name = docNameInput.value.trim(); const category = docCategorySelect.value; if (!name || !category) { alert('Please provide a document name and select a category.'); // Simple validation return; } const newDoc = { id: nextDocId++, name, category, date: new Date().toLocaleDateString() }; dataRoom.documents.push(newDoc); docNameInput.value = ''; renderDataRoom(); }; const removeDocument = (docId) => { const docEl = document.querySelector(`[data-doc-id='${docId}']`).closest('.document-item'); docEl.classList.add('deleting'); setTimeout(() => { dataRoom.documents = dataRoom.documents.filter(d => d.id !== docId); renderDataRoom(); }, 300); }; const addCategory = () => { const name = newCategoryNameInput.value.trim(); if (name && !dataRoom.categories.includes(name)) { dataRoom.categories.push(name); newCategoryNameInput.value = ''; renderCategoryManager(); updateCategoryDropdown(); } }; const removeCategory = (catName) => { // Remove the category dataRoom.categories = dataRoom.categories.filter(c => c !== catName); // Remove documents associated with that category dataRoom.documents = dataRoom.documents.filter(d => d.category !== catName); renderAll(); }; const downloadPDF = () => { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfContentArea = document.getElementById('pdf-content-area'); // Build professional-looking HTML for the PDF let pdfHtml = `

Virtual Data Room Report

`; dataRoom.categories.forEach(category => { pdfHtml += `

${category}

`; const categoryDocs = dataRoom.documents.filter(doc => doc.category === category); if (categoryDocs.length > 0) { pdfHtml += ''; categoryDocs.forEach(doc => { pdfHtml += ``; }); pdfHtml += '
Document NameDate Added
${doc.name}${doc.date}
'; } else { pdfHtml += '

No documents in this category.

'; } }); pdfContentArea.innerHTML = pdfHtml; html2canvas(pdfContentArea, { scale: 2 }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const imgProps= pdf.getImageProperties(imgData); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('Virtual_Data_Room_Report.pdf'); pdfContentArea.innerHTML = ''; // Clean up }); }; // --- EVENT LISTENERS --- prevBtn.addEventListener('click', () => navigateTabs(-1)); nextBtn.addEventListener('click', () => navigateTabs(1)); uploadBtn.addEventListener('click', addDocument); addCategoryBtn.addEventListener('click', addCategory); downloadPdfBtn.addEventListener('click', downloadPDF); tabButtons.forEach(button => { button.addEventListener('click', () => showTab(parseInt(button.dataset.tab))); }); // Event delegation for dynamic remove buttons dataRoomView.addEventListener('click', (e) => { const removeBtn = e.target.closest('.remove-doc-btn'); if (removeBtn) { removeDocument(parseInt(removeBtn.dataset.docId)); } }); categoryManagerList.addEventListener('click', (e) => { const removeBtn = e.target.closest('.remove-cat-btn'); if (removeBtn) { removeCategory(removeBtn.dataset.categoryName); } }); // --- INITIALIZATION --- renderAll(); showTab(0); });
Scroll to Top