- privacy: sezione sulle mappe di Google (consenso, contitolarità C-40/17, Data Privacy Framework), PEC personale della Dott.ssa Giulia Grasso, trasferimenti condizionati a fornitori.soloSee, art. 13, frasi sul consenso e sul modulo solo quando servono, grammatica dei destinatari - mappe: avviso sulla scelta valida per tutto il sito e pulsante «Non caricare più le mappe» con test di revoca - modulo: checkbox di presa visione, informativa breve dai dati dello Studio, nota diversa per php/endpoint, fornitori.modulo obbligatorio in modalità endpoint, messaggi da testi.ts - contact.php: HMAC dell'IP con segreto casuale, cartella privata 0700/0600 fuori dalla webroot, cancellazione dopo un'ora - note legali e accessibilità: D.Lgs. 139/2005 e Codice deontologico, clausola di responsabilità, usi di JavaScript completi - testi senza promesse di tempi; TODO B2/B3/B4/B5/C12, DECISIONS D-036–D-039 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
/**
|
|
* Mappe Google caricate solo dopo il consenso esplicito (clic su «Carica la mappa»).
|
|
* Nessun cookie: la scelta è ricordata in sessionStorage (dato tecnico, nessun dato personale)
|
|
* e vale fino alla chiusura della scheda o alla revoca con «Non caricare più le mappe», che
|
|
* rimuove le mappe della pagina e ripristina i riquadri.
|
|
*/
|
|
|
|
const STORAGE_KEY = 'mappa-consentita';
|
|
|
|
function rememberConsent(): void {
|
|
try {
|
|
sessionStorage.setItem(STORAGE_KEY, '1');
|
|
} catch {
|
|
// sessionStorage non disponibile (es. navigazione privata restrittiva): nessun problema.
|
|
}
|
|
}
|
|
|
|
function forgetConsent(): void {
|
|
try {
|
|
sessionStorage.removeItem(STORAGE_KEY);
|
|
} catch {
|
|
// sessionStorage non disponibile: la scelta non era stata memorizzata.
|
|
}
|
|
}
|
|
|
|
function hasConsent(): boolean {
|
|
try {
|
|
return sessionStorage.getItem(STORAGE_KEY) === '1';
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function loadMap(block: HTMLElement, moveFocus: boolean): void {
|
|
if (block.dataset.mapLoaded === 'true') return;
|
|
const src = block.dataset.mapSrc;
|
|
const frame = block.querySelector<HTMLElement>('[data-map-frame]');
|
|
const placeholder = block.querySelector<HTMLElement>('[data-map-placeholder]');
|
|
if (!src || !frame || !placeholder) return;
|
|
|
|
const iframe = document.createElement('iframe');
|
|
iframe.src = src;
|
|
iframe.title = block.dataset.mapTitle ?? 'Mappa';
|
|
iframe.loading = 'lazy';
|
|
iframe.referrerPolicy = 'strict-origin-when-cross-origin';
|
|
iframe.allowFullscreen = true;
|
|
|
|
frame.append(iframe);
|
|
frame.hidden = false;
|
|
placeholder.hidden = true;
|
|
const revoke = block.querySelector<HTMLButtonElement>('[data-map-revoke]');
|
|
if (revoke) revoke.hidden = false;
|
|
block.dataset.mapLoaded = 'true';
|
|
if (moveFocus) iframe.focus();
|
|
}
|
|
|
|
function unloadMap(block: HTMLElement): void {
|
|
if (block.dataset.mapLoaded !== 'true') return;
|
|
const frame = block.querySelector<HTMLElement>('[data-map-frame]');
|
|
const placeholder = block.querySelector<HTMLElement>('[data-map-placeholder]');
|
|
const revoke = block.querySelector<HTMLButtonElement>('[data-map-revoke]');
|
|
frame?.replaceChildren();
|
|
if (frame) frame.hidden = true;
|
|
if (placeholder) placeholder.hidden = false;
|
|
if (revoke) revoke.hidden = true;
|
|
delete block.dataset.mapLoaded;
|
|
}
|
|
|
|
function init(): void {
|
|
const blocks = Array.from(document.querySelectorAll<HTMLElement>('[data-map-consent]'));
|
|
if (blocks.length === 0) return;
|
|
|
|
for (const block of blocks) {
|
|
const button = block.querySelector<HTMLButtonElement>('[data-map-load]');
|
|
button?.addEventListener('click', () => {
|
|
rememberConsent();
|
|
loadMap(block, true);
|
|
});
|
|
const revoke = block.querySelector<HTMLButtonElement>('[data-map-revoke]');
|
|
revoke?.addEventListener('click', () => {
|
|
forgetConsent();
|
|
for (const b of blocks) unloadMap(b);
|
|
button?.focus();
|
|
});
|
|
}
|
|
|
|
if (hasConsent()) for (const block of blocks) loadMap(block, false);
|
|
}
|
|
|
|
init();
|
|
|
|
export {};
|