More eslint tweaks

This commit is contained in:
David Carley
2022-09-07 17:51:16 +00:00
parent 051e712b53
commit f91dc1d756
26 changed files with 312 additions and 301 deletions

View File

@@ -20,7 +20,12 @@ globals:
Clusterize: readonly Clusterize: readonly
SockJS: readonly SockJS: readonly
ignorePatterns: ignorePatterns:
- "**/dist/**/*" - /src/svelte-components/dist
- /src/static
- /build
- /dist
- /rpi-share
- /src/py/bbctrl/http
rules: rules:
indent: indent:
- off - off
@@ -45,6 +50,7 @@ rules:
- argsIgnorePattern: _.* - argsIgnorePattern: _.*
no-unused-vars: no-unused-vars:
- error - error
- argsIgnorePattern: _.*
no-trailing-spaces: no-trailing-spaces:
- error - error
key-spacing: key-spacing:
@@ -94,3 +100,8 @@ rules:
- error - error
space-infix-ops: space-infix-ops:
- error - error
space-before-function-paren:
- error
- anonymous: never
named: never
asyncArrow: always

View File

@@ -1,11 +1,11 @@
{ module.exports = {
pretty: true, pretty: true,
filters: { filters: {
browserify: function (text, options) { browserify: function(text, _options) {
return require('child_process').execSync( return require("child_process").execSync(
`./node_modules/.bin/browserify - --basedir src/js`, `./node_modules/.bin/browserify - --basedir src/js`,
{input: text} { input: text }
).toString() ).toString();
}
} }
} };
}

View File

@@ -17,7 +17,7 @@ module.exports = {
template: "#admin-general-view-template", template: "#admin-general-view-template",
props: [ "config", "state" ], props: [ "config", "state" ],
data: function () { data: function() {
return { return {
confirmReset: false, confirmReset: false,
autoCheckUpgrade: true, autoCheckUpgrade: true,
@@ -25,20 +25,20 @@ module.exports = {
}; };
}, },
ready: function () { ready: function() {
this.autoCheckUpgrade = this.config.admin["auto-check-upgrade"]; this.autoCheckUpgrade = this.config.admin["auto-check-upgrade"];
}, },
methods: { methods: {
backup: function () { backup: function() {
document.getElementById("download-target").src = "/api/config/download"; document.getElementById("download-target").src = "/api/config/download";
}, },
restore_config: function () { restore_config: function() {
utils.clickFileInput("restore-config"); utils.clickFileInput("restore-config");
}, },
restore: function (e) { restore: function(e) {
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
if (!files.length) { if (!files.length) {
return; return;
@@ -71,7 +71,7 @@ module.exports = {
fileReader.readAsText(files[0]); fileReader.readAsText(files[0]);
}, },
reset: async function () { reset: async function() {
const config = merge( const config = merge(
{}, {},
config_defaults, config_defaults,
@@ -92,19 +92,19 @@ module.exports = {
} }
}, },
check: function () { check: function() {
this.$dispatch("check"); this.$dispatch("check");
}, },
upgrade: function () { upgrade: function() {
this.$dispatch("upgrade"); this.$dispatch("upgrade");
}, },
upload_firmware: function () { upload_firmware: function() {
utils.clickFileInput("upload-firmware"); utils.clickFileInput("upload-firmware");
}, },
upload: function (e) { upload: function(e) {
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
if (!files.length) { if (!files.length) {
return; return;
@@ -112,7 +112,7 @@ module.exports = {
this.$dispatch("upload", files[0]); this.$dispatch("upload", files[0]);
}, },
change_auto_check_upgrade: function () { change_auto_check_upgrade: function() {
this.config.admin["auto-check-upgrade"] = this.autoCheckUpgrade; this.config.admin["auto-check-upgrade"] = this.autoCheckUpgrade;
this.$dispatch("config-changed"); this.$dispatch("config-changed");
} }

View File

@@ -1,7 +1,7 @@
module.exports = { module.exports = {
template: "#admin-network-view-template", template: "#admin-network-view-template",
attached: function () { attached: function() {
this.svelteComponent = SvelteComponents.createComponent( this.svelteComponent = SvelteComponents.createComponent(
"AdminNetworkView", "AdminNetworkView",
document.getElementById("admin-network") document.getElementById("admin-network")

View File

@@ -34,7 +34,7 @@ async function callApi(method, url, data) {
} }
module.exports = { module.exports = {
get: function (url) { get: function(url) {
return callApi("GET", url); return callApi("GET", url);
}, },
@@ -42,7 +42,7 @@ module.exports = {
return callApi("PUT", url, body); return callApi("PUT", url, body);
}, },
delete: function (url) { delete: function(url) {
return callApi("DELETE", url); return callApi("DELETE", url);
} }
}; };

View File

@@ -91,7 +91,7 @@ function update_object(dst, src, remove) {
module.exports = new Vue({ module.exports = new Vue({
el: "body", el: "body",
data: function () { data: function() {
return { return {
status: "connecting", status: "connecting",
currentView: "loading", currentView: "loading",
@@ -136,7 +136,7 @@ module.exports = new Vue({
"help-view": { template: "#help-view-template" }, "help-view": { template: "#help-view-template" },
"cheat-sheet-view": { "cheat-sheet-view": {
template: "#cheat-sheet-view-template", template: "#cheat-sheet-view-template",
data: function () { data: function() {
return { return {
showUnimplemented: false showUnimplemented: false
}; };
@@ -145,32 +145,32 @@ module.exports = new Vue({
}, },
watch: { watch: {
display_units: function (value) { display_units: function(value) {
localStorage.setItem("display_units", value); localStorage.setItem("display_units", value);
SvelteComponents.setDisplayUnits(value); SvelteComponents.setDisplayUnits(value);
}, },
}, },
events: { events: {
"config-changed": function () { "config-changed": function() {
this.modified = true; this.modified = true;
}, },
send: function (msg) { send: function(msg) {
if (this.status == "connected") { if (this.status == "connected") {
this.sock.send(msg); this.sock.send(msg);
} }
}, },
connected: function () { connected: function() {
this.update(); this.update();
}, },
update: function () { update: function() {
this.update(); this.update();
}, },
check: async function () { check: async function() {
try { try {
const response = await fetch("https://raw.githubusercontent.com/OneFinityCNC/onefinity-release/master/latest.txt", { const response = await fetch("https://raw.githubusercontent.com/OneFinityCNC/onefinity-release/master/latest.txt", {
cache: "no-cache" cache: "no-cache"
@@ -182,17 +182,17 @@ module.exports = new Vue({
} }
}, },
upgrade: function () { upgrade: function() {
this.confirmUpgrade = true; this.confirmUpgrade = true;
}, },
upload: function (firmware) { upload: function(firmware) {
this.firmware = firmware; this.firmware = firmware;
this.firmwareName = firmware.name; this.firmwareName = firmware.name;
this.confirmUpload = true; this.confirmUpload = true;
}, },
error: function (msg) { error: function(msg) {
// Honor user error blocking // Honor user error blocking
if (Date.now() - this.errorTimeoutStart < this.errorTimeout * 1000) { if (Date.now() - this.errorTimeoutStart < this.errorTimeout * 1000) {
return; return;
@@ -210,7 +210,7 @@ module.exports = new Vue({
}, },
computed: { computed: {
popupMessages: function () { popupMessages: function() {
const msgs = []; const msgs = [];
for (let i = 0; i < this.state.messages.length; i++) { for (let i = 0; i < this.state.messages.length; i++) {
@@ -224,7 +224,7 @@ module.exports = new Vue({
}, },
}, },
ready: function () { ready: function() {
window.onhashchange = () => this.parse_hash(); window.onhashchange = () => this.parse_hash();
this.connect(); this.connect();
@@ -234,12 +234,12 @@ module.exports = new Vue({
}, },
methods: { methods: {
block_error_dialog: function () { block_error_dialog: function() {
this.errorTimeoutStart = Date.now(); this.errorTimeoutStart = Date.now();
this.errorShow = false; this.errorShow = false;
}, },
toggle_video: function () { toggle_video: function() {
if (this.video_size == "small") { if (this.video_size == "small") {
this.video_size = "large"; this.video_size = "large";
} else if (this.video_size == "large") { } else if (this.video_size == "large") {
@@ -248,13 +248,13 @@ module.exports = new Vue({
cookie.set("video-size", this.video_size); cookie.set("video-size", this.video_size);
}, },
toggle_crosshair: function (e) { toggle_crosshair: function(e) {
e.preventDefault(); e.preventDefault();
this.crosshair = !this.crosshair; this.crosshair = !this.crosshair;
cookie.set("crosshair", this.crosshair); cookie.set("crosshair", this.crosshair);
}, },
estop: function () { estop: function() {
if (this.state.xx == "ESTOPPED") { if (this.state.xx == "ESTOPPED") {
api.put("clear"); api.put("clear");
} else { } else {
@@ -262,7 +262,7 @@ module.exports = new Vue({
} }
}, },
upgrade_confirmed: async function () { upgrade_confirmed: async function() {
this.confirmUpgrade = false; this.confirmUpgrade = false;
try { try {
@@ -274,7 +274,7 @@ module.exports = new Vue({
} }
}, },
upload_confirmed: async function () { upload_confirmed: async function() {
this.confirmUpload = false; this.confirmUpload = false;
const form = new FormData(); const form = new FormData();
@@ -289,7 +289,7 @@ module.exports = new Vue({
} }
}, },
show_upgrade: function () { show_upgrade: function() {
if (!this.latestVersion) { if (!this.latestVersion) {
return false; return false;
} }
@@ -297,11 +297,11 @@ module.exports = new Vue({
return is_newer_version(this.config.version, this.latestVersion); return is_newer_version(this.config.version, this.latestVersion);
}, },
showShutdownDialog: function () { showShutdownDialog: function() {
SvelteComponents.showDialog("Shutdown"); SvelteComponents.showDialog("Shutdown");
}, },
update: async function () { update: async function() {
const config = await api.get("config/load"); const config = await api.get("config/load");
update_object(this.config, config, true); update_object(this.config, config, true);
@@ -319,7 +319,7 @@ module.exports = new Vue({
SvelteComponents.handleConfigUpdate(this.config); SvelteComponents.handleConfigUpdate(this.config);
}, },
connect: function () { connect: function() {
this.sock = new Sock(`//${location.host}/sockjs`); this.sock = new Sock(`//${location.host}/sockjs`);
this.sock.onmessage = (e) => { this.sock.onmessage = (e) => {
@@ -368,7 +368,7 @@ module.exports = new Vue({
}; };
}, },
parse_hash: function () { parse_hash: function() {
const hash = location.hash.substr(1); const hash = location.hash.substr(1);
if (!hash.trim().length) { if (!hash.trim().length) {
@@ -385,7 +385,7 @@ module.exports = new Vue({
this.currentView = parts[0]; this.currentView = parts[0];
}, },
save: async function () { save: async function() {
const selected_tool = this.config.tool["selected-tool"]; const selected_tool = this.config.tool["selected-tool"];
const saveModbus = const saveModbus =
selected_tool !== "pwm" && selected_tool !== "pwm" &&
@@ -411,7 +411,7 @@ module.exports = new Vue({
} }
}, },
close_messages: function (action) { close_messages: function(action) {
if (action == "stop") { if (action == "stop") {
api.put("stop"); api.put("stop");
} }

View File

@@ -5,7 +5,7 @@ module.exports = {
props: [ "axes", "colors", "enabled", "adjust", "step" ], props: [ "axes", "colors", "enabled", "adjust", "step" ],
methods: { methods: {
jog: function (axis, ring, direction) { jog: function(axis, ring, direction) {
const value = direction * this.value(ring); const value = direction * this.value(ring);
this.$dispatch(this.step ? "step" : "jog", this.axes[axis], value); this.$dispatch(this.step ? "step" : "jog", this.axes[axis], value);
}, },
@@ -14,13 +14,13 @@ module.exports = {
this.$dispatch("back2zero",this.axes[axis0],this.axes[axis1]); this.$dispatch("back2zero",this.axes[axis0],this.axes[axis1]);
}, },
release: function (axis) { release: function(axis) {
if (!this.step) { if (!this.step) {
this.$dispatch("jog", this.axes[axis], 0); this.$dispatch("jog", this.axes[axis], 0);
} }
}, },
value: function (ring) { value: function(ring) {
const adjust = [ 0.01, 0.1, 1 ][this.adjust]; const adjust = [ 0.01, 0.1, 1 ][this.adjust];
if (this.step) { if (this.step) {
return adjust * [ 0.1, 1, 10, 100 ][ring]; return adjust * [ 0.1, 1, 10, 100 ][ring];
@@ -28,7 +28,7 @@ module.exports = {
return adjust * [ 0.1, 0.25, 0.5, 1 ][ring]; return adjust * [ 0.1, 0.25, 0.5, 1 ][ring];
}, },
text: function (ring) { text: function(ring) {
let value = this.value(ring) * (this.step ? 1 : 100); let value = this.value(ring) * (this.step ? 1 : 100);
value = parseFloat(value.toFixed(3)); value = parseFloat(value.toFixed(3));
return value + (this.step ? "" : "%"); return value + (this.step ? "" : "%");

View File

@@ -4,51 +4,51 @@ module.exports = {
props: [ "state", "config" ], props: [ "state", "config" ],
computed: { computed: {
metric: function () { metric: function() {
return this.$root.display_units === "METRIC"; return this.$root.display_units === "METRIC";
}, },
x: function () { x: function() {
return this._compute_axis("x"); return this._compute_axis("x");
}, },
y: function () { y: function() {
return this._compute_axis("y"); return this._compute_axis("y");
}, },
z: function () { z: function() {
return this._compute_axis("z"); return this._compute_axis("z");
}, },
a: function () { a: function() {
return this._compute_axis("a"); return this._compute_axis("a");
}, },
b: function () { b: function() {
return this._compute_axis("b"); return this._compute_axis("b");
}, },
c: function () { c: function() {
return this._compute_axis("c"); return this._compute_axis("c");
}, },
axes: function () { axes: function() {
return this._compute_axes(); return this._compute_axes();
} }
}, },
methods: { methods: {
_convert_length: function (value) { _convert_length: function(value) {
return this.metric return this.metric
? value ? value
: value / 25.4; : value / 25.4;
}, },
_length_str: function (value) { _length_str: function(value) {
return this._convert_length(value).toLocaleString() + (this.metric ? " mm" : " in"); return this._convert_length(value).toLocaleString() + (this.metric ? " mm" : " in");
}, },
_compute_axis: function (axis) { _compute_axis: function(axis) {
const abs = this.state[`${axis}p`] || 0; const abs = this.state[`${axis}p`] || 0;
const off = this.state[`offset_${axis}`]; const off = this.state[`offset_${axis}`];
const motor_id = this._get_motor_id(axis); const motor_id = this._get_motor_id(axis);
@@ -182,7 +182,7 @@ module.exports = {
}; };
}, },
_get_motor_id: function (axis) { _get_motor_id: function(axis) {
for (let i = 0; i < this.config.motors.length; i++) { for (let i = 0; i < this.config.motors.length; i++) {
const motor = this.config.motors[i]; const motor = this.config.motors[i];
if (motor.axis.toLowerCase() == axis) { if (motor.axis.toLowerCase() == axis) {
@@ -193,7 +193,7 @@ module.exports = {
return -1; return -1;
}, },
_compute_axes: function () { _compute_axes: function() {
let homed = false; let homed = false;
for (const name of "xyzabc") { for (const name of "xyzabc") {

View File

@@ -13,14 +13,14 @@ const messages = [];
module.exports = { module.exports = {
template: "#console-template", template: "#console-template",
data: function () { data: function() {
return { return {
messages messages
}; };
}, },
events: { events: {
log: function (msg) { log: function(msg) {
// There may be multiple instances of this module so ignore messages // There may be multiple instances of this module so ignore messages
// that have already been processed. // that have already been processed.
if (msg.logged) { if (msg.logged) {
@@ -65,7 +65,7 @@ module.exports = {
}, },
methods: { methods: {
clear: function () { clear: function() {
messages.splice(0, messages.length); messages.splice(0, messages.length);
}, },
} }

View File

@@ -8,7 +8,7 @@ module.exports = {
template: "#control-view-template", template: "#control-view-template",
props: [ "config", "template", "state" ], props: [ "config", "template", "state" ],
data: function () { data: function() {
return { return {
current_time: "", current_time: "",
mach_units: this.$root.state.metric ? "METRIC" : "IMPERIAL", mach_units: this.$root.state.metric ? "METRIC" : "IMPERIAL",
@@ -52,12 +52,12 @@ module.exports = {
}, },
watch: { watch: {
jog_incr: function (value) { jog_incr: function(value) {
localStorage.setItem("jog_incr", value); localStorage.setItem("jog_incr", value);
}, },
"state.metric": { "state.metric": {
handler: function (metric) { handler: function(metric) {
this.mach_units = metric this.mach_units = metric
? "METRIC" ? "METRIC"
: "IMPERIAL"; : "IMPERIAL";
@@ -65,21 +65,21 @@ module.exports = {
immediate: true immediate: true
}, },
"state.line": function () { "state.line": function() {
if (this.mach_state != "HOMING") { if (this.mach_state != "HOMING") {
this.$broadcast("gcode-line", this.state.line); this.$broadcast("gcode-line", this.state.line);
} }
}, },
"state.selected_time": function () { "state.selected_time": function() {
this.load(); this.load();
}, },
jog_step: function () { jog_step: function() {
cookie.set_bool("jog-step", this.jog_step); cookie.set_bool("jog-step", this.jog_step);
}, },
jog_adjust: function () { jog_adjust: function() {
cookie.set("jog-adjust", this.jog_adjust); cookie.set("jog-adjust", this.jog_adjust);
} }
}, },
@@ -87,19 +87,19 @@ module.exports = {
computed: { computed: {
display_units: { display_units: {
cache: false, cache: false,
get: function () { get: function() {
return this.$root.display_units; return this.$root.display_units;
}, },
set: function (value) { set: function(value) {
this.$root.display_units = value; this.$root.display_units = value;
} }
}, },
metric: function () { metric: function() {
return this.display_units === "METRIC"; return this.display_units === "METRIC";
}, },
mach_state: function () { mach_state: function() {
const cycle = this.state.cycle; const cycle = this.state.cycle;
const state = this.state.xx; const state = this.state.xx;
@@ -110,46 +110,46 @@ module.exports = {
return state || ""; return state || "";
}, },
pause_reason: function () { pause_reason: function() {
return this.state.pr; return this.state.pr;
}, },
is_running: function () { is_running: function() {
return this.mach_state == "RUNNING" || this.mach_state == "HOMING"; return this.mach_state == "RUNNING" || this.mach_state == "HOMING";
}, },
is_stopping: function () { is_stopping: function() {
return this.mach_state == "STOPPING"; return this.mach_state == "STOPPING";
}, },
is_holding: function () { is_holding: function() {
return this.mach_state == "HOLDING"; return this.mach_state == "HOLDING";
}, },
is_ready: function () { is_ready: function() {
return this.mach_state == "READY"; return this.mach_state == "READY";
}, },
is_idle: function () { is_idle: function() {
return this.state.cycle == "idle"; return this.state.cycle == "idle";
}, },
is_paused: function () { is_paused: function() {
return this.is_holding && (this.pause_reason == "User pause" || this.pause_reason == "Program pause"); return this.is_holding && (this.pause_reason == "User pause" || this.pause_reason == "Program pause");
}, },
can_mdi: function () { can_mdi: function() {
return this.is_idle || this.state.cycle == "mdi"; return this.is_idle || this.state.cycle == "mdi";
}, },
can_set_axis: function () { can_set_axis: function() {
return this.is_idle; return this.is_idle;
// TODO allow setting axis position during pause // TODO allow setting axis position during pause
// return this.is_idle || this.is_paused; // return this.is_idle || this.is_paused;
}, },
message: function () { message: function() {
if (this.mach_state == "ESTOPPED") { if (this.mach_state == "ESTOPPED") {
return this.state.er; return this.state.er;
} }
@@ -165,15 +165,15 @@ module.exports = {
return ""; return "";
}, },
highlight_state: function () { highlight_state: function() {
return this.mach_state == "ESTOPPED" || this.mach_state == "HOLDING"; return this.mach_state == "ESTOPPED" || this.mach_state == "HOLDING";
}, },
plan_time: function () { plan_time: function() {
return this.state.plan_time; return this.state.plan_time;
}, },
plan_time_remaining: function () { plan_time_remaining: function() {
if (!(this.is_stopping || this.is_running || this.is_holding)) { if (!(this.is_stopping || this.is_running || this.is_holding)) {
return 0; return 0;
} }
@@ -181,7 +181,7 @@ module.exports = {
return this.toolpath.time - this.plan_time; return this.toolpath.time - this.plan_time;
}, },
eta: function () { eta: function() {
if (this.mach_state != "RUNNING") { if (this.mach_state != "RUNNING") {
return ""; return "";
} }
@@ -192,7 +192,7 @@ module.exports = {
return d.toLocaleString(); return d.toLocaleString();
}, },
progress: function () { progress: function() {
if (!this.toolpath.time || this.is_ready) { if (!this.toolpath.time || this.is_ready) {
return 0; return 0;
} }
@@ -203,17 +203,17 @@ module.exports = {
}, },
events: { events: {
jog: function (axis, power) { jog: function(axis, power) {
const data = { ts: new Date().getTime() }; const data = { ts: new Date().getTime() };
data[axis] = power; data[axis] = power;
api.put("jog", data); api.put("jog", data);
}, },
back2zero: function (axis0, axis1) { back2zero: function(axis0, axis1) {
this.send(`G0 ${axis0}0 ${axis1}0`); this.send(`G0 ${axis0}0 ${axis1}0`);
}, },
step: function (axis, value) { step: function(axis, value) {
this.send(` this.send(`
M70 M70
G91 G91
@@ -223,7 +223,7 @@ module.exports = {
}, },
}, },
ready: function () { ready: function() {
this.load(); this.load();
setInterval(() => { setInterval(() => {
@@ -248,7 +248,7 @@ module.exports = {
return [ weight, color ].join(";"); return [ weight, color ].join(";");
}, },
jog_fn: function (x_jog, y_jog, z_jog, a_jog) { jog_fn: function(x_jog, y_jog, z_jog, a_jog) {
const amount = this.jog_incr_amounts[this.display_units][this.jog_incr]; const amount = this.jog_incr_amounts[this.display_units][this.jog_incr];
const xcmd = `X${x_jog * amount}`; const xcmd = `X${x_jog * amount}`;
@@ -263,11 +263,11 @@ module.exports = {
`); `);
}, },
send: function (msg) { send: function(msg) {
this.$dispatch("send", msg); this.$dispatch("send", msg);
}, },
load: function () { load: function() {
const file_time = this.state.selected_time; const file_time = this.state.selected_time;
const file = this.state.selected; const file = this.state.selected;
if (this.last_file == file && this.last_file_time == file_time) { if (this.last_file == file && this.last_file_time == file_time) {
@@ -283,7 +283,7 @@ module.exports = {
this.load_toolpath(file, file_time); this.load_toolpath(file, file_time);
}, },
load_toolpath: async function (file, file_time) { load_toolpath: async function(file, file_time) {
this.toolpath = {}; this.toolpath = {};
if (!file || this.last_file_time != file_time) { if (!file || this.last_file_time != file_time) {
@@ -314,7 +314,7 @@ module.exports = {
} }
}, },
submit_mdi: function () { submit_mdi: function() {
this.send(this.mdi); this.send(this.mdi);
if (!this.history.length || this.history[0] != this.mdi) { if (!this.history.length || this.history[0] != this.mdi) {
@@ -324,7 +324,7 @@ module.exports = {
this.mdi = ""; this.mdi = "";
}, },
mdi_start_pause: function () { mdi_start_pause: function() {
if (this.state.xx == "RUNNING") { if (this.state.xx == "RUNNING") {
this.pause(); this.pause();
} else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") { } else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") {
@@ -334,15 +334,15 @@ module.exports = {
} }
}, },
load_history: function (index) { load_history: function(index) {
this.mdi = this.history[index]; this.mdi = this.history[index];
}, },
open: function () { open: function() {
utils.clickFileInput("gcode-file-input"); utils.clickFileInput("gcode-file-input");
}, },
upload: function (e) { upload: function(e) {
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
if (!files.length) { if (!files.length) {
return; return;
@@ -372,7 +372,7 @@ module.exports = {
}); });
}, },
delete_current: function () { delete_current: function() {
if (this.state.selected) { if (this.state.selected) {
api.delete(`file/${this.state.selected}`); api.delete(`file/${this.state.selected}`);
} }
@@ -380,12 +380,12 @@ module.exports = {
this.deleteGCode = false; this.deleteGCode = false;
}, },
delete_all: function () { delete_all: function() {
api.delete("file"); api.delete("file");
this.deleteGCode = false; this.deleteGCode = false;
}, },
home: function (axis) { home: function(axis) {
this.ask_home = false; this.ask_home = false;
if (typeof axis == "undefined") { if (typeof axis == "undefined") {
@@ -397,31 +397,31 @@ module.exports = {
} }
}, },
set_home: function (axis, position) { set_home: function(axis, position) {
api.put(`home/${axis}/set`, { position: parseFloat(position) }); api.put(`home/${axis}/set`, { position: parseFloat(position) });
}, },
unhome: function (axis) { unhome: function(axis) {
api.put(`home/${axis}/clear`); api.put(`home/${axis}/clear`);
}, },
show_set_position: function (axis) { show_set_position: function(axis) {
SvelteComponents.showDialog("SetAxisPosition", { axis }); SvelteComponents.showDialog("SetAxisPosition", { axis });
}, },
showMoveToZeroDialog: function (axes) { showMoveToZeroDialog: function(axes) {
SvelteComponents.showDialog("MoveToZero", { axes }); SvelteComponents.showDialog("MoveToZero", { axes });
}, },
showToolpathMessageDialog: function (axis) { showToolpathMessageDialog: function(axis) {
SvelteComponents.showDialog("Message", { title: this[axis].toolmsg }); SvelteComponents.showDialog("Message", { title: this[axis].toolmsg });
}, },
set_position: function (axis, position) { set_position: function(axis, position) {
api.put(`position/${axis}`, { "position": parseFloat(position) }); api.put(`position/${axis}`, { "position": parseFloat(position) });
}, },
zero_all: function () { zero_all: function() {
for (const axis of "xyzabc") { for (const axis of "xyzabc") {
if (this[axis].enabled) { if (this[axis].enabled) {
this.zero(axis); this.zero(axis);
@@ -429,7 +429,7 @@ module.exports = {
} }
}, },
zero: function (axis) { zero: function(axis) {
if (typeof axis == "undefined") { if (typeof axis == "undefined") {
this.zero_all(); this.zero_all();
} else { } else {
@@ -437,7 +437,7 @@ module.exports = {
} }
}, },
start_pause: function () { start_pause: function() {
if (this.state.xx == "RUNNING") { if (this.state.xx == "RUNNING") {
this.pause(); this.pause();
} else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") { } else if (this.state.xx == "STOPPING" || this.state.xx == "HOLDING") {
@@ -447,39 +447,39 @@ module.exports = {
} }
}, },
start: function () { start: function() {
api.put("start"); api.put("start");
}, },
pause: function () { pause: function() {
api.put("pause"); api.put("pause");
}, },
unpause: function () { unpause: function() {
api.put("unpause"); api.put("unpause");
}, },
optional_pause: function () { optional_pause: function() {
api.put("pause/optional"); api.put("pause/optional");
}, },
stop: function () { stop: function() {
api.put("stop"); api.put("stop");
}, },
step: function () { step: function() {
api.put("step"); api.put("step");
}, },
override_feed: function () { override_feed: function() {
api.put(`override/feed/${this.feed_override}`); api.put(`override/feed/${this.feed_override}`);
}, },
override_speed: function () { override_speed: function() {
api.put(`override/speed/${this.speed_override}`); api.put(`override/speed/${this.speed_override}`);
}, },
current: function (axis, value) { current: function(axis, value) {
const x = value / 32.0; const x = value / 32.0;
if (this.state[`${axis}pl`] == x) { if (this.state[`${axis}pl`] == x) {
return; return;
@@ -490,7 +490,7 @@ module.exports = {
this.send(JSON.stringify(data)); this.send(JSON.stringify(data));
}, },
showProbeDialog: function (probeType) { showProbeDialog: function(probeType) {
SvelteComponents.showDialog("Probe", { probeType }); SvelteComponents.showDialog("Probe", { probeType });
} }
}, },

View File

@@ -1,12 +1,12 @@
"use strict"; "use strict";
module.exports = function (prefix) { module.exports = function(prefix) {
if (typeof prefix == "undefined") { if (typeof prefix == "undefined") {
prefix = ""; prefix = "";
} }
const cookie = { const cookie = {
get: function (name, defaultValue) { get: function(name, defaultValue) {
const decodedCookie = decodeURIComponent(document.cookie); const decodedCookie = decodeURIComponent(document.cookie);
const ca = decodedCookie.split(";"); const ca = decodedCookie.split(";");
name = `${prefix + name}=`; name = `${prefix + name}=`;
@@ -24,7 +24,7 @@ module.exports = function (prefix) {
return defaultValue; return defaultValue;
}, },
set: function (name, value, days) { set: function(name, value, days) {
let offset = 2147483647; // Max value let offset = 2147483647; // Max value
if (typeof days != "undefined") { if (typeof days != "undefined") {
offset = days * 24 * 60 * 60 * 1000; offset = days * 24 * 60 * 60 * 1000;
@@ -36,11 +36,11 @@ module.exports = function (prefix) {
document.cookie = `${prefix}${name}=${value};${expires};path=/`; document.cookie = `${prefix}${name}=${value};${expires};path=/`;
}, },
set_bool: function (name, value) { set_bool: function(name, value) {
cookie.set(name, value ? "true" : "false"); cookie.set(name, value ? "true" : "false");
}, },
get_bool: function (name, defaultValue) { get_bool: function(name, defaultValue) {
return cookie.get(name, defaultValue ? "true" : "false") == "true"; return cookie.get(name, defaultValue ? "true" : "false") == "true";
} }
}; };

View File

@@ -5,7 +5,7 @@ const entityMap = {
"/": "&#x2F;", "`": "&#x60;", "=": "&#x3D;" }; "/": "&#x2F;", "`": "&#x60;", "=": "&#x3D;" };
function escapeHTML(s) { function escapeHTML(s) {
return s.replace(/[&<>"'`=\\/]/g, function (c) { return s.replace(/[&<>"'`=\\/]/g, function(c) {
return entityMap[c]; return entityMap[c];
}); });
} }
@@ -13,7 +13,7 @@ function escapeHTML(s) {
module.exports = { module.exports = {
template: "#gcode-viewer-template", template: "#gcode-viewer-template",
data: function () { data: function() {
return { return {
empty: true, empty: true,
file: "", file: "",
@@ -22,21 +22,21 @@ module.exports = {
}, },
events: { events: {
"gcode-load": function (file) { "gcode-load": function(file) {
this.load(file); this.load(file);
}, },
"gcode-clear": function () { "gcode-clear": function() {
this.clear(); this.clear();
}, },
"gcode-reload": function (file) { "gcode-reload": function(file) {
this.reload(file); this.reload(file);
}, },
"gcode-line": function (line) { "gcode-line": function(line) {
this.update_line(line); this.update_line(line);
} }
}, },
ready: function () { ready: function() {
this.clusterize = new Clusterize({ this.clusterize = new Clusterize({
rows: [], rows: [],
scrollElem: this.$el.querySelector(".clusterize-scroll"), scrollElem: this.$el.querySelector(".clusterize-scroll"),
@@ -46,7 +46,7 @@ module.exports = {
}); });
}, },
attached: function () { attached: function() {
if (typeof this.clusterize != "undefined") { if (typeof this.clusterize != "undefined") {
this.clusterize.refresh(true); this.clusterize.refresh(true);
} }
@@ -83,14 +83,14 @@ module.exports = {
Vue.nextTick(this.update_line); Vue.nextTick(this.update_line);
}, },
clear: function () { clear: function() {
this.empty = true; this.empty = true;
this.file = ""; this.file = "";
this.line = -1; this.line = -1;
this.clusterize.clear(); this.clusterize.clear();
}, },
reload: function (file) { reload: function(file) {
if (file != this.file) { if (file != this.file) {
return; return;
} }
@@ -99,7 +99,7 @@ module.exports = {
this.load(file); this.load(file);
}, },
highlight: function () { highlight: function() {
const highlights = this.$el.querySelectorAll(".highlight"); const highlights = this.$el.querySelectorAll(".highlight");
for (const highlight of highlights) { for (const highlight of highlights) {
highlight.className = (highlight.className || "") highlight.className = (highlight.className || "")

View File

@@ -7,11 +7,11 @@ module.exports = {
props: [ "state" ], props: [ "state" ],
computed: { computed: {
modbus_status: function () { modbus_status: function() {
return modbus.status_to_string(this.state.mx); return modbus.status_to_string(this.state.mx);
}, },
sense_error: function () { sense_error: function() {
let error = ""; let error = "";
if (this.state.motor_voltage_sense_error) { if (this.state.motor_voltage_sense_error) {
@@ -35,11 +35,11 @@ module.exports = {
}, },
methods: { methods: {
is_motor_enabled: function (motor) { is_motor_enabled: function(motor) {
return typeof this.state[`${motor}me`] != "undefined" && this.state[`${motor}me`]; return typeof this.state[`${motor}me`] != "undefined" && this.state[`${motor}me`];
}, },
get_min_pin: function (motor) { get_min_pin: function(motor) {
switch (motor) { switch (motor) {
case 0: return 3; case 0: return 3;
case 1: return 5; case 1: return 5;
@@ -48,7 +48,7 @@ module.exports = {
} }
}, },
get_max_pin: function (motor) { get_max_pin: function(motor) {
switch (motor) { switch (motor) {
case 0: return 4; case 0: return 4;
case 1: return 8; case 1: return 8;
@@ -57,7 +57,7 @@ module.exports = {
} }
}, },
motor_fault_class: function (motor, bit) { motor_fault_class: function(motor, bit) {
if (typeof motor == "undefined") { if (typeof motor == "undefined") {
const status = this.state["fa"]; const status = this.state["fa"];
@@ -78,7 +78,7 @@ module.exports = {
"fa-thumbs-up success"; "fa-thumbs-up success";
}, },
motor_reset: function (motor) { motor_reset: function(motor) {
if (typeof motor == "undefined") { if (typeof motor == "undefined") {
let cmd = ""; let cmd = "";
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {

View File

@@ -5,7 +5,7 @@ module.exports = {
props: [ "name", "state" ], props: [ "name", "state" ],
computed: { computed: {
klass: function () { klass: function() {
switch (this.name) { switch (this.name) {
case "min-switch-0": return this.get_motor_min_class(0); case "min-switch-0": return this.get_motor_min_class(0);
case "min-switch-1": return this.get_motor_min_class(1); case "min-switch-1": return this.get_motor_min_class(1);
@@ -25,7 +25,7 @@ module.exports = {
} }
}, },
tooltip: function () { tooltip: function() {
switch (this.name) { switch (this.name) {
case "min-switch-0": return this.get_motor_min_tooltip(0); case "min-switch-0": return this.get_motor_min_tooltip(0);
case "min-switch-1": return this.get_motor_min_tooltip(1); case "min-switch-1": return this.get_motor_min_tooltip(1);
@@ -47,7 +47,7 @@ module.exports = {
}, },
methods: { methods: {
get_io_state_class: function (active, state) { get_io_state_class: function(active, state) {
if (typeof active == "undefined" || typeof state == "undefined") { if (typeof active == "undefined" || typeof state == "undefined") {
return "fa-exclamation-triangle warn"; return "fa-exclamation-triangle warn";
} }
@@ -60,7 +60,7 @@ module.exports = {
return `${icon} ${active ? "active" : "inactive"}`; return `${icon} ${active ? "active" : "inactive"}`;
}, },
get_input_active: function (stateCode, typeCode) { get_input_active: function(stateCode, typeCode) {
const type = this.state[typeCode]; const type = this.state[typeCode];
const state = this.state[stateCode]; const state = this.state[stateCode];
@@ -73,23 +73,23 @@ module.exports = {
return false; return false;
}, },
get_input_class: function (stateCode, typeCode) { get_input_class: function(stateCode, typeCode) {
return this.get_io_state_class(this.get_input_active(stateCode, typeCode), this.state[stateCode]); return this.get_io_state_class(this.get_input_active(stateCode, typeCode), this.state[stateCode]);
}, },
get_output_class: function (output) { get_output_class: function(output) {
return this.get_io_state_class(this.state[`${output}oa`], this.state[`${output}os`]); return this.get_io_state_class(this.state[`${output}oa`], this.state[`${output}os`]);
}, },
get_motor_min_class: function (motor) { get_motor_min_class: function(motor) {
return this.get_input_class(`${motor}lw`, `${motor}ls`); return this.get_input_class(`${motor}lw`, `${motor}ls`);
}, },
get_motor_max_class: function (motor) { get_motor_max_class: function(motor) {
return this.get_input_class(`${motor}xw`, `${motor}xs`); return this.get_input_class(`${motor}xw`, `${motor}xs`);
}, },
get_tooltip: function (mode, active, state) { get_tooltip: function(mode, active, state) {
if (typeof mode == "undefined" || typeof active == "undefined" || typeof state == "undefined") { if (typeof mode == "undefined" || typeof active == "undefined" || typeof state == "undefined") {
return "Invalid"; return "Invalid";
} }
@@ -107,7 +107,7 @@ module.exports = {
return `Mode: ${mode}\nActive: ${active ? "True" : "False"}\nLevel: ${state}`; return `Mode: ${mode}\nActive: ${active ? "True" : "False"}\nLevel: ${state}`;
}, },
get_input_tooltip: function (stateCode, typeCode) { get_input_tooltip: function(stateCode, typeCode) {
let type = this.state[typeCode]; let type = this.state[typeCode];
if (type == 0) { if (type == 0) {
return "Disabled"; return "Disabled";
@@ -123,7 +123,7 @@ module.exports = {
return this.get_tooltip(type, active, state); return this.get_tooltip(type, active, state);
}, },
get_output_tooltip: function (output) { get_output_tooltip: function(output) {
let mode = this.state[`${output}om`]; let mode = this.state[`${output}om`];
switch (mode) { switch (mode) {
@@ -144,11 +144,11 @@ module.exports = {
return this.get_tooltip(mode, active, state); return this.get_tooltip(mode, active, state);
}, },
get_motor_min_tooltip: function (motor) { get_motor_min_tooltip: function(motor) {
return this.get_input_tooltip(`${motor}lw`, `${motor}ls`); return this.get_input_tooltip(`${motor}lw`, `${motor}ls`);
}, },
get_motor_max_tooltip: function (motor) { get_motor_max_tooltip: function(motor) {
return this.get_input_tooltip(`${motor}xw`, `${motor}xs`); return this.get_input_tooltip(`${motor}xw`, `${motor}xs`);
} }
} }

View File

@@ -39,7 +39,7 @@ function uuid(length) {
return s; return s;
} }
window.onload = function () { window.onload = function() {
if (typeof cookie_get("client-id") == "undefined") { if (typeof cookie_get("client-id") == "undefined") {
cookie_set("client-id", uuid(), 10000); cookie_set("client-id", uuid(), 10000);
} }
@@ -52,7 +52,7 @@ window.onload = function () {
Vue.component("console", require("./console")); Vue.component("console", require("./console"));
Vue.component("unit-value", require("./unit-value")); Vue.component("unit-value", require("./unit-value"));
Vue.filter("number", function (value) { Vue.filter("number", function(value) {
if (isNaN(value)) { if (isNaN(value)) {
return "NaN"; return "NaN";
} }
@@ -60,7 +60,7 @@ window.onload = function () {
return value.toLocaleString(); return value.toLocaleString();
}); });
Vue.filter("percent", function (value, precision) { Vue.filter("percent", function(value, precision) {
if (typeof value == "undefined") { if (typeof value == "undefined") {
return ""; return "";
} }
@@ -72,7 +72,7 @@ window.onload = function () {
return `${(value * 100.0).toFixed(precision)}%`; return `${(value * 100.0).toFixed(precision)}%`;
}); });
Vue.filter("non_zero_percent", function (value, precision) { Vue.filter("non_zero_percent", function(value, precision) {
if (!value) { if (!value) {
return ""; return "";
} }
@@ -84,7 +84,7 @@ window.onload = function () {
return `${(value * 100.0).toFixed(precision)}%`; return `${(value * 100.0).toFixed(precision)}%`;
}); });
Vue.filter("fixed", function (value, precision) { Vue.filter("fixed", function(value, precision) {
if (typeof value == "undefined") { if (typeof value == "undefined") {
return "0"; return "0";
} }
@@ -92,7 +92,7 @@ window.onload = function () {
return parseFloat(value).toFixed(precision); return parseFloat(value).toFixed(precision);
}); });
Vue.filter("upper", function (value) { Vue.filter("upper", function(value) {
if (typeof value == "undefined") { if (typeof value == "undefined") {
return ""; return "";
} }
@@ -100,7 +100,7 @@ window.onload = function () {
return value.toUpperCase(); return value.toUpperCase();
}); });
Vue.filter("time", function (value, precision) { Vue.filter("time", function(value, precision) {
if (isNaN(value)) { if (isNaN(value)) {
return ""; return "";
} }

View File

@@ -6,14 +6,14 @@ module.exports = {
props: [ "index", "model", "template", "enable" ], props: [ "index", "model", "template", "enable" ],
computed: { computed: {
has_user_value: function () { has_user_value: function() {
const type = this.model["reg-type"]; const type = this.model["reg-type"];
return type.indexOf("write") != -1 || type.indexOf("fixed") != -1; return type.indexOf("write") != -1 || type.indexOf("fixed") != -1;
} }
}, },
methods: { methods: {
change: function () { change: function() {
this.$dispatch("input-changed"); this.$dispatch("input-changed");
} }
} }

View File

@@ -11,7 +11,7 @@ const constants = {
module.exports = { module.exports = {
...constants, ...constants,
status_to_string: function (status) { status_to_string: function(status) {
switch (status) { switch (status) {
case constants.OK: return "Ok"; case constants.OK: return "Ok";
case constants.CRC: return "CRC error"; case constants.CRC: return "CRC error";

View File

@@ -5,11 +5,11 @@ module.exports = {
props: [ "index", "config", "template", "state" ], props: [ "index", "config", "template", "state" ],
computed: { computed: {
metric: function () { metric: function() {
return this.$root.display_units === "METRIC"; return this.$root.display_units === "METRIC";
}, },
is_slave: function () { is_slave: function() {
for (let i = 0; i < this.index; i++) { for (let i = 0; i < this.index; i++) {
if (this.motor.axis == this.config.motors[i].axis) { if (this.motor.axis == this.config.motors[i].axis) {
return true; return true;
@@ -19,47 +19,47 @@ module.exports = {
return false; return false;
}, },
motor: function () { motor: function() {
return this.config.motors[this.index]; return this.config.motors[this.index];
}, },
invalidMaxVelocity: function () { invalidMaxVelocity: function() {
return this.maxMaxVelocity < this.motor["max-velocity"]; return this.maxMaxVelocity < this.motor["max-velocity"];
}, },
maxMaxVelocity: function () { maxMaxVelocity: function() {
return 1 * (15 * this.umPerStep / this.motor["microsteps"]).toFixed(3); return 1 * (15 * this.umPerStep / this.motor["microsteps"]).toFixed(3);
}, },
ustepPerSec: function () { ustepPerSec: function() {
return this.rpm * this.stepsPerRev * this.motor["microsteps"] / 60; return this.rpm * this.stepsPerRev * this.motor["microsteps"] / 60;
}, },
rpm: function () { rpm: function() {
return 1000 * this.motor["max-velocity"] / this.motor["travel-per-rev"]; return 1000 * this.motor["max-velocity"] / this.motor["travel-per-rev"];
}, },
gForce: function () { gForce: function() {
return this.motor["max-accel"] * 0.0283254504; return this.motor["max-accel"] * 0.0283254504;
}, },
gForcePerMin: function () { gForcePerMin: function() {
return this.motor["max-jerk"] * 0.0283254504; return this.motor["max-jerk"] * 0.0283254504;
}, },
stepsPerRev: function () { stepsPerRev: function() {
return 360 / this.motor["step-angle"]; return 360 / this.motor["step-angle"];
}, },
umPerStep: function () { umPerStep: function() {
return this.motor["travel-per-rev"] * this.motor["step-angle"] / 0.36; return this.motor["travel-per-rev"] * this.motor["step-angle"] / 0.36;
}, },
milPerStep: function () { milPerStep: function() {
return this.umPerStep / 25.4; return this.umPerStep / 25.4;
}, },
invalidStallVelocity: function () { invalidStallVelocity: function() {
if (!this.motor["homing-mode"].startsWith("stall-")) { if (!this.motor["homing-mode"].startsWith("stall-")) {
return false; return false;
} }
@@ -67,12 +67,12 @@ module.exports = {
return this.maxStallVelocity < this.motor["search-velocity"]; return this.maxStallVelocity < this.motor["search-velocity"];
}, },
stallRPM: function () { stallRPM: function() {
const v = this.motor["search-velocity"]; const v = this.motor["search-velocity"];
return 1000 * v / this.motor["travel-per-rev"]; return 1000 * v / this.motor["travel-per-rev"];
}, },
maxStallVelocity: function () { maxStallVelocity: function() {
const maxRate = 900000 / this.motor["stall-sample-time"]; const maxRate = 900000 / this.motor["stall-sample-time"];
const ustep = this.motor["stall-microstep"]; const ustep = this.motor["stall-microstep"];
const angle = this.motor["step-angle"]; const angle = this.motor["step-angle"];
@@ -82,15 +82,15 @@ module.exports = {
return 1 * maxStall.toFixed(3); return 1 * maxStall.toFixed(3);
}, },
stallUStepPerSec: function () { stallUStepPerSec: function() {
const ustep = this.motor["stall-microstep"]; const ustep = this.motor["stall-microstep"];
return this.stallRPM * this.stepsPerRev * ustep / 60; return this.stallRPM * this.stepsPerRev * ustep / 60;
} }
}, },
events: { events: {
"input-changed": function () { "input-changed": function() {
Vue.nextTick(function () { Vue.nextTick(function() {
// Limit max-velocity // Limit max-velocity
if (this.invalidMaxVelocity) { if (this.invalidMaxVelocity) {
this.$set('motor["max-velocity"]', this.maxMaxVelocity); this.$set('motor["max-velocity"]', this.maxMaxVelocity);
@@ -109,7 +109,7 @@ module.exports = {
}, },
methods: { methods: {
show: function (name, templ) { show: function(name, templ) {
if (templ.hmodes == undefined) { if (templ.hmodes == undefined) {
return true; return true;
} }

View File

@@ -17,7 +17,7 @@
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
// Pan - right mouse, or arrow keys / touch: two-finger move // Pan - right mouse, or arrow keys / touch: two-finger move
const OrbitControls = function (object, domElement) { const OrbitControls = function(object, domElement) {
// internals // internals
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const scope = this; const scope = this;
@@ -119,21 +119,21 @@ const OrbitControls = function (object, domElement) {
this.zoom0 = this.object.zoom; this.zoom0 = this.object.zoom;
// public methods // public methods
this.getPolarAngle = function () { this.getPolarAngle = function() {
return spherical.phi; return spherical.phi;
}; };
this.getAzimuthalAngle = function () { this.getAzimuthalAngle = function() {
return spherical.theta; return spherical.theta;
}; };
this.saveState = function () { this.saveState = function() {
scope.target0.copy(scope.target); scope.target0.copy(scope.target);
scope.position0.copy(scope.object.position); scope.position0.copy(scope.object.position);
scope.zoom0 = scope.object.zoom; scope.zoom0 = scope.object.zoom;
}; };
this.reset = function () { this.reset = function() {
scope.target.copy(scope.target0); scope.target.copy(scope.target0);
scope.object.position.copy(scope.position0); scope.object.position.copy(scope.position0);
scope.object.zoom = scope.zoom0; scope.object.zoom = scope.zoom0;
@@ -145,7 +145,7 @@ const OrbitControls = function (object, domElement) {
state = STATE.NONE; state = STATE.NONE;
}; };
this.update = function () { this.update = function() {
const offset = new THREE.Vector3(); const offset = new THREE.Vector3();
// so camera.up is the orbit axis // so camera.up is the orbit axis
@@ -228,7 +228,7 @@ const OrbitControls = function (object, domElement) {
}; };
}(); }();
this.dispose = function () { this.dispose = function() {
scope.domElement.removeEventListener("contextmenu", onContextMenu, false); scope.domElement.removeEventListener("contextmenu", onContextMenu, false);
scope.domElement.removeEventListener("mousedown", onMouseDown, false); scope.domElement.removeEventListener("mousedown", onMouseDown, false);
scope.domElement.removeEventListener("wheel", onMouseWheel, false); scope.domElement.removeEventListener("wheel", onMouseWheel, false);
@@ -256,7 +256,7 @@ const OrbitControls = function (object, domElement) {
sphericalDelta.phi -= angle; sphericalDelta.phi -= angle;
} }
const panLeft = function () { const panLeft = function() {
const v = new THREE.Vector3(); const v = new THREE.Vector3();
return function panLeft(distance, objectMatrix) { return function panLeft(distance, objectMatrix) {
@@ -266,7 +266,7 @@ const OrbitControls = function (object, domElement) {
}; };
}(); }();
const panUp = function () { const panUp = function() {
const v = new THREE.Vector3(); const v = new THREE.Vector3();
return function panUp(distance, objectMatrix) { return function panUp(distance, objectMatrix) {
@@ -289,7 +289,7 @@ const OrbitControls = function (object, domElement) {
} }
// deltaX and deltaY are in pixels; right and down are positive // deltaX and deltaY are in pixels; right and down are positive
const pan = function () { const pan = function() {
const offset = new THREE.Vector3(); const offset = new THREE.Vector3();
return function pan(deltaX, deltaY) { return function pan(deltaX, deltaY) {

View File

@@ -8,7 +8,7 @@ module.exports = {
template: "#path-viewer-template", template: "#path-viewer-template",
props: [ "toolpath" ], props: [ "toolpath" ],
data: function () { data: function() {
return { return {
enabled: false, enabled: false,
loading: false, loading: false,
@@ -25,7 +25,7 @@ module.exports = {
}, },
computed: { computed: {
target: function () { target: function() {
return this.$el.querySelector(".path-viewer-content"); return this.$el.querySelector(".path-viewer-content");
}, },
@@ -44,65 +44,65 @@ module.exports = {
}, },
watch: { watch: {
toolpath: function () { toolpath: function() {
Vue.nextTick(this.update); Vue.nextTick(this.update);
}, },
surfaceMode: function (mode) { surfaceMode: function(mode) {
this.update_surface_mode(mode); this.update_surface_mode(mode);
}, },
small: function (enable) { small: function(enable) {
cookie.set_bool("small-path-view", enable); cookie.set_bool("small-path-view", enable);
Vue.nextTick(this.update_view); Vue.nextTick(this.update_view);
}, },
showPath: function (enable) { showPath: function(enable) {
cookie.set_bool("show-path", enable); cookie.set_bool("show-path", enable);
this.set_visible(this.pathView, enable); this.set_visible(this.pathView, enable);
}, },
showTool: function (enable) { showTool: function(enable) {
cookie.set_bool("show-tool", enable); cookie.set_bool("show-tool", enable);
this.set_visible(this.toolView, enable); this.set_visible(this.toolView, enable);
}, },
showAxes: function (enable) { showAxes: function(enable) {
cookie.set_bool("show-axes", enable); cookie.set_bool("show-axes", enable);
this.set_visible(this.axesView, enable); this.set_visible(this.axesView, enable);
}, },
showIntensity: function (enable) { showIntensity: function(enable) {
cookie.set_bool("show-intensity", enable); cookie.set_bool("show-intensity", enable);
Vue.nextTick(this.update); Vue.nextTick(this.update);
}, },
showBBox: function (enable) { showBBox: function(enable) {
cookie.set_bool("show-bbox", enable); cookie.set_bool("show-bbox", enable);
this.set_visible(this.bboxView, enable); this.set_visible(this.bboxView, enable);
this.set_visible(this.envelopeView, enable); this.set_visible(this.envelopeView, enable);
}, },
x: function () { x: function() {
this.axis_changed(); this.axis_changed();
}, },
y: function () { y: function() {
this.axis_changed(); this.axis_changed();
}, },
z: function () { z: function() {
this.axis_changed(); this.axis_changed();
} }
}, },
ready: function () { ready: function() {
this.graphics(); this.graphics();
Vue.nextTick(this.update); Vue.nextTick(this.update);
}, },
methods: { methods: {
update: async function () { update: async function() {
if (!this.webglAvailable) { if (!this.webglAvailable) {
return; return;
} }
@@ -145,7 +145,7 @@ module.exports = {
this.update_view(); this.update_view();
}, },
update_surface_mode: function (mode) { update_surface_mode: function(mode) {
if (!this.enabled) { if (!this.enabled) {
return; return;
} }
@@ -159,7 +159,7 @@ module.exports = {
this.set_visible(this.workpieceMesh, mode == "solid"); this.set_visible(this.workpieceMesh, mode == "solid");
}, },
load_surface: function (surface) { load_surface: function(surface) {
if (typeof surface == "undefined") { if (typeof surface == "undefined") {
this.vertices = undefined; this.vertices = undefined;
this.normals = undefined; this.normals = undefined;
@@ -179,14 +179,14 @@ module.exports = {
} }
}, },
set_visible: function (target, visible) { set_visible: function(target, visible) {
if (typeof target != "undefined") { if (typeof target != "undefined") {
target.visible = visible; target.visible = visible;
} }
this.dirty = true; this.dirty = true;
}, },
get_dims: function () { get_dims: function() {
const computedStyle = window.getComputedStyle(this.target); const computedStyle = window.getComputedStyle(this.target);
return { return {
@@ -195,7 +195,7 @@ module.exports = {
}; };
}, },
update_view: function () { update_view: function() {
if (!this.enabled) { if (!this.enabled) {
return; return;
} }
@@ -215,7 +215,7 @@ module.exports = {
this.dirty = true; this.dirty = true;
}, },
update_tool: function (tool) { update_tool: function(tool) {
if (!this.enabled) { if (!this.enabled) {
return; return;
} }
@@ -233,7 +233,7 @@ module.exports = {
tool.position.z = this.z.pos; tool.position.z = this.z.pos;
}, },
update_envelope: function (envelope) { update_envelope: function(envelope) {
if (!this.enabled || !this.axes.homed) { if (!this.enabled || !this.axes.homed) {
return; return;
} }
@@ -262,13 +262,13 @@ module.exports = {
} }
}, },
axis_changed: function () { axis_changed: function() {
this.update_tool(); this.update_tool();
this.update_envelope(); this.update_envelope();
this.dirty = true; this.dirty = true;
}, },
graphics: function () { graphics: function() {
if (!this.webglAvailable) { if (!this.webglAvailable) {
return; return;
} }
@@ -318,8 +318,8 @@ module.exports = {
this.controls.enableZoom = true; this.controls.enableZoom = true;
// Move lights with scene // Move lights with scene
this.controls.addEventListener("change", function (scope) { this.controls.addEventListener("change", function(scope) {
return function () { return function() {
keyLight.position.copy(scope.camera.position); keyLight.position.copy(scope.camera.position);
fillLight.position.copy(scope.camera.position); fillLight.position.copy(scope.camera.position);
backLight.position.copy(scope.camera.position); backLight.position.copy(scope.camera.position);
@@ -337,7 +337,7 @@ module.exports = {
this.render(); this.render();
}, },
create_surface_material: function () { create_surface_material: function() {
return new THREE.MeshPhongMaterial({ return new THREE.MeshPhongMaterial({
specular: 0x111111, specular: 0x111111,
shininess: 10, shininess: 10,
@@ -346,7 +346,7 @@ module.exports = {
}); });
}, },
draw_loading: function () { draw_loading: function() {
this.scene = new THREE.Scene(); this.scene = new THREE.Scene();
const geometry = new THREE.TextGeometry("Loading 3D View...", { const geometry = new THREE.TextGeometry("Loading 3D View...", {
@@ -369,7 +369,7 @@ module.exports = {
this.update_view(); this.update_view();
}, },
draw_workpiece: function (scene, material) { draw_workpiece: function(scene, material) {
if (typeof this.workpiece == "undefined") { if (typeof this.workpiece == "undefined") {
return; return;
} }
@@ -397,7 +397,7 @@ module.exports = {
return mesh; return mesh;
}, },
draw_surface: function (scene, material) { draw_surface: function(scene, material) {
if (typeof this.vertices == "undefined") { if (typeof this.vertices == "undefined") {
return; return;
} }
@@ -413,7 +413,7 @@ module.exports = {
return new THREE.Mesh(geometry, material); return new THREE.Mesh(geometry, material);
}, },
draw_tool: function (scene, bbox) { draw_tool: function(scene, bbox) {
// Tool size is relative to bounds // Tool size is relative to bounds
const size = bbox.getSize(new THREE.Vector3()); const size = bbox.getSize(new THREE.Vector3());
let length = (size.x + size.y + size.z) / 24; let length = (size.x + size.y + size.z) / 24;
@@ -441,7 +441,7 @@ module.exports = {
return mesh; return mesh;
}, },
draw_axis: function (axis, up, length, radius) { draw_axis: function(axis, up, length, radius) {
let color; let color;
if (axis == 0) { if (axis == 0) {
@@ -475,7 +475,7 @@ module.exports = {
return group; return group;
}, },
draw_axes: function (scene, bbox) { draw_axes: function(scene, bbox) {
const size = bbox.getSize(new THREE.Vector3()); const size = bbox.getSize(new THREE.Vector3());
let length = (size.x + size.y + size.z) / 3; let length = (size.x + size.y + size.z) / 3;
length /= 10; length /= 10;
@@ -500,7 +500,7 @@ module.exports = {
return group; return group;
}, },
get_color: function (speed) { get_color: function(speed) {
if (isNaN(speed)) { if (isNaN(speed)) {
return [ 255, 0, 0 ]; return [ 255, 0, 0 ];
} // Rapid } // Rapid
@@ -513,7 +513,7 @@ module.exports = {
return [ 0, 255 * intensity, 127 * (1 - intensity) ]; return [ 0, 255 * intensity, 127 * (1 - intensity) ];
}, },
draw_path: function (scene) { draw_path: function(scene) {
const geometry = new THREE.BufferGeometry(); const geometry = new THREE.BufferGeometry();
const material = new THREE.LineBasicMaterial({ const material = new THREE.LineBasicMaterial({
vertexColors: THREE.VertexColors, vertexColors: THREE.VertexColors,
@@ -543,14 +543,14 @@ module.exports = {
return line; return line;
}, },
create_empty_geom: function () { create_empty_geom: function() {
const geometry = new THREE.BufferGeometry(); const geometry = new THREE.BufferGeometry();
geometry.addAttribute("position", geometry.addAttribute("position",
new THREE.Float32BufferAttribute([], 3)); new THREE.Float32BufferAttribute([], 3));
return geometry; return geometry;
}, },
create_bbox_geom: function (bbox) { create_bbox_geom: function(bbox) {
const vertices = []; const vertices = [];
if (!bbox.isEmpty()) { if (!bbox.isEmpty()) {
@@ -593,7 +593,7 @@ module.exports = {
return geometry; return geometry;
}, },
draw_bbox: function (scene, bbox) { draw_bbox: function(scene, bbox) {
const geometry = this.create_bbox_geom(bbox); const geometry = this.create_bbox_geom(bbox);
const material = new THREE.LineBasicMaterial({ color: 0xffffff }); const material = new THREE.LineBasicMaterial({ color: 0xffffff });
const line = new THREE.LineSegments(geometry, material); const line = new THREE.LineSegments(geometry, material);
@@ -605,7 +605,7 @@ module.exports = {
return line; return line;
}, },
draw_envelope: function (scene) { draw_envelope: function(scene) {
const geometry = this.create_empty_geom(); const geometry = this.create_empty_geom();
const material = new THREE.LineBasicMaterial({ color: 0x00f7ff }); const material = new THREE.LineBasicMaterial({ color: 0x00f7ff });
const line = new THREE.LineSegments(geometry, material); const line = new THREE.LineSegments(geometry, material);
@@ -618,7 +618,7 @@ module.exports = {
return line; return line;
}, },
draw: function (scene) { draw: function(scene) {
// Lights // Lights
scene.add(this.ambient); scene.add(this.ambient);
scene.add(this.lights); scene.add(this.lights);
@@ -639,7 +639,7 @@ module.exports = {
this.envelopeView = this.draw_envelope(scene); this.envelopeView = this.draw_envelope(scene);
}, },
render: function () { render: function() {
window.requestAnimationFrame(this.render); window.requestAnimationFrame(this.render);
if (typeof this.scene == "undefined") { if (typeof this.scene == "undefined") {
@@ -652,7 +652,7 @@ module.exports = {
} }
}, },
get_model_bounds: function () { get_model_bounds: function() {
const bbox = new THREE.Box3(new THREE.Vector3(0, 0, 0), const bbox = new THREE.Box3(new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0.00001, 0.00001, 0.00001)); new THREE.Vector3(0.00001, 0.00001, 0.00001));
@@ -671,7 +671,7 @@ module.exports = {
return bbox; return bbox;
}, },
snap: function (view) { snap: function(view) {
if (this.loading) { if (this.loading) {
return; return;
} }

View File

@@ -1,7 +1,7 @@
module.exports = { module.exports = {
template: "#settings-view-template", template: "#settings-view-template",
attached: function () { attached: function() {
this.svelteComponent = SvelteComponents.createComponent( this.svelteComponent = SvelteComponents.createComponent(
"SettingsView", "SettingsView",
document.getElementById("settings") document.getElementById("settings")

View File

@@ -1,6 +1,6 @@
"use strict"; "use strict";
const Sock = function (url, retry, timeout) { const Sock = function(url, retry, timeout) {
if (!(this instanceof Sock)) { if (!(this instanceof Sock)) {
return new Sock(url, retry); return new Sock(url, retry);
} }
@@ -21,37 +21,37 @@ const Sock = function (url, retry, timeout) {
this.connect(); this.connect();
}; };
Sock.prototype.onmessage = function () { Sock.prototype.onmessage = function() {
// Ignore // Ignore
}; };
Sock.prototype.onopen = function () { Sock.prototype.onopen = function() {
// Ignore // Ignore
}; };
Sock.prototype.onclose = function () { Sock.prototype.onclose = function() {
// Ignore // Ignore
}; };
Sock.prototype.connect = function () { Sock.prototype.connect = function() {
console.debug("connecting to", this.url); console.debug("connecting to", this.url);
this.close(); this.close();
this._sock = new SockJS(this.url); this._sock = new SockJS(this.url);
this._sock.onmessage = function (e) { this._sock.onmessage = function(e) {
console.debug("msg:", e.data); console.debug("msg:", e.data);
this.heartbeat("msg"); this.heartbeat("msg");
this.onmessage(e); this.onmessage(e);
}.bind(this); }.bind(this);
this._sock.onopen = function () { this._sock.onopen = function() {
console.debug("connected"); console.debug("connected");
this.heartbeat("open"); this.heartbeat("open");
this.onopen(); this.onopen();
}.bind(this); }.bind(this);
this._sock.onclose = function () { this._sock.onclose = function() {
console.debug("disconnected"); console.debug("disconnected");
this._cancel_timeout(); this._cancel_timeout();
@@ -62,7 +62,7 @@ Sock.prototype.connect = function () {
}.bind(this); }.bind(this);
}; };
Sock.prototype._timedout = function () { Sock.prototype._timedout = function() {
// Divide timeout so slow browser doesn't trigger timeouts when the // Divide timeout so slow browser doesn't trigger timeouts when the
// connection is good. // connection is good.
if (this.divisions <= ++this.count) { if (this.divisions <= ++this.count) {
@@ -75,23 +75,23 @@ Sock.prototype._timedout = function () {
} }
}; };
Sock.prototype._cancel_timeout = function () { Sock.prototype._cancel_timeout = function() {
clearTimeout(this._timeout); clearTimeout(this._timeout);
this._timeout = undefined; this._timeout = undefined;
this.count = 0; this.count = 0;
}; };
Sock.prototype._set_timeout = function () { Sock.prototype._set_timeout = function() {
this._timeout = setTimeout(this._timedout.bind(this), this._timeout = setTimeout(this._timedout.bind(this),
this.timeout / this.divisions); this.timeout / this.divisions);
}; };
Sock.prototype.heartbeat = function () { Sock.prototype.heartbeat = function() {
this._cancel_timeout(); this._cancel_timeout();
this._set_timeout(); this._set_timeout();
}; };
Sock.prototype.close = function () { Sock.prototype.close = function() {
if (typeof this._sock != "undefined") { if (typeof this._sock != "undefined") {
const sock = this._sock; const sock = this._sock;
this._sock = undefined; this._sock = undefined;
@@ -99,7 +99,7 @@ Sock.prototype.close = function () {
} }
}; };
Sock.prototype.send = function (msg) { Sock.prototype.send = function(msg) {
this._sock.send(msg); this._sock.send(msg);
}; };

View File

@@ -5,16 +5,16 @@ module.exports = {
template: "#templated-input-template", template: "#templated-input-template",
props: [ "name", "model", "template" ], props: [ "name", "model", "template" ],
data: function () { data: function() {
return { view: "" }; return { view: "" };
}, },
computed: { computed: {
metric: function () { metric: function() {
return this.$root.display_units === "METRIC"; return this.$root.display_units === "METRIC";
}, },
_view: function () { _view: function() {
if (this.template.scale) { if (this.template.scale) {
if (this.metric) { if (this.metric) {
return 1 * this.model.toFixed(3); return 1 * this.model.toFixed(3);
@@ -26,13 +26,13 @@ module.exports = {
return this.model; return this.model;
}, },
units: function () { units: function() {
return (this.metric || !this.template.iunit) return (this.metric || !this.template.iunit)
? this.template.unit ? this.template.unit
: this.template.iunit; : this.template.iunit;
}, },
title: function () { title: function() {
let s = `Default :${this.template.default} ${(this.template.unit || "")}`; let s = `Default :${this.template.default} ${(this.template.unit || "")}`;
if (typeof this.template.help != "undefined") { if (typeof this.template.help != "undefined") {
@@ -44,11 +44,11 @@ module.exports = {
}, },
watch: { watch: {
_view: function () { _view: function() {
this.view = this._view; this.view = this._view;
}, },
view: function () { view: function() {
if (this.template.scale && !this.metric) { if (this.template.scale && !this.metric) {
this.model = this.view * this.template.scale; this.model = this.view * this.template.scale;
} else { } else {
@@ -57,12 +57,12 @@ module.exports = {
} }
}, },
ready: function () { ready: function() {
this.view = this._view; this.view = this._view;
}, },
methods: { methods: {
change: function () { change: function() {
this.$dispatch("input-changed"); this.$dispatch("input-changed");
} }
} }

View File

@@ -8,7 +8,7 @@ module.exports = {
template: "#tool-view-template", template: "#tool-view-template",
props: [ "config", "template", "state" ], props: [ "config", "template", "state" ],
data: function () { data: function() {
return { return {
address: 0, address: 0,
value: 0, value: 0,
@@ -91,41 +91,41 @@ module.exports = {
}, },
watch: { watch: {
"state.mr": function () { "state.mr": function() {
this.value = this.state.mr; this.value = this.state.mr;
} }
}, },
events: { events: {
"input-changed": function () { "input-changed": function() {
this.$dispatch("config-changed"); this.$dispatch("config-changed");
return false; return false;
}, },
}, },
ready: function () { ready: function() {
this.value = this.state.mr; this.value = this.state.mr;
}, },
computed: { computed: {
regs_tmpl: function () { regs_tmpl: function() {
return this.template["modbus-spindle"].regs; return this.template["modbus-spindle"].regs;
}, },
tool_type: function () { tool_type: function() {
return this.config.tool["tool-type"].toUpperCase(); return this.config.tool["tool-type"].toUpperCase();
}, },
selected_tool: function () { selected_tool: function() {
return this.config.tool["selected-tool"]; return this.config.tool["selected-tool"];
}, },
is_pwm_spindle: function () { is_pwm_spindle: function() {
return this.selected_tool == "pwm"; return this.selected_tool == "pwm";
}, },
is_modbus: function () { is_modbus: function() {
switch (this.selected_tool) { switch (this.selected_tool) {
case "disabled": case "disabled":
case "laser": case "laser":
@@ -138,13 +138,13 @@ module.exports = {
} }
}, },
modbus_status: function () { modbus_status: function() {
return modbus.status_to_string(this.state.mx); return modbus.status_to_string(this.state.mx);
} }
}, },
methods: { methods: {
change_selected_tool: function () { change_selected_tool: function() {
const selectedToolSettings = this.config["selected-tool-settings"] || {}; const selectedToolSettings = this.config["selected-tool-settings"] || {};
const settings = selectedToolSettings[this.selected_tool] || {}; const settings = selectedToolSettings[this.selected_tool] || {};
this.config.tool = merge({}, this.config.tool, settings["tool"]); this.config.tool = merge({}, this.config.tool, settings["tool"]);
@@ -157,7 +157,7 @@ module.exports = {
this.$dispatch("config-changed"); this.$dispatch("config-changed");
}, },
show_tool_settings: function (key) { show_tool_settings: function(key) {
switch (true) { switch (true) {
case key === "tool-type": case key === "tool-type":
case key === "selected-tool": case key === "selected-tool":
@@ -181,38 +181,38 @@ module.exports = {
} }
}, },
get_reg_type: function (reg) { get_reg_type: function(reg) {
return this.regs_tmpl.template["reg-type"].values[this.state[`${reg}vt`]]; return this.regs_tmpl.template["reg-type"].values[this.state[`${reg}vt`]];
}, },
get_reg_addr: function (reg) { get_reg_addr: function(reg) {
return this.state[`${reg}va`]; return this.state[`${reg}va`];
}, },
get_reg_value: function (reg) { get_reg_value: function(reg) {
return this.state[`${reg}vv`]; return this.state[`${reg}vv`];
}, },
get_reg_fails: function (reg) { get_reg_fails: function(reg) {
const fails = this.state[`${reg}vr`]; const fails = this.state[`${reg}vr`];
return fails == 255 ? "Max" : fails; return fails == 255 ? "Max" : fails;
}, },
show_modbus_field: function (key) { show_modbus_field: function(key) {
return key != "regs" && (key != "multi-write" || this.tool_type == "CUSTOM MODBUS VFD"); return key != "regs" && (key != "multi-write" || this.tool_type == "CUSTOM MODBUS VFD");
}, },
read: function (e) { read: function(e) {
e.preventDefault(); e.preventDefault();
api.put("modbus/read", { address: this.address }); api.put("modbus/read", { address: this.address });
}, },
write: function (e) { write: function(e) {
e.preventDefault(); e.preventDefault();
api.put("modbus/write", { address: this.address, value: this.value }); api.put("modbus/write", { address: this.address, value: this.value });
}, },
customize: function (e) { customize: function(e) {
e.preventDefault(); e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD"; this.config.tool["tool-type"] = "Custom Modbus VFD";
@@ -227,7 +227,7 @@ module.exports = {
this.$dispatch("config-changed"); this.$dispatch("config-changed");
}, },
clear: function (e) { clear: function(e) {
e.preventDefault(); e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD"; this.config.tool["tool-type"] = "Custom Modbus VFD";
@@ -241,7 +241,7 @@ module.exports = {
this.$dispatch("config-changed"); this.$dispatch("config-changed");
}, },
reset_failures: function (e) { reset_failures: function(e) {
e.preventDefault(); e.preventDefault();
const regs = this.config["modbus-spindle"].regs; const regs = this.config["modbus-spindle"].regs;
for (let reg = 0; reg < regs.length; reg++) { for (let reg = 0; reg < regs.length; reg++) {

View File

@@ -8,12 +8,12 @@ module.exports = {
computed: { computed: {
metric: { metric: {
cache: false, cache: false,
get: function () { get: function() {
return this.$root.display_units === "METRIC"; return this.$root.display_units === "METRIC";
} }
}, },
text: function () { text: function() {
let value = this.value; let value = this.value;
if (typeof value == "undefined") { if (typeof value == "undefined") {
return ""; return "";
@@ -27,7 +27,7 @@ module.exports = {
} }
}, },
ready: function () { ready: function() {
if (typeof this.precision == "undefined") { if (typeof this.precision == "undefined") {
this.precision = 0; this.precision = 0;
} }

View File

@@ -31,7 +31,7 @@ function formatFraction(value: number) {
export const numberWithUnit = { export const numberWithUnit = {
regex: /^\s*(?:(\d+)\s*\/\s*(\d+)|(\d*\.\d+)|(\d+(?:\.\d+)?))\s*("|in|inch|inches|mm|millimeters)\s*$/, regex: /^\s*(?:(\d+)\s*\/\s*(\d+)|(\d*\.\d+)|(\d+(?:\.\d+)?))\s*("|in|inch|inches|mm|millimeters)\s*$/,
parse: function (str: string) { parse: function(str: string) {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let [ , numerator, denominator, decimal1, decimal2, unit ]: any = str?.match(numberWithUnit.regex) ?? []; let [ , numerator, denominator, decimal1, decimal2, unit ]: any = str?.match(numberWithUnit.regex) ?? [];
@@ -68,7 +68,7 @@ export const numberWithUnit = {
return undefined; return undefined;
} }
}, },
normalize: function (str) { normalize: function(str) {
const value = this.parse(str); const value = this.parse(str);
switch (true) { switch (true) {