-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.html
76 lines (76 loc) · 2.08 KB
/
main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Numeric Quantity Demo</title>
<style>
th {
font-family: Arial, Helvetica, sans-serif;
border-bottom: 1px solid gray;
}
h1,
h2,
h3,
td {
font-family: 'Courier New', Courier, monospace;
}
#input {
display: flex;
flex-direction: row;
gap: 1rem;
margin-bottom: 0.5rem;
}
#round {
width: 3rem;
}
</style>
</head>
<body>
<h1>numeric-quantity</h1>
<h3>Demo</h3>
<div id="input">
<input type="text" autofocus value="12.14" /><span>=></span>
<div id="result"></div>
</div>
<div id="options">
<div>
<label
><input type="checkbox" id="allowTrailingInvalid" checked /><code
>allowTrailingInvalid</code
></label
>
</div>
<div>
<label
><input type="checkbox" id="romanNumerals" checked /><code
>romanNumerals</code
></label
>
</div>
<div><code>round</code> <input type="number" id="round" value="3" /></div>
</div>
<h3>Tests</h3>
<div id="app"></div>
<script type="module" src="/src/dev.ts"></script>
<script>
const updateResult = () => {
const allowTrailingInvalid = document.getElementById(
'allowTrailingInvalid'
).checked;
const romanNumerals = document.getElementById('romanNumerals').checked;
const round = document.getElementById('round').valueAsNumber;
document.getElementById('result').innerText = numericQuantity(
document.querySelector('#input>input').value,
{ allowTrailingInvalid, romanNumerals, round }
);
};
for (const event of ['keyup', 'change']) {
document
.querySelectorAll('input')
.forEach(el => el.addEventListener(event, updateResult));
}
setTimeout(updateResult, 500);
</script>
</body>
</html>