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); }); }