fix: revisione legale e dei fatti prima del rilascio

- 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
This commit is contained in:
Claude committed 2026-10-15 23:35:06 +00:00
1 parent b680eff88d
commit ac69a4351f
23 files changed
+474 -164

No files matched your search

+27 -23
View File
@@ -5,26 +5,30 @@
* usa la validazione nativa del browser.
*/
const MESSAGES = {
required: 'Compila questo campo.',
email: 'Inserisci un indirizzo e-mail valido (es. nome@esempio.it).',
tel: 'Inserisci un numero di telefono valido (solo cifre, spazi e +).',
short: 'Il testo è troppo breve.',
consent: 'Per inviare la richiesta devi accettare l’informativa sulla privacy.',
tooFast: 'Attendi qualche secondo prima di inviare il modulo.',
};
/** Testi in src/data/testi.ts (`modulo.errori`), passati dal componente in `data-messages`. */
interface Messages {
obbligatorio: string;
email: string;
telefono: string;
breve: string;
presaVisione: string;
rapido: string;
unErrore: string;
piuErrori: string;
invio: string;
}
type Field = HTMLInputElement | HTMLTextAreaElement;
function messageFor(field: Field): string | null {
function messageFor(field: Field, m: Messages): string | null {
const v = field.validity;
if (v.valid) return null;
if (field instanceof HTMLInputElement && field.type === 'checkbox') return MESSAGES.consent;
if (v.valueMissing) return MESSAGES.required;
if (v.typeMismatch && field.type === 'email') return MESSAGES.email;
if (field.type === 'tel' && (v.patternMismatch || v.tooShort || v.tooLong)) return MESSAGES.tel;
if (v.tooShort) return MESSAGES.short;
return field.validationMessage || MESSAGES.required;
if (field instanceof HTMLInputElement && field.type === 'checkbox') return m.presaVisione;
if (v.valueMissing) return m.obbligatorio;
if (v.typeMismatch && field.type === 'email') return m.email;
if (field.type === 'tel' && (v.patternMismatch || v.tooShort || v.tooLong)) return m.telefono;
if (v.tooShort) return m.breve;
return field.validationMessage || m.obbligatorio;
}
function labelText(form: HTMLFormElement, field: Field): string {
@@ -50,6 +54,7 @@ function showError(field: Field, message: string | null): void {
}
function init(form: HTMLFormElement): void {
const m = JSON.parse(form.dataset.messages ?? '{}') as Messages;
const loadedAt = Date.now();
const minMs = Number(form.dataset.minSeconds ?? '3') * 1000;
const ts = form.querySelector<HTMLInputElement>('[data-form-ts]');
@@ -69,18 +74,18 @@ function init(form: HTMLFormElement): void {
const event = field.type === 'checkbox' ? 'change' : 'blur';
field.addEventListener(event, () => {
if (field.getAttribute('aria-invalid') === 'true' || field.value !== '') {
showError(field, messageFor(field));
showError(field, messageFor(field, m));
}
});
field.addEventListener('input', () => {
if (field.getAttribute('aria-invalid') === 'true') showError(field, messageFor(field));
if (field.getAttribute('aria-invalid') === 'true') showError(field, messageFor(field, m));
});
}
form.addEventListener('submit', (event) => {
const invalid: { field: Field; message: string }[] = [];
for (const field of fields) {
const message = messageFor(field);
const message = messageFor(field, m);
showError(field, message);
if (message) invalid.push({ field, message });
}
@@ -106,9 +111,8 @@ function init(form: HTMLFormElement): void {
summary.focus();
}
if (status) {
status.textContent = `Il modulo contiene ${invalid.length} ${
invalid.length === 1 ? 'errore' : 'errori'
}.`;
status.textContent =
invalid.length === 1 ? m.unErrore : m.piuErrori.replace('{n}', String(invalid.length));
}
return;
}
@@ -117,11 +121,11 @@ function init(form: HTMLFormElement): void {
if (Date.now() - loadedAt < minMs) {
event.preventDefault();
if (status) status.textContent = MESSAGES.tooFast;
if (status) status.textContent = m.rapido;
return;
}
if (status) status.textContent = 'Invio in corso…';
if (status) status.textContent = m.invio;
});
}
+30 -1
View File
@@ -1,7 +1,8 @@
/**
* 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.
* 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';
@@ -14,6 +15,14 @@ function rememberConsent(): void {
}
}
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';
@@ -39,10 +48,24 @@ function loadMap(block: HTMLElement, moveFocus: boolean): void {
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;
@@ -53,6 +76,12 @@ function init(): void {
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);