dechatter 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -1
- package/README.md +46 -12
- package/package.json +2 -1
- package/web/dechatter.zip +0 -0
- package/web/engine.js +3 -2
- package/web/index.html +13 -1
- package/web/stepper.js +402 -0
- package/web/units.js +43 -0
- package/web/widget.css +4 -0
- package/web/widget.js +485 -137
- package/web/wizard.js +2 -3
package/web/units.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Lengths, feeds and removal rates as the machine's units show them. Everything is stored in
|
|
2
|
+
// millimetres; on a machine in G20 it is shown in inches (4 decimals), with mm alongside
|
|
3
|
+
// where there is room, as the printed report does.
|
|
4
|
+
|
|
5
|
+
export const MM_PER_INCH = 25.4;
|
|
6
|
+
const MM3_PER_IN3 = MM_PER_INCH ** 3;
|
|
7
|
+
|
|
8
|
+
// Enough decimals that a hundred-thousandth of an inch survives the trip to millimetres.
|
|
9
|
+
export const tidy = (number) => Number(number.toFixed(5));
|
|
10
|
+
|
|
11
|
+
// "3.175 mm", or "0.1250 in" and with `mmToo` "0.1250 in (3.175 mm)". Millimetres drop
|
|
12
|
+
// trailing zeros: "5 mm".
|
|
13
|
+
export function length(mm, units, { mmToo = false, places = 3, inchPlaces = 4 } = {}) {
|
|
14
|
+
const metric = `${Number(mm.toFixed(places))} mm`;
|
|
15
|
+
if (units !== 'in') {
|
|
16
|
+
return metric;
|
|
17
|
+
}
|
|
18
|
+
const inches = `${(mm / MM_PER_INCH).toFixed(inchPlaces)} in`;
|
|
19
|
+
return mmToo ? `${inches} (${metric})` : inches;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A chip load is a few hundredths of a millimetre: one more decimal each way.
|
|
23
|
+
export function chipLoad(mm, units, options = {}) {
|
|
24
|
+
return length(mm, units, { ...options, places: 4, inchPlaces: 5 });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function feed(mmPerMin, units, { mmToo = false } = {}) {
|
|
28
|
+
const metric = `${Math.round(mmPerMin)} mm/min`;
|
|
29
|
+
if (units !== 'in') {
|
|
30
|
+
return metric;
|
|
31
|
+
}
|
|
32
|
+
const inches = `${(mmPerMin / MM_PER_INCH).toFixed(1)} in/min`;
|
|
33
|
+
return mmToo ? `${inches} (${metric})` : inches;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function rate(cm3PerMin, units, { mmToo = false } = {}) {
|
|
37
|
+
const metric = `${cm3PerMin.toFixed(2)} cm³/min`;
|
|
38
|
+
if (units !== 'in') {
|
|
39
|
+
return metric;
|
|
40
|
+
}
|
|
41
|
+
const inches = `${((cm3PerMin * 1000) / MM3_PER_IN3).toFixed(3)} in³/min`;
|
|
42
|
+
return mmToo ? `${inches} (${metric})` : inches;
|
|
43
|
+
}
|
package/web/widget.css
CHANGED
|
@@ -79,6 +79,10 @@ button:disabled { color: #999; cursor: not-allowed; }
|
|
|
79
79
|
button.primary { color: #fff; background: #337ab7; border-color: #2e6da4; }
|
|
80
80
|
button.primary:hover:not(:disabled) { background: #286090; }
|
|
81
81
|
button.primary:disabled { color: #fff; opacity: 0.55; }
|
|
82
|
+
button.danger { color: #fff; background: #c9302c; border-color: #ac2925; }
|
|
83
|
+
button.danger:hover:not(:disabled) { background: #ac2925; }
|
|
84
|
+
dialog { max-width: min(360px, calc(100vw - 32px)); border: 1px solid #ccc; border-radius: 3px; }
|
|
85
|
+
dialog p { margin: 0 0 8px; }
|
|
82
86
|
td select { padding: 1px 2px; }
|
|
83
87
|
|
|
84
88
|
.recording { color: #c9302c; font-weight: bold; }
|