Investment Fund Legal Structure Comparison Tool
Select the investment fund legal structures you wish to compare:
Select at least two fund structures and click 'Compare Selected Structures' to see the comparison.
Select at least two fund structures and click \'Compare Selected Structures\' to see the comparison.
'; downloadPdfButton.style.display = 'none'; return; } if (!comparisonOutputDiv) { console.error('Comparison output div not found.'); return; } let tableHTML = `Comparison of Selected Investment Fund Structures
| Feature | `; selectedStructures.forEach(key => { const fund = fundStructures[key]; if (fund) { tableHTML += `${fund.name} | `; } }); tableHTML += `|
|---|---|---|
| ${criteria} | `; selectedStructures.forEach(key => { const fund = fundStructures[key]; if (fund && fund.features[criteria]) { tableHTML += `${fund.features[criteria]} | `; } else { tableHTML += `N/A | `; } }); tableHTML += `
Note: This comparison provides general information. Specific regulations, tax implications, and costs can vary significantly based on jurisdiction and individual fund characteristics. Always consult with legal and financial professionals.
`; comparisonOutputDiv.innerHTML = tableHTML; downloadPdfButton.style.display = 'inline-flex'; } /** * Clears all selected checkboxes and resets the output. */ function clearSelection() { const checkboxes = document.querySelectorAll('#fund-structure-selection input[type="checkbox"]'); checkboxes.forEach(cb => { cb.checked = false; }); comparisonOutputDiv.innerHTML = 'Select at least two fund structures and click \'Compare Selected Structures\' to see the comparison.
'; downloadPdfButton.style.display = 'none'; } /** * Handles PDF download. */ function downloadPDF() { if (comparisonOutputDiv.innerHTML.includes('Select at least two fund structures')) { showCustomModal('No Comparison Data', 'Please generate a comparison table before downloading the PDF.'); return; } // Create a temporary container for PDF content to exclude nav buttons and other UI. const pdfContent = document.createElement('div'); pdfContent.innerHTML = `Investment Fund Legal Structure Comparison
Generated on: ${new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}
${comparisonOutputDiv.innerHTML}
`;
// Temporarily hide the main tool container to avoid layout issues during PDF generation
toolContainer.style.display = 'none';
html2pdf().from(pdfContent).set({
margin: [20, 20, 20, 20], // Top, Left, Bottom, Right
filename: 'Investment_Fund_Structure_Comparison.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'landscape' } /* Landscape for wider tables */
}).save().then(() => {
// Restore visibility of the main tool container after PDF generation is complete
toolContainer.style.display = 'flex';
pdfContent.remove(); // Clean up temporary element
}).catch(error => {
console.error("Error generating PDF:", error);
showCustomModal('PDF Generation Error', 'There was an issue generating the PDF. Please try again.');
toolContainer.style.display = 'flex';
pdfContent.remove();
});
}
// --- Event Listeners ---
if (compareButton) {
compareButton.addEventListener('click', generateComparisonTable);
}
if (clearSelectionButton) {
clearSelectionButton.addEventListener('click', clearSelection);
}
if (downloadPdfButton) {
downloadPdfButton.addEventListener('click', downloadPDF);
}
// Custom modal close button
if (modalCloseButton) {
modalCloseButton.addEventListener('click', hideCustomModal);
}
// Close modal if clicking outside (on overlay)
if (customModalOverlay) {
customModalOverlay.addEventListener('click', (e) => {
if (e.target === customModalOverlay) {
hideCustomModal();
}
});
}
// --- Initial Setup ---
populateCheckboxes(); // Populate checkboxes on load
});