Skip to content

Commit a56f01c

Browse files
committed
updateText() updates
consistent ids in .html too
1 parent 632e895 commit a56f01c

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

apps/input-num/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,15 @@
118118
</select>
119119
</div>
120120
<div class="row mt1-2 mb3-16">
121-
<check-box id="blur-cancel" label="onblur() = cancel input"
121+
<check-box id="blurCancel" label="onblur() &nbsp;= cancel input"
122122
title="Cancel instead of confirming when tabbing out of the element or clicking elsewhere on the page.">
123123
</check-box>
124124
</div>
125+
<div class="row mb3-16">
126+
<check-box id="anyDecimal" label="anyDecimal: comma or period"
127+
title='Allows the user to input either comma "," or period "." as the decimal marker'>
128+
</check-box>
129+
</div>
125130
<!-------------->
126131
<div class="row mt1-2">
127132
<label for="fontFamily">Font:</label>

apps/input-num/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ function load() {
5151
decimals.push(newOption(n, i));
5252
// init these remaining elements by id:
5353
["autoWidth","autoAlign","autoScale","max","digits","accounting",
54-
"spins","confirms","keyboards","step","delay","interval","blur-cancel",
55-
"fontSize","fontWeight","fontStyle"].forEach(id => initElm(id, decimals));
54+
"spins","confirms","keyboards","step","delay","interval","blurCancel",
55+
"anyDecimal","fontSize","fontWeight","fontStyle"
56+
].forEach(id => initElm(id, decimals));
5657

5758
const // #min is a modified clone of #max
5859
min = "min",
@@ -151,7 +152,7 @@ function initElm(id, decimals) {
151152
let i, n, opt;
152153
const elm = document.getElementById(id);
153154

154-
elms[kebabToCamel(id)] = elm;
155+
elms[id] = elm;
155156
addChangeEvent(elm);
156157
switch (id) {
157158
case "digits":
@@ -281,8 +282,9 @@ function updateText() {
281282
for (elm of [elms.step, elms.delay, elms.interval])
282283
ctrls.add(elm);
283284

284-
if (elms.blurCancel.checked)
285-
ctrls.add(elms.blurCancel);
285+
for (elm of [elms.blurCancel, elms.anyDecimal])
286+
if (elm.checked)
287+
ctrls.add(elm);
286288

287289
for (elm of ctrls) {
288290
prop = elm.id;
@@ -306,8 +308,8 @@ function updateText() {
306308
js += getText(elm, prop, true);
307309
}
308310
break;
309-
case elms.accounting: case elms.blurCancel:
310-
pre += prop;
311+
case elms.accounting: case elms.blurCancel: case elms.anyDecimal:
312+
pre += prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase());
311313
js += getText(null, prop, true, true);
312314
break;
313315
}
@@ -319,7 +321,7 @@ function updateText() {
319321
//======================================
320322
function getText(elm, prop, isJS, val) {
321323
let equals, prefix, suffix;
322-
const value = (val != undefined)
324+
const value = (val !== undefined)
323325
? val
324326
: isJS && !Number.isNaN(parseFloat(elm.value))
325327
? elm.value

0 commit comments

Comments
 (0)