`;
// Add GDPR Clause
if (data.privacy.gdpr) {
content += `
`;
}
// Add CCPA Clause
if (data.privacy.ccpa) {
content += `
`;
}
content += `
`;
return content;
}
// --- 5. RENDER LOGIC ---
function renderAll() {
// 1. Sync Data from Inputs
Object.keys(legalData.meta).forEach(key => { if (inputs[key]) legalData.meta[key] = inputs[key].value; });
Object.keys(legalData.tos).forEach(key => { if (inputs[key]) legalData.tos[key] = inputs[key].value; });
Object.keys(legalData.privacy).forEach(key => { if (inputs[key] && inputs[key].type !== 'checkbox') legalData.privacy[key] = inputs[key].value; });
legalData.privacy.gdpr = inputs.gdpr.checked;
legalData.privacy.ccpa = inputs.ccpa.checked;
// 2. Update Metadata Headers
outputs.dateTos.textContent = inputs.date.value || "Draft Date";
outputs.datePp.textContent = inputs.date.value || "Draft Date";
outputs.jurisdiction.textContent = inputs.jurisdiction.value || "N/A";
let badges = [];
if (legalData.privacy.gdpr) badges.push('GDPR');
if (legalData.privacy.ccpa) badges.push('CCPA');
outputs.complianceBadges.textContent = badges.join(', ') || "None Specified";
// 3. Render Document Bodies
outputs.tosBody.innerHTML = getTOSContent(legalData);
outputs.ppBody.innerHTML = getPrivacyPolicyContent(legalData);
}
// --- 6. EVENT LISTENERS ---
function attachListeners() {
// Attach listener to every single input/textarea/checkbox
const allInputs = document.querySelectorAll('.lg-input, .lg-checkbox-label input');
allInputs.forEach(inp => inp.addEventListener('input', renderAll));
}
// --- 7. TAB NAVIGATION ---
window.lgSwitchTab = function(tabId) {
document.querySelectorAll('.lg-tab-pane').forEach(p => p.classList.remove('active'));
document.querySelectorAll('.lg-tab-btn').forEach(b => b.classList.remove('active'));
document.getElementById(tabId).classList.add('active');
document.querySelector(`.lg-tab-btn[data-tab="${tabId}"]`).classList.add('active');
document.getElementById('legal-generator-tool').scrollIntoView({behavior: 'smooth'});
};
document.querySelectorAll('.lg-tab-btn').forEach(btn => {
btn.addEventListener('click', function() { lgSwitchTab(this.dataset.tab); });
});
// --- 8. PDF EXPORT ---
const btnDown = document.getElementById('lg-download-btn');
if(btnDown) {
btnDown.addEventListener('click', function() {
renderAll();
const element = document.getElementById('lg-render-area');
const filename = (inputs.company.value || 'Legal_Packet').replace(/[^a-z0-9]/gi, '_');
const opt = {
margin: 0.5,
filename: `${filename}_Legal_Packet.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
const origText = btnDown.innerText;
btnDown.innerText = "Generating Documents...";
html2pdf().set(opt).from(element).save().then(() => {
btnDown.innerText = origText;
});
});
}
// Start
init();
});
4. GDPR Rights (EU Users)
If you are a resident of the European Economic Area (EEA), you have certain data protection rights, including the right to access, rectify, or erase your Personal Data (Right to be Forgotten).
5. CCPA Rights (California)
If you are a California resident, you may be entitled to certain information regarding the disclosure of Personal Data to third parties for their direct marketing purposes. We do not sell your personal data.
6. Contact for Privacy Questions
If you have any questions about this Privacy Policy, please contact us by email at ${email}.
