diff --git a/www/js/app.js b/www/js/app.js index 5da3d8ad..52522e22 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -158,7 +158,7 @@ function update_UI_firmware_target() { displayFlex('grblPanel'); grblpanel(); // id('FW_github').href = 'https://github.com/bdring/FluidNC'; - displayBlock('settings_filters'); + displayBlock('settings_filters'); // TODO: Or should this be 'preferences_filters'? id('control_x_position_label').innerHTML = 'Xw'; id('control_y_position_label').innerHTML = 'Yw'; diff --git a/www/js/controls.js b/www/js/controls.js index e9619ce7..94e2036c 100644 --- a/www/js/controls.js +++ b/www/js/controls.js @@ -166,9 +166,9 @@ function SendZerocommand(cmd) { } function JogFeedrate(axis) { - var controlName = axis.startsWith("Z") ? "control_z_velocity" : "control_xy_velocity"; - var feedrateValue = parseInt(id(controlName).value); - if (feedrateValue < 1 || isNaN(feedrateValue) || (feedrateValue === null)) { + const controlName = axis.startsWith("Z") ? "control_z_velocity" : "control_xy_velocity"; + const feedrateValue = Number.parseInt(id(controlName).value); + if (feedrateValue < 1 || Number.isNaN(feedrateValue) || (feedrateValue === null)) { alertdlg(translate_text_item("Out of range"), translate_text_item("Feedrate value must be at least 1 mm/min!")); return 1; } diff --git a/www/js/grbl.js b/www/js/grbl.js index 66bac305..77ff0362 100644 --- a/www/js/grbl.js +++ b/www/js/grbl.js @@ -55,10 +55,10 @@ function build_axis_selection() { } function control_changeaxis() { - var letter = getValue('control_select_axis') - setHTML('axisup', '+' + letter) - setHTML('axisdown', '-' + letter) - setHTML('homeZlabel', ' ' + letter + ' ') + const letter = getValue('control_select_axis') + setHTML('axisup', `+${letter}`) + setHTML('axisdown', `-${letter}`) + setHTML('homeZlabel', ` ${letter} `) switch (last_axis_letter) { case 'Z': axis_feedrate[2] = getValue('control_z_velocity') @@ -103,14 +103,14 @@ function grbl_clear_status() { } function grbl_set_probe_detected(state) { - var color = state ? 'green' : 'grey' - var glyph = state ? 'ok-circle' : 'record' + const color = state ? 'green' : 'grey' + const glyph = state ? 'ok-circle' : 'record' setHTML('touch_status_icon', get_icon_svg(glyph, '1.3em', '1.3em', color)) } function onprobemaxtravelChange() { - var travel = parseFloat(getValue('probemaxtravel')) - if (travel > 9999 || travel <= 0 || isNaN(travel) || travel === null) { + const travel = Number.parseFloat(getValue('grblpanel_probemaxtravel')) + if (travel > 9999 || travel <= 0 || Number.isNaN(travel) || travel === null) { alertdlg( translate_text_item('Out of range'), translate_text_item('Value of maximum probe travel must be between 1 mm and 9999 mm !') @@ -121,8 +121,8 @@ function onprobemaxtravelChange() { } function onprobefeedrateChange() { - var feedratevalue = parseInt(getValue('probefeedrate')) - if (feedratevalue <= 0 || feedratevalue > 9999 || isNaN(feedratevalue) || feedratevalue === null) { + const feedratevalue = Number.parseInt(getValue('grblpanel_probefeedrate')) + if (feedratevalue <= 0 || feedratevalue > 9999 || Number.isNaN(feedratevalue) || feedratevalue === null) { alertdlg( translate_text_item('Out of range'), translate_text_item('Value of probe feedrate must be between 1 mm/min and 9999 mm/min !') @@ -133,8 +133,8 @@ function onprobefeedrateChange() { } function onproberetractChange() { - var thickness = parseFloat(getValue('proberetract')) - if (thickness < 0 || thickness > 999 || isNaN(thickness) || thickness === null) { + const thickness = Number.parseFloat(getValue('grblpanel_proberetract')) + if (thickness < 0 || thickness > 999 || Number.isNaN(thickness) || thickness === null) { alertdlg( translate_text_item('Out of range'), translate_text_item('Value of probe retract must be between 0 mm and 9999 mm !') @@ -145,8 +145,8 @@ function onproberetractChange() { } function onprobetouchplatethicknessChange() { - var thickness = parseFloat(getValue('probetouchplatethickness')) - if (thickness < 0 || thickness > 999 || isNaN(thickness) || thickness === null) { + const thickness = Number.parseFloat(getValue('grblpanel_probetouchplatethickness')) + if (thickness < 0 || thickness > 999 || Number.isNaN(thickness) || thickness === null) { alertdlg( translate_text_item('Out of range'), translate_text_item('Value of probe touch plate thickness must be between 0 mm and 9999 mm !') @@ -160,8 +160,8 @@ var reportType = 'none' function disablePolling() { setAutocheck(false) - // setValue('statusInterval_check', 0); - if (interval_status != -1) { + // setValue('grblpanel_interval_status', 0); + if (interval_status !== -1) { clearInterval(interval_status) interval_status = -1 } @@ -171,56 +171,51 @@ function disablePolling() { } function enablePolling() { - var interval = parseFloat(getValue('statusInterval_check')) - if (!isNaN(interval) && interval == 0) { - if (interval_status != -1) { + const interval = Number.parseFloat(getValue('grblpanel_interval_status')) + if (!Number.isNaN(interval) && interval === 0) { + if (interval_status !== -1) { clearInterval(interval_status) } disablePolling() reportNone() return } - if (!isNaN(interval) && interval > 0 && interval < 100) { - if (interval_status != -1) { + if (!Number.isNaN(interval) && interval > 0 && interval < 100) { + if (interval_status !== -1) { clearInterval(interval_status) } - interval_status = setInterval(function () { - get_status() - }, interval * 1000) + interval_status = setInterval(() => { get_status() }, interval * 1000) reportType = 'polled' setChecked('report_poll', true) return } - setValue('statusInterval_check', 0) - alertdlg( - translate_text_item('Out of range'), - translate_text_item('Value of auto-check must be between 0s and 99s !!') - ) + setValue('grblpanel_interval_status', 0) + alertdlg(translate_text_item('Out of range'), translate_text_item('Value of auto-check must be between 0s and 99s !!')) disablePolling() reportNone() } function tryAutoReport() { - if (reportType == 'polled') { - disablePolling() + if (reportType === 'polled') { + disablePolling(); } - reportType == 'auto' - var interval = id('autoReportInterval').value - if (interval == 0) { - enablePolling() - return + reportType = "auto"; + const interval = id("grblpanel_autoreport_interval").value ?? 0; + if (interval === 0) { + enablePolling(); + return; } - setChecked('report_auto', true) + setChecked("report_auto", true); reportType = 'auto' SendPrinterCommand( - '$Report/Interval=' + interval, + `$Report/Interval=${interval}`, true, // Do nothing more on success - function () {}, + () => { }, // Fall back to polling if the firmware does not support auto-reports - function () { - enablePolling() + () => { + enablePolling(); }, 99.1, @@ -455,8 +450,8 @@ function finalize_probing() { } function show_grbl_SD(sdName, sdPercent) { - var status = sdName - ? sdName + ' ' + sdPercent + '%' + const status = sdName + ? `${sdName} ${sdPercent}%` : '' setHTML('grbl_SD_status', status) } @@ -494,39 +489,34 @@ function grblProcessStatus(response) { if (grbl.mpos) { MPOS = grbl.mpos if (WCO) { - WPOS = grbl.mpos.map(function (v, index) { - return v - WCO[index] - }) + WPOS = grbl.mpos.map((v, index) => v - WCO[index]) } } else if (grbl.wpos) { WPOS = grbl.wpos if (WCO) { - MPOS = grbl.wpos.map(function (v, index) { - return v + WCO[index] - }) + MPOS = grbl.wpos.map((v, index) => v + WCO[index]) } } show_grbl_position(WPOS, MPOS) show_grbl_status(grbl.stateName, grbl.message, grbl.sdName) show_grbl_SD(grbl.sdName, grbl.sdPercent) - show_grbl_probe_status(grbl.pins && grbl.pins.indexOf('P') != -1) + show_grbl_probe_status(grbl.pins && grbl.pins.indexOf('P') !== -1) tabletGrblState(grbl, response) } function grbl_reset() { - if (probe_progress_status != 0) probe_failed_notification() + if (probe_progress_status !== 0) probe_failed_notification() SendRealtimeCmd(0x18) } function grblGetProbeResult(response) { - var tab1 = response.split(':') + const tab1 = response.split(':') if (tab1.length > 2) { - var status = tab1[2].replace(']', '') - if (parseInt(status.trim()) == 1) { - if (probe_progress_status != 0) { - var cmd = - '$J=G90 G21 F1000 Z' + - (parseFloat(getValue('probetouchplatethickness')) + parseFloat(getValue('proberetract'))) + const status = tab1[2].replace(']', '') + if (Number.parseInt(status.trim()) === 1) { + if (probe_progress_status !== 0) { + const cmd = + `$J=G90 G21 F1000 Z${Number.parseFloat(getValue('probetouchplatethickness')) + Number.parseFloat(getValue('grblpanel_proberetract'))}` SendPrinterCommand(cmd, true, null, null, 0, 1) finalize_probing() } @@ -541,7 +531,7 @@ function probe_failed_notification() { alertdlg(translate_text_item('Error'), translate_text_item('Probe failed !')) beep(3, 140, 261) } -var modalModes = [ +const modalModes = [ { name: 'motion', values: ['G80', 'G0', 'G1', 'G2', 'G3', 'G38.1', 'G38.2', 'G38.3', 'G38.4'] }, { name: 'wcs', values: ['G54', 'G55', 'G56', 'G57', 'G58', 'G59'] }, { name: 'plane', values: ['G17', 'G18', 'G19'] }, @@ -621,7 +611,7 @@ function grblHandleMessage(msg) { .replace(/(\b(?:bl|br|tr|tl)\b):/g, '"$1":') .replace('CLBM:', '') .replace(/,]$/, ']') - let measurements = JSON.parse(validJsonMSG) + const measurements = JSON.parse(validJsonMSG) handleCalibrationData(measurements) } if (msg.startsWith('<')) { @@ -705,10 +695,10 @@ function grblHandleMessage(msg) { } } if (msg.startsWith('error:') || msg.startsWith('ALARM:') || msg.startsWith('Hold:') || msg.startsWith('Door:')) { - if (probe_progress_status != 0) { + if (probe_progress_status !== 0) { probe_failed_notification() } - if (grbl_error_msg.length == 0) { + if (grbl_error_msg.length === 0) { grbl_error_msg = translate_text_item(msg.trim()) } return @@ -734,15 +724,11 @@ function StartProbeProcess() { return } cmd += - parseFloat(getValue('probemaxtravel')) + - ' F' + - parseInt(getValue('probefeedrate')) + - ' P' + - getValue('probetouchplatethickness') + `${Number.parseFloat(getValue('grblpanel_probemaxtravel'))} F${Number.parseInt(getValue('grblpanel_probefeedrate'))} P${getValue('grblpanel_probetouchplatethickness')}` console.log(cmd) probe_progress_status = 1 - var restoreReport = false - if (reportType == 'none') { + let restoreReport = false + if (reportType === 'none') { tryAutoReport() // will fall back to polled if autoreport fails restoreReport = true } diff --git a/www/js/preferencesdlg.js b/www/js/preferencesdlg.js index 5c99aabf..b7487fd9 100644 --- a/www/js/preferencesdlg.js +++ b/www/js/preferencesdlg.js @@ -82,7 +82,7 @@ function initpreferences() { displayBlock('grbl_pref_panel'); displayTable('has_tft_sd'); displayTable('has_tft_usb'); - + default_preferenceslist = JSON.parse(defaultpreferenceslist); } @@ -156,32 +156,32 @@ function Preferences_build_list(response_text) { } function ontogglePing(forcevalue) { - if (typeof forcevalue !== 'undefined') enable_ping = forcevalue - else enable_ping = !enable_ping - if (enable_ping) { - if (interval_ping !== -1) clearInterval(interval_ping) - last_ping = Date.now() - interval_ping = setInterval(() => {check_ping()}, 10 * 1000) - console.log('enable ping') - } else { - if (interval_ping !== -1) clearInterval(interval_ping) - console.log('disable ping') - } + if (typeof forcevalue !== 'undefined') enable_ping = forcevalue + else enable_ping = !enable_ping + if (enable_ping) { + if (interval_ping !== -1) clearInterval(interval_ping) + last_ping = Date.now() + interval_ping = setInterval(() => { check_ping() }, 10 * 1000) + console.log('enable ping') + } else { + if (interval_ping !== -1) clearInterval(interval_ping) + console.log('disable ping') + } } function applypreferenceslist() { //Assign each control state translate_text(preferenceslist[0].language); build_HTML_setting_list(current_setting_filter); - if (typeof id('camtab') != "undefined") { - var camoutput = false; - if (typeof(preferenceslist[0].enable_camera) !== 'undefined') { + if (typeof id('camtab') !== "undefined") { + let camoutput = false; + if (typeof (preferenceslist[0].enable_camera) !== 'undefined') { if (preferenceslist[0].enable_camera === 'true') { displayBlock('camtablink'); camera_GetAddress(); - if (typeof(preferenceslist[0].auto_load_camera) !== 'undefined') { + if (typeof (preferenceslist[0].auto_load_camera) !== 'undefined') { if (preferenceslist[0].auto_load_camera === 'true') { - var saddress = id('camera_webaddress').value + const saddress = id('camera_webaddress').value camera_loadframe(); camoutput = true; } @@ -245,29 +245,27 @@ function applypreferenceslist() { if (preferenceslist[0].enable_files_panel === 'true') displayFlex('filesPanel'); else displayNone('filesPanel'); - - if (preferenceslist[0].has_TFT_SD === 'true'){ - displayFlex('files_refresh_tft_sd_btn'); - } - else { + + if (preferenceslist[0].has_TFT_SD === 'true') { + displayFlex('files_refresh_tft_sd_btn'); + } else { displayNone('files_refresh_tft_sd_btn'); } - + if (preferenceslist[0].has_TFT_USB === 'true') { displayFlex('files_refresh_tft_usb_btn'); - } - else { + } else { displayNone('files_refresh_tft_usb_btn'); } - - if ((preferenceslist[0].has_TFT_SD === 'true') || (preferenceslist[0].has_TFT_USB === 'true')){ + + if ((preferenceslist[0].has_TFT_SD === 'true') || (preferenceslist[0].has_TFT_USB === 'true')) { displayFlex('files_refresh_printer_sd_btn'); displayNone('files_refresh_btn'); } else { displayNone('files_refresh_printer_sd_btn'); displayFlex('files_refresh_btn'); } - + if (preferenceslist[0].enable_commands_panel === 'true') { displayFlex('commandsPanel'); if (preferenceslist[0].enable_autoscroll === 'true') { @@ -276,56 +274,56 @@ function applypreferenceslist() { } else id('monitor_enable_autoscroll').checked = false; } else displayNone('commandsPanel'); - var autoReportValue = parseInt(preferenceslist[0].autoreport_interval); - var autoReportChanged = id('autoReportInterval').value != autoReportValue; + const autoReportValue = Number.parseInt(preferenceslist[0].autoreport_interval); + const autoReportChanged = id("preferences_autoReport_Interval").value !== autoReportValue; if (autoReportChanged) { - id('autoReportInterval').value = autoReportValue; + id("preferences_autoReport_Interval").value = autoReportValue; } - var statusIntervalValue = parseInt(preferenceslist[0].interval_status); - statusIntervalChanged = id('statusInterval_check').value != statusIntervalValue; + const statusIntervalValue = Number.parseInt(preferenceslist[0].interval_status); + statusIntervalChanged = id('preferences_status_Interval_check').value !== statusIntervalValue; if (statusIntervalChanged) { - id('statusInterval_check').value = statusIntervalValue; + id('preferences_status_Interval_check').value = statusIntervalValue; } if (autoReportChanged || statusIntervalChanged) { onAutoReportIntervalChange(); } - id('posInterval_check').value = parseInt(preferenceslist[0].interval_positions); - id('control_xy_velocity').value = parseInt(preferenceslist[0].xy_feedrate); - id('control_z_velocity').value = parseInt(preferenceslist[0].z_feedrate); + id('preferences_pos_Interval_check').value = Number.parseInt(preferenceslist[0].interval_positions); + id('preferences_control_xy_velocity').value = Number.parseInt(preferenceslist[0].xy_feedrate); + id('preferences_control_z_velocity').value = Number.parseInt(preferenceslist[0].z_feedrate); - if (grblaxis > 2 )axis_Z_feedrate = parseInt(preferenceslist[0].z_feedrate); - if (grblaxis > 3 )axis_A_feedrate = parseInt(preferenceslist[0].a_feedrate); - if (grblaxis > 4 )axis_B_feedrate = parseInt(preferenceslist[0].b_feedrate); - if (grblaxis > 5 )axis_C_feedrate = parseInt(preferenceslist[0].c_feedrate); - - if (grblaxis > 3 ){ - var letter = id('control_select_axis').value; - switch(letter) { + if (grblaxis > 2) axis_Z_feedrate = Number.parseInt(preferenceslist[0].z_feedrate); + if (grblaxis > 3) axis_A_feedrate = Number.parseInt(preferenceslist[0].a_feedrate); + if (grblaxis > 4) axis_B_feedrate = Number.parseInt(preferenceslist[0].b_feedrate); + if (grblaxis > 5) axis_C_feedrate = Number.parseInt(preferenceslist[0].c_feedrate); + + if (grblaxis > 3) { + const letter = id('control_select_axis').value; + switch (letter) { case "Z": - id('control_z_velocity').value = axis_Z_feedrate; + id('preferences_control_z_velocity').value = axis_Z_feedrate; break; case "A": - id('control_z_velocity').value = axis_A_feedrate; + id('preferences_control_z_velocity').value = axis_A_feedrate; break; case "B": - id('control_z_velocity').value = axis_B_feedrate; + id('preferences_control_z_velocity').value = axis_B_feedrate; break; case "C": - id('control_z_velocity').value = axis_C_feedrate; + id('preferences_control_z_velocity').value = axis_C_feedrate; break; - } + } } - id('probemaxtravel').value = parseFloat(preferenceslist[0].probemaxtravel); - id('probefeedrate').value = parseInt(preferenceslist[0].probefeedrate); - id('proberetract').value = parseFloat(preferenceslist[0].proberetract); - id('probetouchplatethickness').value = parseFloat(preferenceslist[0].probetouchplatethickness); + id('preferences_probemaxtravel').value = Number.parseFloat(preferenceslist[0].probemaxtravel); + id('preferences_probefeedrate').value = Number.parseInt(preferenceslist[0].probefeedrate); + id('preferences_proberetract').value = Number.parseFloat(preferenceslist[0].proberetract); + id('preferences_probetouchplatethickness').value = Number.parseFloat(preferenceslist[0].probetouchplatethickness); build_file_filter_list(preferenceslist[0].f_filters); } function showpreferencesdlg() { - var modal = setactiveModal('preferencesdlg.html'); + const modal = setactiveModal('preferencesdlg.html'); if (modal == null) return; language_save = language; build_dlg_preferences_list(); @@ -335,133 +333,133 @@ function showpreferencesdlg() { function build_dlg_preferences_list() { //use preferenceslist to set dlg status - var content = " @@ -21,7 +22,8 @@
"; - content += get_icon_svg("flag") + " "; + let content = "
"; + content += `${get_icon_svg("flag")} `; content += build_language_list("language_preferences"); content += "
"; id("preferences_langage_list").innerHTML = content; //camera - if (typeof(preferenceslist[0].enable_camera) !== 'undefined') { + if (typeof (preferenceslist[0].enable_camera) !== 'undefined') { id('show_camera_panel').checked = (preferenceslist[0].enable_camera === 'true'); } else id('show_camera_panel').checked = false; //autoload camera - if (typeof(preferenceslist[0].auto_load_camera) !== 'undefined') { + if (typeof (preferenceslist[0].auto_load_camera) !== 'undefined') { id('autoload_camera_panel').checked = (preferenceslist[0].auto_load_camera === 'true'); } else id('autoload_camera_panel').checked = false; //camera address - if (typeof(preferenceslist[0].camera_address) !== 'undefined') { + if (typeof (preferenceslist[0].camera_address) !== 'undefined') { id('preferences_camera_webaddress').value = HTMLDecode(preferenceslist[0].camera_address); } else id('preferences_camera_webaddress').value = ""; //DHT - if (typeof(preferenceslist[0].enable_DHT) !== 'undefined') { + if (typeof (preferenceslist[0].enable_DHT) !== 'undefined') { id('enable_DHT').checked = (preferenceslist[0].enable_DHT === 'true'); } else id('enable_DHT').checked = false; //lock UI - if (typeof(preferenceslist[0].enable_lock_UI) !== 'undefined') { + if (typeof (preferenceslist[0].enable_lock_UI) !== 'undefined') { id('enable_lock_UI').checked = (preferenceslist[0].enable_lock_UI === 'true'); } else id('enable_lock_UI').checked = false; //Monitor connection - if (typeof(preferenceslist[0].enable_ping) !== 'undefined') { + if (typeof (preferenceslist[0].enable_ping) !== 'undefined') { id('enable_ping').checked = (preferenceslist[0].enable_ping === 'true'); } else id('enable_ping').checked = false; //grbl panel - if (typeof(preferenceslist[0].enable_grbl_panel) !== 'undefined') { + if (typeof (preferenceslist[0].enable_grbl_panel) !== 'undefined') { id('show_grbl_panel').checked = (preferenceslist[0].enable_grbl_panel === 'true'); } else id('show_grbl_panel').checked = false; //grbl probe panel - if (typeof(preferenceslist[0].enable_grbl_probe_panel) !== 'undefined') { + if (typeof (preferenceslist[0].enable_grbl_probe_panel) !== 'undefined') { id('show_grbl_probe_tab').checked = (preferenceslist[0].enable_grbl_probe_panel === 'true'); } else id('show_grbl_probe_tab').checked = false; //control panel - if (typeof(preferenceslist[0].enable_control_panel) !== 'undefined') { + if (typeof (preferenceslist[0].enable_control_panel) !== 'undefined') { id('show_control_panel').checked = (preferenceslist[0].enable_control_panel === 'true'); } else id('show_control_panel').checked = false; //files panel - if (typeof(preferenceslist[0].enable_files_panel) !== 'undefined') { + if (typeof (preferenceslist[0].enable_files_panel) !== 'undefined') { id('show_files_panel').checked = (preferenceslist[0].enable_files_panel === 'true'); } else id('show_files_panel').checked = false; //TFT SD - if (typeof(preferenceslist[0].has_TFT_SD) !== 'undefined') { + if (typeof (preferenceslist[0].has_TFT_SD) !== 'undefined') { id('has_tft_sd').checked = (preferenceslist[0].has_TFT_SD === 'true'); } else id('has_tft_sd').checked = false; //TFT USB - if (typeof(preferenceslist[0].has_TFT_USB) !== 'undefined') { + if (typeof (preferenceslist[0].has_TFT_USB) !== 'undefined') { id('has_tft_usb').checked = (preferenceslist[0].has_TFT_USB === 'true'); } else id('has_tft_usb').checked = false; //commands - if (typeof(preferenceslist[0].enable_commands_panel) !== 'undefined') { + if (typeof (preferenceslist[0].enable_commands_panel) !== 'undefined') { id('show_commands_panel').checked = (preferenceslist[0].enable_commands_panel === 'true'); } else id('show_commands_panel').checked = false; //autoreport interval - if (typeof(preferenceslist[0].autoreport_interval) !== 'undefined') { - id('preferences_autoReport_Interval').value = parseInt(preferenceslist[0].autoreport_interval); - } else id('preferences_autoReport_Interval').value = parseInt(default_preferenceslist[0].autoreport_interval); + if (typeof (preferenceslist[0].autoreport_interval) !== 'undefined') { + id('preferences_autoReport_Interval').value = Number.parseInt(preferenceslist[0].autoreport_interval); + } else id('preferences_autoReport_Interval').value = Number.parseInt(default_preferenceslist[0].autoreport_interval); //interval positions - if (typeof(preferenceslist[0].interval_positions) !== 'undefined') { - id('preferences_pos_Interval_check').value = parseInt(preferenceslist[0].interval_positions); - } else id('preferences_pos_Interval_check').value = parseInt(default_preferenceslist[0].interval_positions); + if (typeof (preferenceslist[0].interval_positions) !== 'undefined') { + id('preferences_pos_Interval_check').value = Number.parseInt(preferenceslist[0].interval_positions); + } else id('preferences_pos_Interval_check').value = Number.parseInt(default_preferenceslist[0].interval_positions); //interval status - if (typeof(preferenceslist[0].interval_status) !== 'undefined') { - id('preferences_status_Interval_check').value = parseInt(preferenceslist[0].interval_status); - } else id('preferences_status_Interval_check').value = parseInt(default_preferenceslist[0].interval_status); + if (typeof (preferenceslist[0].interval_status) !== 'undefined') { + id('preferences_status_Interval_check').value = Number.parseInt(preferenceslist[0].interval_status); + } else id('preferences_status_Interval_check').value = Number.parseInt(default_preferenceslist[0].interval_status); //xy feedrate - if (typeof(preferenceslist[0].xy_feedrate) !== 'undefined') { - id('preferences_control_xy_velocity').value = parseInt(preferenceslist[0].xy_feedrate); - } else id('preferences_control_xy_velocity').value = parseInt(default_preferenceslist[0].xy_feedrate); + if (typeof (preferenceslist[0].xy_feedrate) !== 'undefined') { + id('preferences_control_xy_velocity').value = Number.parseInt(preferenceslist[0].xy_feedrate); + } else id('preferences_control_xy_velocity').value = Number.parseInt(default_preferenceslist[0].xy_feedrate); if (grblaxis > 2) { //z feedrate - if (typeof(preferenceslist[0].z_feedrate) !== 'undefined') { - id('preferences_control_z_velocity').value = parseInt(preferenceslist[0].z_feedrate); - } else id('preferences_control_z_velocity').value = parseInt(default_preferenceslist[0].z_feedrate); + if (typeof (preferenceslist[0].z_feedrate) !== 'undefined') { + id('preferences_control_z_velocity').value = Number.parseInt(preferenceslist[0].z_feedrate); + } else id('preferences_control_z_velocity').value = Number.parseInt(default_preferenceslist[0].z_feedrate); } if (grblaxis > 3) { //a feedrate - if (typeof(preferenceslist[0].a_feedrate) !== 'undefined') { - id('preferences_control_a_velocity').value = parseInt(preferenceslist[0].a_feedrate); - } else id('preferences_control_a_velocity').value = parseInt(default_preferenceslist[0].a_feedrate); + if (typeof (preferenceslist[0].a_feedrate) !== 'undefined') { + id('preferences_control_a_velocity').value = Number.parseInt(preferenceslist[0].a_feedrate); + } else id('preferences_control_a_velocity').value = Number.parseInt(default_preferenceslist[0].a_feedrate); } if (grblaxis > 4) { //b feedrate - if (typeof(preferenceslist[0].b_feedrate) !== 'undefined') { - id('preferences_control_b_velocity').value = parseInt(preferenceslist[0].b_feedrate); - } else id('preferences_control_b_velocity').value = parseInt(default_preferenceslist[0].b_feedrate); + if (typeof (preferenceslist[0].b_feedrate) !== 'undefined') { + id('preferences_control_b_velocity').value = Number.parseInt(preferenceslist[0].b_feedrate); + } else id('preferences_control_b_velocity').value = Number.parseInt(default_preferenceslist[0].b_feedrate); } if (grblaxis > 5) { //c feedrate - if (typeof(preferenceslist[0].c_feedrate) !== 'undefined') { - id('preferences_control_c_velocity').value = parseInt(preferenceslist[0].c_feedrate); - } else id('preferences_control_c_velocity').value = parseInt(default_preferenceslist[0].c_feedrate); + if (typeof (preferenceslist[0].c_feedrate) !== 'undefined') { + id('preferences_control_c_velocity').value = Number.parseInt(preferenceslist[0].c_feedrate); + } else id('preferences_control_c_velocity').value = Number.parseInt(default_preferenceslist[0].c_feedrate); } //probemaxtravel - if ((typeof(preferenceslist[0].probemaxtravel) !== 'undefined') && (preferenceslist[0].probemaxtravel.length != 0)) { - id('preferences_probemaxtravel').value = parseFloat(preferenceslist[0].probemaxtravel); + if ((typeof (preferenceslist[0].probemaxtravel) !== 'undefined') && (preferenceslist[0].probemaxtravel.length !== 0)) { + id('preferences_probemaxtravel').value = Number.parseFloat(preferenceslist[0].probemaxtravel); } else { - id('preferences_probemaxtravel').value = parseFloat(default_preferenceslist[0].probemaxtravel); + id('preferences_probemaxtravel').value = Number.parseFloat(default_preferenceslist[0].probemaxtravel); } //probefeedrate - if ((typeof(preferenceslist[0].probefeedrate) !== 'undefined') && (preferenceslist[0].probefeedrate.length != 0)) { - id('preferences_probefeedrate').value = parseInt(preferenceslist[0].probefeedrate); - } else id('preferences_probefeedrate').value = parseInt(default_preferenceslist[0].probefeedrate); + if ((typeof (preferenceslist[0].probefeedrate) !== 'undefined') && (preferenceslist[0].probefeedrate.length !== 0)) { + id('preferences_probefeedrate').value = Number.parseInt(preferenceslist[0].probefeedrate); + } else id('preferences_probefeedrate').value = Number.parseInt(default_preferenceslist[0].probefeedrate); //proberetract - if ((typeof(preferenceslist[0].proberetract) !== 'undefined') && (preferenceslist[0].proberetract.length != 0)) { - id('preferences_proberetract').value = parseFloat(preferenceslist[0].proberetract); - } else id('preferences_proberetract').value = parseFloat(default_preferenceslist[0].proberetract); + if ((typeof (preferenceslist[0].proberetract) !== 'undefined') && (preferenceslist[0].proberetract.length !== 0)) { + id('preferences_proberetract').value = Number.parseFloat(preferenceslist[0].proberetract); + } else id('preferences_proberetract').value = Number.parseFloat(default_preferenceslist[0].proberetract); //probetouchplatethickness - if ((typeof(preferenceslist[0].probetouchplatethickness) !== 'undefined') && (preferenceslist[0].probetouchplatethickness.length != 0)) { - id('preferences_probetouchplatethickness').value = parseFloat(preferenceslist[0].probetouchplatethickness); - } else id('preferences_probetouchplatethickness').value = parseFloat(default_preferenceslist[0].probetouchplatethickness); + if ((typeof (preferenceslist[0].probetouchplatethickness) !== 'undefined') && (preferenceslist[0].probetouchplatethickness.length !== 0)) { + id('preferences_probetouchplatethickness').value = Number.parseFloat(preferenceslist[0].probetouchplatethickness); + } else id('preferences_probetouchplatethickness').value = Number.parseFloat(default_preferenceslist[0].probetouchplatethickness); //autoscroll - if (typeof(preferenceslist[0].enable_autoscroll) !== 'undefined') { + if (typeof (preferenceslist[0].enable_autoscroll) !== 'undefined') { id('preferences_autoscroll').checked = (preferenceslist[0].enable_autoscroll === 'true'); } else id('preferences_autoscroll').checked = false; //Verbose Mode - if (typeof(preferenceslist[0].enable_verbose_mode) !== 'undefined') { + if (typeof (preferenceslist[0].enable_verbose_mode) !== 'undefined') { id('preferences_verbose_mode').checked = (preferenceslist[0].enable_verbose_mode === 'true'); } else id('preferences_verbose_mode').checked = false; //file filters - if (typeof(preferenceslist[0].f_filters) != 'undefined') { + if (typeof (preferenceslist[0].f_filters) !== 'undefined') { console.log("Use prefs filters"); id('preferences_filters').value = preferenceslist[0].f_filters; } else { @@ -478,109 +476,109 @@ function build_dlg_preferences_list() { } function closePreferencesDialog() { - var modified = false; - if (preferenceslist[0].length != 0) { + let modified = false; + if (preferenceslist[0].length !== 0) { //check dialog compare to global state - if ((typeof(preferenceslist[0].language) === 'undefined') || - (typeof(preferenceslist[0].enable_camera) === 'undefined') || - (typeof(preferenceslist[0].auto_load_camera) === 'undefined') || - (typeof(preferenceslist[0].camera_address) === 'undefined') || - (typeof(preferenceslist[0].enable_DHT) === 'undefined') || - (typeof(preferenceslist[0].enable_lock_UI) === 'undefined') || - (typeof(preferenceslist[0].enable_ping) === 'undefined') || - (typeof(preferenceslist[0].enable_redundant) === 'undefined') || - (typeof(preferenceslist[0].enable_probe) === 'undefined') || - (typeof(preferenceslist[0].xy_feedrate) === 'undefined') || - (typeof(preferenceslist[0].z_feedrate) === 'undefined') || - (typeof(preferenceslist[0].e_feedrate) === 'undefined') || - (typeof(preferenceslist[0].e_distance) === 'undefined') || - (typeof(preferenceslist[0].enable_control_panel) === 'undefined') || - (typeof(preferenceslist[0].enable_grbl_panel) === 'undefined') || - (typeof(preferenceslist[0].enable_grbl_probe_panel) === 'undefined') || - (typeof(preferenceslist[0].probemaxtravel) === 'undefined') || - (typeof(preferenceslist[0].probefeedrate) === 'undefined') || - (typeof(preferenceslist[0].proberetract) === 'undefined') || - (typeof(preferenceslist[0].probetouchplatethickness) === 'undefined') || - (typeof(preferenceslist[0].enable_files_panel) === 'undefined') || - (typeof(preferenceslist[0].has_TFT_SD) === 'undefined') || - (typeof(preferenceslist[0].has_TFT_USB) === 'undefined') || - (typeof(preferenceslist[0].autoreport_interval) === 'undefined') || - (typeof(preferenceslist[0].interval_positions) === 'undefined') || - (typeof(preferenceslist[0].interval_status) === 'undefined') || - (typeof(preferenceslist[0].enable_autoscroll) === 'undefined') || - (typeof(preferenceslist[0].enable_verbose_mode) === 'undefined') || - (typeof(preferenceslist[0].enable_commands_panel) === 'undefined')) { + if ((typeof (preferenceslist[0].language) === 'undefined') || + (typeof (preferenceslist[0].enable_camera) === 'undefined') || + (typeof (preferenceslist[0].auto_load_camera) === 'undefined') || + (typeof (preferenceslist[0].camera_address) === 'undefined') || + (typeof (preferenceslist[0].enable_DHT) === 'undefined') || + (typeof (preferenceslist[0].enable_lock_UI) === 'undefined') || + (typeof (preferenceslist[0].enable_ping) === 'undefined') || + (typeof (preferenceslist[0].enable_redundant) === 'undefined') || + (typeof (preferenceslist[0].enable_probe) === 'undefined') || + (typeof (preferenceslist[0].xy_feedrate) === 'undefined') || + (typeof (preferenceslist[0].z_feedrate) === 'undefined') || + (typeof (preferenceslist[0].e_feedrate) === 'undefined') || + (typeof (preferenceslist[0].e_distance) === 'undefined') || + (typeof (preferenceslist[0].enable_control_panel) === 'undefined') || + (typeof (preferenceslist[0].enable_grbl_panel) === 'undefined') || + (typeof (preferenceslist[0].enable_grbl_probe_panel) === 'undefined') || + (typeof (preferenceslist[0].probemaxtravel) === 'undefined') || + (typeof (preferenceslist[0].probefeedrate) === 'undefined') || + (typeof (preferenceslist[0].proberetract) === 'undefined') || + (typeof (preferenceslist[0].probetouchplatethickness) === 'undefined') || + (typeof (preferenceslist[0].enable_files_panel) === 'undefined') || + (typeof (preferenceslist[0].has_TFT_SD) === 'undefined') || + (typeof (preferenceslist[0].has_TFT_USB) === 'undefined') || + (typeof (preferenceslist[0].autoreport_interval) === 'undefined') || + (typeof (preferenceslist[0].interval_positions) === 'undefined') || + (typeof (preferenceslist[0].interval_status) === 'undefined') || + (typeof (preferenceslist[0].enable_autoscroll) === 'undefined') || + (typeof (preferenceslist[0].enable_verbose_mode) === 'undefined') || + (typeof (preferenceslist[0].enable_commands_panel) === 'undefined')) { modified = true; } else { //camera - if (id('show_camera_panel').checked != (preferenceslist[0].enable_camera === 'true')) modified = true; + if (id('show_camera_panel').checked !== (preferenceslist[0].enable_camera === 'true')) modified = true; //Autoload - if (id('autoload_camera_panel').checked != (preferenceslist[0].auto_load_camera === 'true')) modified = true; + if (id('autoload_camera_panel').checked !== (preferenceslist[0].auto_load_camera === 'true')) modified = true; //camera address if (id('preferences_camera_webaddress').value !== HTMLDecode(preferenceslist[0].camera_address)) modified = true; //DHT - if (id('enable_DHT').checked != (preferenceslist[0].enable_DHT === 'true')) modified = true; + if (id('enable_DHT').checked !== (preferenceslist[0].enable_DHT === 'true')) modified = true; //Lock UI - if (id('enable_lock_UI').checked != (preferenceslist[0].enable_lock_UI === 'true')) modified = true; + if (id('enable_lock_UI').checked !== (preferenceslist[0].enable_lock_UI === 'true')) modified = true; //Monitor connection - if (id('enable_ping').checked != (preferenceslist[0].enable_ping === 'true')) modified = true; + if (id('enable_ping').checked !== (preferenceslist[0].enable_ping === 'true')) modified = true; //probe - if (id('enable_probe_controls').checked != (preferenceslist[0].enable_probe === 'true')) modified = true; + if (id('show_grbl_probe_tab').checked !== (preferenceslist[0].enable_probe === 'true')) modified = true; //control panel - if (id('show_control_panel').checked != (preferenceslist[0].enable_control_panel === 'true')) modified = true; + if (id('show_control_panel').checked !== (preferenceslist[0].enable_control_panel === 'true')) modified = true; //grbl panel - if (id('show_grbl_panel').checked != (preferenceslist[0].enable_grbl_panel === 'true')) modified = true; + if (id('show_grbl_panel').checked !== (preferenceslist[0].enable_grbl_panel === 'true')) modified = true; //grbl probe panel - if (id('show_grbl_probe_tab').checked != (preferenceslist[0].enable_grbl_probe_panel === 'true')) modified = true; + if (id('show_grbl_probe_tab').checked !== (preferenceslist[0].enable_grbl_probe_panel === 'true')) modified = true; //files panel - if (id('show_files_panel').checked != (preferenceslist[0].enable_files_panel === 'true')) modified = true; + if (id('show_files_panel').checked !== (preferenceslist[0].enable_files_panel === 'true')) modified = true; //TFT SD - if (id('has_tft_sd').checked != (preferenceslist[0].has_TFT_SD === 'true')) modified = true; + if (id('has_tft_sd').checked !== (preferenceslist[0].has_TFT_SD === 'true')) modified = true; //TFT USB - if (id('has_tft_usb').checked != (preferenceslist[0].has_TFT_USB === 'true')) modified = true; + if (id('has_tft_usb').checked !== (preferenceslist[0].has_TFT_USB === 'true')) modified = true; //commands - if (id('show_commands_panel').checked != (preferenceslist[0].enable_commands_panel === 'true')) modified = true; + if (id('show_commands_panel').checked !== (preferenceslist[0].enable_commands_panel === 'true')) modified = true; //interval positions - if (id('preferences_autoReport_Interval').value != parseInt(preferenceslist[0].autoReport_interval)) modified = true; - if (id('preferences_pos_Interval_check').value != parseInt(preferenceslist[0].interval_positions)) modified = true; + if (id('preferences_autoReport_Interval').value !== Number.parseInt(preferenceslist[0].autoReport_interval)) modified = true; + if (id('preferences_pos_Interval_check').value !== Number.parseInt(preferenceslist[0].interval_positions)) modified = true; //interval status - if (id('preferences_status_Interval_check').value != parseInt(preferenceslist[0].interval_status)) modified = true; + if (id('preferences_status_Interval_check').value !== Number.parseInt(preferenceslist[0].interval_status)) modified = true; //xy feedrate - if (id('preferences_control_xy_velocity').value != parseInt(preferenceslist[0].xy_feedrate)) modified = true; + if (id('preferences_control_xy_velocity').value !== Number.parseInt(preferenceslist[0].xy_feedrate)) modified = true; if (grblaxis > 2) { //z feedrate - if (id('preferences_control_z_velocity').value != parseInt(preferenceslist[0].z_feedrate)) modified = true; + if (id('preferences_control_z_velocity').value !== Number.parseInt(preferenceslist[0].z_feedrate)) modified = true; } if (grblaxis > 3) { //a feedrate - if (id('preferences_control_a_velocity').value != parseInt(preferenceslist[0].a_feedrate)) modified = true; + if (id('preferences_control_a_velocity').value !== Number.parseInt(preferenceslist[0].a_feedrate)) modified = true; } if (grblaxis > 4) { //b feedrate - if (id('preferences_control_b_velocity').value != parseInt(preferenceslist[0].b_feedrate)) modified = true; + if (id('preferences_control_b_velocity').value !== Number.parseInt(preferenceslist[0].b_feedrate)) modified = true; } if (grblaxis > 5) { //c feedrate - if (id('preferences_control_c_velocity').value != parseInt(preferenceslist[0].c_feedrate)) modified = true; + if (id('preferences_control_c_velocity').value !== Number.parseInt(preferenceslist[0].c_feedrate)) modified = true; } } //autoscroll - if (id('preferences_autoscroll').checked != (preferenceslist[0].enable_autoscroll === 'true')) modified = true; + if (id('preferences_autoscroll').checked !== (preferenceslist[0].enable_autoscroll === 'true')) modified = true; //Verbose Mode - if (id('preferences_verbose_mode').checked != (preferenceslist[0].enable_verbose_mode === 'true')) modified = true; + if (id('preferences_verbose_mode').checked !== (preferenceslist[0].enable_verbose_mode === 'true')) modified = true; //file filters - if (id('preferences_filters').value != preferenceslist[0].f_filters) modified = true; + if (id('preferences_filters').value !== preferenceslist[0].f_filters) modified = true; //probemaxtravel - if (id('preferences_probemaxtravel').value != parseFloat(preferenceslist[0].probemaxtravel)) modified = true; + if (id('preferences_probemaxtravel').value !== Number.parseFloat(preferenceslist[0].probemaxtravel)) modified = true; //probefeedrate - if (id('preferences_probefeedrate').value != parseInt(preferenceslist[0].probefeedrate)) modified = true; + if (id('preferences_probefeedrate').value !== Number.parseInt(preferenceslist[0].probefeedrate)) modified = true; //proberetract - if (id('preferences_proberetract').value != parseFloat(preferenceslist[0].proberetract)) modified = true; + if (id('preferences_proberetract').value !== Number.parseFloat(preferenceslist[0].proberetract)) modified = true; //probetouchplatethickness - if (id('preferences_probetouchplatethickness').value != parseFloat(preferenceslist[0].probetouchplatethickness)) modified = true; + if (id('preferences_probetouchplatethickness').value !== Number.parseFloat(preferenceslist[0].probetouchplatethickness)) modified = true; } - if (language_save != language) modified = true; + if (language_save !== language) modified = true; if (modified) { confirmdlg(translate_text_item("Data mofified"), translate_text_item("Do you want to save?"), process_preferencesCloseDialog) } else { @@ -605,7 +603,7 @@ function SavePreferences(current_preferences) { return; } console.log("save prefs"); - if (((typeof(current_preferences) != 'undefined') && !current_preferences) || (typeof(current_preferences) == 'undefined')) { + if (((typeof (current_preferences) !== 'undefined') && !current_preferences) || (typeof (current_preferences) == 'undefined')) { if (!Checkvalues("preferences_autoReport_Interval") || !Checkvalues("preferences_pos_Interval_check") || !Checkvalues("preferences_status_Interval_check") || @@ -617,56 +615,54 @@ function SavePreferences(current_preferences) { !Checkvalues("preferences_probetouchplatethickness") ) return; if (grblaxis > 2) { - if(!Checkvalues("preferences_control_z_velocity")) return; + if (!Checkvalues("preferences_control_z_velocity")) return; } - if( (grblaxis > 3) && (!Checkvalues("preferences_control_a_velocity"))) return; - if( (grblaxis > 4) && (!Checkvalues("preferences_control_b_velocity"))) return; - if( (grblaxis > 5) && (!Checkvalues("preferences_control_c_velocity"))) return; + if ((grblaxis > 3) && (!Checkvalues("preferences_control_a_velocity"))) return; + if ((grblaxis > 4) && (!Checkvalues("preferences_control_b_velocity"))) return; + if ((grblaxis > 5) && (!Checkvalues("preferences_control_c_velocity"))) return; preferenceslist = []; - var saveprefs = "[{\"language\":\"" + language; - saveprefs += "\",\"enable_camera\":\"" + id('show_camera_panel').checked; - saveprefs += "\",\"auto_load_camera\":\"" + id('autoload_camera_panel').checked; + let saveprefs = `[{\"language\":\"${language}`; + saveprefs += `\",\"enable_camera\":\"${id('show_camera_panel').checked}`; + saveprefs += `\",\"auto_load_camera\":\"${id('autoload_camera_panel').checked}`; saveprefs += `\",\"camera_address\":\"${HTMLEncode(id('preferences_camera_webaddress').value)}`; saveprefs += `\",\"enable_DHT\":\"${id('enable_DHT').checked}`; saveprefs += `\",\"enable_lock_UI\":\"${id('enable_lock_UI').checked}`; - saveprefs += "\",\"enable_ping\":\"" + id('enable_ping').checked; - saveprefs += "\",\"enable_control_panel\":\"" + id('show_control_panel').checked; - saveprefs += "\",\"enable_grbl_probe_panel\":\"" + id('show_grbl_probe_tab').checked; - saveprefs += "\",\"enable_grbl_panel\":\"" + id('show_grbl_panel').checked; - saveprefs += "\",\"enable_files_panel\":\"" + id('show_files_panel').checked; - saveprefs += "\",\"has_TFT_SD\":\"" + id('has_tft_sd').checked; - saveprefs += "\",\"has_TFT_USB\":\"" + id('has_tft_usb').checked; - saveprefs += "\",\"probemaxtravel\":\"" + id('preferences_probemaxtravel').value; - saveprefs += "\",\"probefeedrate\":\"" + id('preferences_probefeedrate').value; - saveprefs += "\",\"proberetract\":\"" + id('preferences_proberetract').value; - saveprefs += "\",\"probetouchplatethickness\":\"" + id('preferences_probetouchplatethickness').value; - saveprefs += "\",\"autoreport_interval\":\"" + id('preferences_autoReport_Interval').value; - saveprefs += "\",\"interval_positions\":\"" + id('preferences_pos_Interval_check').value; - saveprefs += "\",\"interval_status\":\"" + id('preferences_status_Interval_check').value; - saveprefs += "\",\"xy_feedrate\":\"" + id('preferences_control_xy_velocity').value; + saveprefs += `\",\"enable_ping\":\"${id('enable_ping').checked}`; + saveprefs += `\",\"enable_control_panel\":\"${id('show_control_panel').checked}`; + saveprefs += `\",\"enable_grbl_probe_panel\":\"${id('show_grbl_probe_tab').checked}`; + saveprefs += `\",\"enable_grbl_panel\":\"${id('show_grbl_panel').checked}`; + saveprefs += `\",\"enable_files_panel\":\"${id('show_files_panel').checked}`; + saveprefs += `\",\"has_TFT_SD\":\"${id('has_tft_sd').checked}`; + saveprefs += `\",\"has_TFT_USB\":\"${id('has_tft_usb').checked}`; + saveprefs += `\",\"probemaxtravel\":\"${id('preferences_probemaxtravel').value}`; + saveprefs += `\",\"probefeedrate\":\"${id('preferences_probefeedrate').value}`; + saveprefs += `\",\"proberetract\":\"${id('preferences_proberetract').value}`; + saveprefs += `\",\"probetouchplatethickness\":\"${id('preferences_probetouchplatethickness').value}`; + saveprefs += `\",\"autoreport_interval\":\"${id('preferences_autoReport_Interval').value}`; + saveprefs += `\",\"interval_positions\":\"${id('preferences_pos_Interval_check').value}`; + saveprefs += `\",\"interval_status\":\"${id('preferences_status_Interval_check').value}`; + saveprefs += `\",\"xy_feedrate\":\"${id('preferences_control_xy_velocity').value}`; if (grblaxis > 2) { - saveprefs += "\",\"z_feedrate\":\"" + id('preferences_control_z_velocity').value; + saveprefs += `\",\"z_feedrate\":\"${id('preferences_control_z_velocity').value}`; } - if (grblaxis > 3){ - saveprefs += "\",\"a_feedrate\":\"" + id('preferences_control_a_velocity').value; + if (grblaxis > 3) { + saveprefs += `\",\"a_feedrate\":\"${id('preferences_control_a_velocity').value}`; } - if (grblaxis > 4){ - saveprefs += "\",\"b_feedrate\":\"" + id('preferences_control_b_velocity').value; + if (grblaxis > 4) { + saveprefs += `\",\"b_feedrate\":\"${id('preferences_control_b_velocity').value}`; } - if (grblaxis > 5){ - saveprefs += "\",\"c_feedrate\":\"" + id('preferences_control_c_velocity').value; + if (grblaxis > 5) { + saveprefs += `\",\"c_feedrate\":\"${id('preferences_control_c_velocity').value}`; } - saveprefs += "\",\"f_filters\":\"" + id('preferences_filters').value; - saveprefs += "\",\"enable_autoscroll\":\"" + id('preferences_autoscroll').checked; - saveprefs += "\",\"enable_verbose_mode\":\"" + id('preferences_verbose_mode').checked; - saveprefs += "\",\"enable_commands_panel\":\"" + id('show_commands_panel').checked + "\"}]"; + saveprefs += `\",\"f_filters\":\"${id('preferences_filters').value}`; + saveprefs += `\",\"enable_autoscroll\":\"${id('preferences_autoscroll').checked}`; + saveprefs += `\",\"enable_verbose_mode\":\"${id('preferences_verbose_mode').checked}`; + saveprefs += `\",\"enable_commands_panel\":\"${id('show_commands_panel').checked}\"}]`; preferenceslist = JSON.parse(saveprefs); } - var blob = new Blob([JSON.stringify(preferenceslist, null, " ")], { - type: 'application/json' - }); + const blob = new Blob([JSON.stringify(preferenceslist, null, " ")], { type: 'application/json' }); var file; if (browser_is("IE") || browser_is("Edge")) { file = blob; @@ -677,7 +673,7 @@ function SavePreferences(current_preferences) { var url = "/files"; formData.append('path', '/'); formData.append('myfile[]', file, preferences_file_name); - if ((typeof(current_preferences) != 'undefined') && current_preferences) SendFileHttp(url, formData); + if ((typeof (current_preferences) != 'undefined') && current_preferences) SendFileHttp(url, formData); else SendFileHttp(url, formData, preferencesdlgUploadProgressDisplay, preferencesUploadsuccess, preferencesUploadfailed); } @@ -704,40 +700,40 @@ function preferencesUploadfailed(error_code, response) { function Checkvalues(id_2_check) { - var status = true; - var value = 0; + let status = true; + let value = 0; switch (id_2_check) { case "preferences_autoReport_Interval": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && (value == 0 || (value >= 50 && value <= 30000)))) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && (value === 0 || (value >= 50 && value <= 30000)))) { error_message = translate_text_item("Value of auto-report must be 0 or between 50ms and 30000ms !!"); status = false; } break; case "preferences_status_Interval_check": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 0 && value <= 100)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 0 && value <= 100)) { error_message = translate_text_item("Value of auto-check must be between 0s and 99s !!"); status = false; } break; case "preferences_pos_Interval_check": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1 && value <= 100)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1 && value <= 100)) { error_message = translate_text_item("Value of auto-check must be between 0s and 99s !!"); status = false; } break; case "preferences_control_xy_velocity": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1)) { error_message = translate_text_item("XY Feedrate value must be at least 1 mm/min!"); status = false; } break; case "preferences_control_z_velocity": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1)) { error_message = translate_text_item("Z Feedrate value must be at least 1 mm/min!"); status = false; } @@ -745,36 +741,36 @@ function Checkvalues(id_2_check) { case "preferences_control_a_velocity": case "preferences_control_b_velocity": case "preferences_control_c_velocity": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1)) { error_message = translate_text_item("Axis Feedrate value must be at least 1 mm/min!"); status = false; } break; case "preferences_probefeedrate": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1 && value <= 9999)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1 && value <= 9999)) { error_message = translate_text_item("Value of probe feedrate must be between 1 mm/min and 9999 mm/min !"); status = false; } break; case "preferences_probemaxtravel": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 1 && value <= 9999)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 1 && value <= 9999)) { error_message = translate_text_item("Value of maximum probe travel must be between 1 mm and 9999 mm !"); status = false; } break; case "preferences_proberetract": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 0 && value <= 9999)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 0 && value <= 9999)) { error_message = translate_text_item("Value of probe retract must be between 0 mm and 9999 mm !"); status = false; } break; case "preferences_probetouchplatethickness": - value = parseInt(id(id_2_check).value); - if (!(!isNaN(value) && value >= 0 && value <= 9999)) { + value = Number.parseInt(id(id_2_check).value); + if (!(!Number.isNaN(value) && value >= 0 && value <= 9999)) { error_message = translate_text_item("Value of probe touch plate thickness must be between 0 mm and 9999 mm !"); status = false; } @@ -782,21 +778,21 @@ function Checkvalues(id_2_check) { case "preferences_filters": //TODO a regex would be better value = id(id_2_check).value; - if ((value.indexOf(".") != -1) || - (value.indexOf("*") != -1)) { + if ((value.indexOf(".") !== -1) || + (value.indexOf("*") !== -1)) { error_message = translate_text_item("Only alphanumeric chars separated by ; for extensions filters"); status = false; } break; } if (status) { - id(id_2_check + "_group").classList.remove("has-feedback"); - id(id_2_check + "_group").classList.remove("has-error"); - id(id_2_check + "_icon").innerHTML = ""; + id(`${id_2_check}_group`).classList.remove("has-feedback"); + id(`${id_2_check}_group`).classList.remove("has-error"); + id(`${id_2_check}_icon`).innerHTML = ""; } else { // has-feedback hides the value so it is hard to fix it // id(id_2_check + "_group").classList.add("has-feedback"); - id(id_2_check + "_group").classList.add("has-error"); + id(`${id_2_check}_group`).classList.add("has-error"); // id(id_2_check + "_icon").innerHTML = get_icon_svg("remove"); alertdlg(translate_text_item("Out of range"), error_message); } diff --git a/www/sub/controlspanel.html b/www/sub/controlspanel.html index d985ca9b..528bee5f 100644 --- a/www/sub/controlspanel.html +++ b/www/sub/controlspanel.html @@ -12,7 +12,8 @@
  
@@ -36,26 +38,31 @@
-
+
-   +  
- -

+ +
- + sec
@@ -68,22 +75,27 @@ + +
- + - X:  + X: 
- Xm:  + Xm:  +
- - -
@@ -96,22 +108,27 @@ + +
- + - Y:  + Y: 
- Ym:  + Ym:  +
- - -
@@ -122,13 +139,15 @@ + +
- + - Z:  + Z: 
- Zm:  + Zm:  +
- - -

@@ -137,10 +156,13 @@ @@ -153,22 +175,27 @@ + +
- + - Aw:  + Aw: 
- Am:  + Am:  +
- - -
@@ -181,22 +208,27 @@ + +
- + - Bw:  + Bw: 
- Bm:  + Bm:  +
- - -
-
+
@@ -207,13 +239,15 @@ + +
- + - Cw:  + + Cw: 
- Cm:  + + Cm:  +
- - -
@@ -228,7 +262,8 @@ - + mm/min @@ -237,7 +272,7 @@   - @@ -245,14 +280,16 @@
+ Z: - + mm/min
  - + - + \ No newline at end of file diff --git a/www/sub/grblpanel.html b/www/sub/grblpanel.html index 9256ec89..62ef2027 100644 --- a/www/sub/grblpanel.html +++ b/www/sub/grblpanel.html @@ -121,14 +121,14 @@
- diff --git a/www/sub/preferencesdlg.html b/www/sub/preferencesdlg.html index 671fad3d..566d7d0f 100644 --- a/www/sub/preferencesdlg.html +++ b/www/sub/preferencesdlg.html @@ -17,7 +17,7 @@

@@ -27,7 +27,7 @@

@@ -37,7 +37,7 @@

@@ -47,7 +47,8 @@

@@ -55,14 +56,15 @@

Camera address: - +
@@ -71,7 +73,8 @@

@@ -86,8 +89,10 @@

- - + +
@@ -109,8 +114,11 @@

- - + +
@@ -124,7 +132,7 @@


- +
@@ -133,8 +141,10 @@

@@ -418,7 +457,8 @@

@@ -426,13 +466,13 @@

@@ -460,4 +500,4 @@

- + \ No newline at end of file

- - + +
@@ -154,8 +164,10 @@

- - + +
@@ -175,8 +187,10 @@

- - + +
@@ -196,8 +210,10 @@

- - + +
@@ -215,7 +231,8 @@

@@ -229,8 +246,11 @@

- - + +
@@ -251,8 +271,11 @@

- - + +
@@ -269,7 +292,8 @@

@@ -283,8 +307,11 @@

- - + +
@@ -305,8 +332,11 @@

- - + +
@@ -327,8 +357,11 @@

- - + +
@@ -349,8 +382,11 @@

- - + +
@@ -371,7 +407,8 @@

@@ -383,7 +420,7 @@

@@ -393,7 +430,7 @@

@@ -405,8 +442,10 @@

- - + +