From 813b66d0c5355d5a81b444396eca3f206b4281c0 Mon Sep 17 00:00:00 2001 From: "Adriano (daitarn)" Date: Sat, 24 Oct 2026 15:28:59 +0200 Subject: [PATCH] Acquisizione: parametri camera con un decimale nelle caselle (#87) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Jbf7qKuxsnAVjxthRy7dnB --- scripts/calibrazione_pagina.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/calibrazione_pagina.py b/scripts/calibrazione_pagina.py index fbb7aee..6ddae2f 100644 --- a/scripts/calibrazione_pagina.py +++ b/scripts/calibrazione_pagina.py @@ -208,7 +208,8 @@ function fmt(v, cifre) { return n.toLocaleString("it-IT", o); } // numero senza separatore delle migliaia, per le caselle di input -function fmtCasella(v) { return Number(v).toLocaleString("it-IT", { maximumFractionDigits: 6, useGrouping: false }); } +// #87: cifre = decimali massimi; i parametri camera ne usano 1 (la camera rilegge 11999,993164 per 12000) +function fmtCasella(v, cifre) { return Number(v).toLocaleString("it-IT", { maximumFractionDigits: cifre === undefined ? 6 : cifre, useGrouping: false }); } // legge un numero scritto con virgola o con punto function leggiNumero(testo) { var n = Number(String(testo).split(" ").join("").replace(",", ".")); @@ -504,20 +505,20 @@ function creaParametro(nome, d) { cur.disabled = bloccato; cur.oninput = function () { // il cursore aggiorna la casella subito, la scrittura arriva dopo 300 ms var v = adatta(d, daPosizione(d, Number(cur.value))); - casella.value = fmtCasella(v); + casella.value = fmtCasella(v, 1); modifica(nome, v); }; campo.appendChild(cur); } casella.type = "text"; casella.inputMode = "decimal"; - casella.value = fmtCasella(d.valore); + casella.value = fmtCasella(d.valore, 1); casella.disabled = bloccato; casella.onchange = function () { var v = leggiNumero(casella.value); - if (isNaN(v)) { dire("msgParametri", "Valore non valido per " + ETICHETTE[nome].toLowerCase() + ".", "errore"); casella.value = fmtCasella(P.dati[nome].valore); return; } + if (isNaN(v)) { dire("msgParametri", "Valore non valido per " + ETICHETTE[nome].toLowerCase() + ".", "errore"); casella.value = fmtCasella(P.dati[nome].valore, 1); return; } v = adatta(d, v); - casella.value = fmtCasella(v); + casella.value = fmtCasella(v, 1); if (cur) cur.value = aPosizione(d, v); modifica(nome, v); }; @@ -588,7 +589,7 @@ function aggiornaValori(j) { if (!el || P.pendenti.hasOwnProperty(nome)) return; P.dati[nome].valore = d.valore; if (el.select) el.select.value = d.valore; - if (el.casella && document.activeElement !== el.casella) el.casella.value = fmtCasella(d.valore); + if (el.casella && document.activeElement !== el.casella) el.casella.value = fmtCasella(d.valore, 1); if (el.cursore && document.activeElement !== el.cursore) el.cursore.value = aPosizione(P.dati[nome], d.valore); }); }