/** * SiteForge Privacy Manager * Gestisce il consenso ai cookie e la privacy (GDPR/CCPA compliant basics). * * Utilizzo: * 1. Includi questo script: * 2. Inizializza: * PrivacyManager.init({ * policyUrl: '/privacy-policy', * cookiePolicyUrl: '/cookie-policy' * }); */ $( document ).ready(function() {PrivacyManager.init({policyUrl: '/privacy-policy.htm', cookiePolicyUrl: '/cookie-policy.html'});}); const PrivacyManager = (function () { const STORAGE_KEY = 'siteforge_privacy_consent'; // Default config let config = { policyUrl: '#', cookiePolicyUrl: '#', autoBlock: true // Blocca script src se non autorizzati (richiede gestione specifica) }; let consent = { necessary: true, // Sempre true analytics: false, marketing: false, timestamp: null }; // --- UI TEMPLATES --- const css = ` #sf-privacy-banner { position: fixed; bottom: 0; left: 0; width: 100%; background: #fff; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); padding: 20px; font-family: sans-serif; font-size: 14px; z-index: 99999; display: none; flex-direction: column; gap: 15px; border-top: 1px solid #eee; } @media (min-width: 768px) { #sf-privacy-banner { flex-direction: row; align-items: center; justify-content: space-between; padding: 20px 40px; } } .sf-privacy-buttons { display: flex; gap: 10px; flex-wrap: wrap; } .sf-btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 13px; } .sf-btn-primary { background: #1a73e8; color: white; } .sf-btn-secondary { background: #f1f3f4; color: #333; } .sf-btn-link { background: none; text-decoration: underline; color: #555; } #sf-privacy-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 100000; display: none; align-items: center; justify-content: center; } .sf-privacy-modal-content { background: white; padding: 30px; border-radius: 8px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; font-family: sans-serif; } .sf-switch-group { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #eee; } .sf-switch-label { font-weight: bold; display: block; } .sf-switch-desc { font-size: 12px; color: #666; display: block; margin-top: 5px; } `; function init(userConfig) { config = { ...config, ...userConfig }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', runStartLogic); } else { runStartLogic(); } } function runStartLogic() { // Load saved consent const saved = localStorage.getItem(STORAGE_KEY); if (saved) { consent = JSON.parse(saved); // Apply saved consent (e.g. enable scripts) applyConsent(); } else { // Show Banner injectStyles(); injectBanner(); } } function injectStyles() { const style = document.createElement('style'); style.textContent = css; document.head.appendChild(style); } function injectBanner() { $('#sf-privacy-banner').remove(); if (document.getElementById('sf-privacy-banner')) return; const banner = document.createElement('div'); banner.id = 'sf-privacy-banner'; banner.innerHTML = `
Utilizziamo cookie tecnici e, previo consenso, cookie di profilazione e analitici per migliorare la tua esperienza. Puoi gestire le tue preferenze o accettare tutti i cookie. Leggi la Privacy Policy.