diff --git a/www/js/app.js b/www/js/app.js index 52522e22..e3d16181 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -58,35 +58,44 @@ function browser_is(bname) { window.onload = () => { //to check if javascript is disabled like in android preview - displayNone('loadingmsg'); - console.log('Connect to board'); + displayNone("loadingmsg"); + console.log("Connect to board"); - let connectLoaded = false; - let controlsLoaded = false; - let navbarLoaded = false; + // These are all falsey, indicating nothing has been loaded + let connectDlg = ""; + let controlsPanel = ""; + let navbarLoaded = ""; + + let failSafe = 10; let startUpInt = setInterval(() => { // Check for various key HTML panels and load them up - if (!connectLoaded && id("connectdlg.html")) { + if (!connectDlg && id("connectdlg.html")) { + connectDlg = "loading"; connectdlg(); - connectLoaded = true; + connectDlg = "loaded"; } - if (!controlsLoaded && id("controlspanel.html")) { + if (!controlsPanel && id("controlPanel")) { + controlsPanel = "loading"; ControlsPanel(); - controlsLoaded = true; + controlsPanel = "loaded"; } if (!navbarLoaded && id("navbar")) { + navbarLoaded = "loading"; navbar(); tabletInit(); - navbarLoaded = true; + navbarLoaded = "loaded"; } - if (connectLoaded && controlsLoaded && navbarLoaded) { + if ((connectDlg && controlsPanel && navbarLoaded) || failSafe <= 0) { clearInterval(startUpInt); startUpInt = null; } + + // Ensure that we always break out of this + failSafe--; }, 500); } @@ -195,7 +204,9 @@ function Set_page_title(page_title) { function initUI() { console.log('Init UI'); - if (ESP3D_authentication) connectdlg(false); + if (ESP3D_authentication) { + connectdlg(false); + } AddCmd(display_boot_progress); //initial check if (typeof target_firmware === 'undefined' || typeof web_ui_version === 'undefined' || typeof direct_sd === 'undefined') @@ -238,7 +249,7 @@ function initUI_3() { console.log('Get macros'); init_controls_panel(); init_grbl_panel(); - console.log('Get preferences') + console.log('Get preferences'); getpreferenceslist(); initUI_4(); } @@ -265,7 +276,7 @@ function initUI_4() { } function show_main_UI() { - displayUndoNone('main_ui') + displayUndoNone('main_ui'); } // var socket_response = '' diff --git a/www/js/config.js b/www/js/config.js index 85b35b1d..b745adb0 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -226,10 +226,7 @@ function get_config_value(sline) { return tline2.length > 1 ? tline2[1] : "???"; } -function get_config_help(sline) { - if (is_override_config) return ""; - return inline_help(get_config_label(sline)) -} +const get_config_help = (sline) => (is_override_config) ? "" : inline_help(get_config_label(sline)); function get_config_command(sline) { return get_config_label(sline) + "="; @@ -237,9 +234,8 @@ function get_config_command(sline) { function is_config_commented(sline) { var line = sline.trim(); - if (line.length == 0) return false; - if (is_override_config) return line.startsWith(";"); - return false; + if (!line.length) return false; + return (is_override_config) ? line.startsWith(";") : false; } function config_revert_to_default(index, is_override) { diff --git a/www/js/controls.js b/www/js/controls.js index e94ee8a4..2d1c5ab3 100644 --- a/www/js/controls.js +++ b/www/js/controls.js @@ -212,14 +212,13 @@ function SendJogcommand(cmd, feedrate) { return; } - const controlName = axis.startsWith("Z") ? "controlpanel_z_feedrate" : "controlpanel_xy_feedrate"; - const prefName = axis.startsWith("Z") ? "z_feedrate" : "xy_feedrate"; - const valueDef = buildFeedRateValueDef(axis); + const controlName = feedrate.startsWith("Z") ? "controlpanel_z_feedrate" : "controlpanel_xy_feedrate"; + const prefName = feedrate.startsWith("Z") ? "z_feedrate" : "xy_feedrate"; + const valueDef = buildFeedRateValueDef(feedrate); let letter = "Z"; - const common = new Common(); let cmd = ""; - if (common.grblaxis > 3) { + if (grblaxis > 3) { letter = "Axis"; valueDef.label = valueDef.label.replace("Z axis", letter); cmd = cmd.replace("Z", id("control_select_axis").value); @@ -279,7 +278,7 @@ function control_build_macro_ui() { var content = "
"; content += "Manage macros" - content += "
-
+
@@ -151,18 +148,18 @@
-
-
+
+
- +
- Zm: + Zm: 
@@ -175,9 +172,10 @@
- + - Aw:  + + Aw:  +
- Am:  + + Am:  +
@@ -185,17 +183,17 @@
-
+
@@ -208,9 +206,10 @@
- + - Bw:  + + Bw:  +
- Bm:  + + Bm:  +
@@ -222,13 +221,13 @@ @@ -241,7 +240,8 @@
- + Cw:  + id="control_c_position">  +
Cm:  + id="control_cm_position">  +
@@ -262,8 +262,7 @@ - + mm/min @@ -273,23 +272,21 @@ -
- Z: + Z: + - + mm/min
  - +
\ No newline at end of file