Acquisizione: parametri camera con un decimale nelle caselle (#87)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jbf7qKuxsnAVjxthRy7dnB
This commit is contained in:
@@ -208,7 +208,8 @@ function fmt(v, cifre) {
|
|||||||
return n.toLocaleString("it-IT", o);
|
return n.toLocaleString("it-IT", o);
|
||||||
}
|
}
|
||||||
// numero senza separatore delle migliaia, per le caselle di input
|
// 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
|
// legge un numero scritto con virgola o con punto
|
||||||
function leggiNumero(testo) {
|
function leggiNumero(testo) {
|
||||||
var n = Number(String(testo).split(" ").join("").replace(",", "."));
|
var n = Number(String(testo).split(" ").join("").replace(",", "."));
|
||||||
@@ -504,20 +505,20 @@ function creaParametro(nome, d) {
|
|||||||
cur.disabled = bloccato;
|
cur.disabled = bloccato;
|
||||||
cur.oninput = function () { // il cursore aggiorna la casella subito, la scrittura arriva dopo 300 ms
|
cur.oninput = function () { // il cursore aggiorna la casella subito, la scrittura arriva dopo 300 ms
|
||||||
var v = adatta(d, daPosizione(d, Number(cur.value)));
|
var v = adatta(d, daPosizione(d, Number(cur.value)));
|
||||||
casella.value = fmtCasella(v);
|
casella.value = fmtCasella(v, 1);
|
||||||
modifica(nome, v);
|
modifica(nome, v);
|
||||||
};
|
};
|
||||||
campo.appendChild(cur);
|
campo.appendChild(cur);
|
||||||
}
|
}
|
||||||
casella.type = "text";
|
casella.type = "text";
|
||||||
casella.inputMode = "decimal";
|
casella.inputMode = "decimal";
|
||||||
casella.value = fmtCasella(d.valore);
|
casella.value = fmtCasella(d.valore, 1);
|
||||||
casella.disabled = bloccato;
|
casella.disabled = bloccato;
|
||||||
casella.onchange = function () {
|
casella.onchange = function () {
|
||||||
var v = leggiNumero(casella.value);
|
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);
|
v = adatta(d, v);
|
||||||
casella.value = fmtCasella(v);
|
casella.value = fmtCasella(v, 1);
|
||||||
if (cur) cur.value = aPosizione(d, v);
|
if (cur) cur.value = aPosizione(d, v);
|
||||||
modifica(nome, v);
|
modifica(nome, v);
|
||||||
};
|
};
|
||||||
@@ -588,7 +589,7 @@ function aggiornaValori(j) {
|
|||||||
if (!el || P.pendenti.hasOwnProperty(nome)) return;
|
if (!el || P.pendenti.hasOwnProperty(nome)) return;
|
||||||
P.dati[nome].valore = d.valore;
|
P.dati[nome].valore = d.valore;
|
||||||
if (el.select) el.select.value = 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);
|
if (el.cursore && document.activeElement !== el.cursore) el.cursore.value = aPosizione(P.dati[nome], d.valore);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user