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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ module.exports = {
props: [ "axes", "colors", "enabled", "adjust", "step" ],
methods: {
jog: function (axis, ring, direction) {
jog: function(axis, ring, direction) {
const value = direction * this.value(ring);
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]);
},
release: function (axis) {
release: function(axis) {
if (!this.step) {
this.$dispatch("jog", this.axes[axis], 0);
}
},
value: function (ring) {
value: function(ring) {
const adjust = [ 0.01, 0.1, 1 ][this.adjust];
if (this.step) {
return adjust * [ 0.1, 1, 10, 100 ][ring];
@@ -28,7 +28,7 @@ module.exports = {
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);
value = parseFloat(value.toFixed(3));
return value + (this.step ? "" : "%");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
// Pan - right mouse, or arrow keys / touch: two-finger move
const OrbitControls = function (object, domElement) {
const OrbitControls = function(object, domElement) {
// internals
// eslint-disable-next-line @typescript-eslint/no-this-alias
const scope = this;
@@ -119,21 +119,21 @@ const OrbitControls = function (object, domElement) {
this.zoom0 = this.object.zoom;
// public methods
this.getPolarAngle = function () {
this.getPolarAngle = function() {
return spherical.phi;
};
this.getAzimuthalAngle = function () {
this.getAzimuthalAngle = function() {
return spherical.theta;
};
this.saveState = function () {
this.saveState = function() {
scope.target0.copy(scope.target);
scope.position0.copy(scope.object.position);
scope.zoom0 = scope.object.zoom;
};
this.reset = function () {
this.reset = function() {
scope.target.copy(scope.target0);
scope.object.position.copy(scope.position0);
scope.object.zoom = scope.zoom0;
@@ -145,7 +145,7 @@ const OrbitControls = function (object, domElement) {
state = STATE.NONE;
};
this.update = function () {
this.update = function() {
const offset = new THREE.Vector3();
// 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("mousedown", onMouseDown, false);
scope.domElement.removeEventListener("wheel", onMouseWheel, false);
@@ -256,7 +256,7 @@ const OrbitControls = function (object, domElement) {
sphericalDelta.phi -= angle;
}
const panLeft = function () {
const panLeft = function() {
const v = new THREE.Vector3();
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();
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
const pan = function () {
const pan = function() {
const offset = new THREE.Vector3();
return function pan(deltaX, deltaY) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,7 +31,7 @@ function formatFraction(value: number) {
export const numberWithUnit = {
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
let [ , numerator, denominator, decimal1, decimal2, unit ]: any = str?.match(numberWithUnit.regex) ?? [];
@@ -68,7 +68,7 @@ export const numberWithUnit = {
return undefined;
}
},
normalize: function (str) {
normalize: function(str) {
const value = this.parse(str);
switch (true) {