Skip to content

Commit

Permalink
Rsolving various start uip issues
Browse files Browse the repository at this point in the history
  • Loading branch information
md8n committed Dec 20, 2024
1 parent 72abacd commit 70ad67c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 91 deletions.
39 changes: 25 additions & 14 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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();
}
Expand All @@ -265,7 +276,7 @@ function initUI_4() {
}

function show_main_UI() {
displayUndoNone('main_ui')
displayUndoNone('main_ui');
}

// var socket_response = ''
Expand Down
10 changes: 3 additions & 7 deletions www/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,16 @@ 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) + "=";
}

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) {
Expand Down
11 changes: 5 additions & 6 deletions www/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -279,7 +278,7 @@ function control_build_macro_ui() {

var content = "<div class='tooltip'>";
content += "<span class='tooltip-text'>Manage macros</span>"
content += "<button class='btn btn-primary' onclick='showmacrodlg(processMacroSave)'>";
content += "<button id='control_btn_show_macro_dlg' class='btn btn-primary' onclick='showmacrodlg(processMacroSave)'>";
actions.push({ id: "control_btn_show_macro_dlg", type: "click", method: showmacrodlg(processMacroSave) });
content += "<span class='badge'>";
content += "<svg width='1.3em' height='1.2em' viewBox='0 0 1300 1200'>";
Expand Down
4 changes: 2 additions & 2 deletions www/js/grblpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const grblpanel = () => {
id("grblpanel_flood").addEventListener("click", (event) => SendRealtimeCmd(0xa0));
id("grblpanel_mist").addEventListener("click", (event) => SendRealtimeCmd(0xa1));

id("grblspindle_fwd").addEventListener("click", (event) => SendPrinterCommand(`M3 S${common.spindleTabSpindleSpeed}`, false, null, null, 1, 1,));
id("grblspindle_rew").addEventListener("click", (event) => SendPrinterCommand(`M4 S${common.spindleTabSpindleSpeed}`, false, null, null, 1, 1,));
id("grblspindle_fwd").addEventListener("click", (event) => SendPrinterCommand(`M3 S${spindleTabSpindleSpeed}`, false, null, null, 1, 1,));
id("grblspindle_rew").addEventListener("click", (event) => SendPrinterCommand(`M4 S${spindleTabSpindleSpeed}`, false, null, null, 1, 1,));
id("grblspindle_off").addEventListener("click", (event) => SendPrinterCommand("M5 S0", false, null, null, 1, 1));
id("grblspindle_rpm").addEventListener("change", (event) => setSpindleSpeed(event.value));
id("grblspindle_rpm").addEventListener("keyup", (event) => setSpindleSpeed(event.value));
Expand Down
3 changes: 1 addition & 2 deletions www/js/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ function AddCmd(cmd_fn, id) {
http_errorfn(999, translate_text_item("Server not responding"));
return;
}
var cmd_id = 0;
if (typeof id != 'undefined') cmd_id = id;
const cmd_id = (typeof id !== 'undefined') ? id : 0;
//console.log("adding command");
var cmd = {
cmd: cmd_fn,
Expand Down
Loading

0 comments on commit 70ad67c

Please sign in to comment.