Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No global space function calls in tablet.js #94

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions www/js/alertdlg.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const alertdlg = (titledlg, textdlg, closefunc) => {
return;
}

id("cancelAlertDlg").addEventListener("click", (event) =>
closeModal("cancel"),
);
id("cancelAlertDlg").addEventListener("click", (event) => closeModal("cancel"));
id("closeAlertDlg").addEventListener("click", (event) => closeModal("Ok"));

const title = modal.element.getElementsByClassName("modal-title")[0];
Expand Down
28 changes: 9 additions & 19 deletions www/js/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@ let Monitor_output = [];

/** Set up the event handlers for the commands panel */
const init_command_panel = () => {
id("clear_monitor_btn").addEventListener("click", (event) =>
Monitor_output_Clear(),
);
id("custom_cmd_txt").addEventListener("keyup", (event) =>
CustomCommand_OnKeyUp(event),
);
id("commandspanel_send").addEventListener("click", (event) =>
SendCustomCommand(),
);
id("monitor_enable_autoscroll").addEventListener("click", (event) =>
Monitor_check_autoscroll(),
);
id("monitor_enable_verbose_mode").addEventListener("click", (event) =>
Monitor_check_verbose_mode(),
);
id("clear_monitor_btn").addEventListener("click", (event) => Monitor_output_Clear());
id("custom_cmd_txt").addEventListener("keyup", (event) => CustomCommand_OnKeyUp(event));
id("commandspanel_send").addEventListener("click", (event) => SendCustomCommand());
id("monitor_enable_autoscroll").addEventListener("click", (event) => Monitor_check_autoscroll());
id("monitor_enable_verbose_mode").addEventListener("click", (event) => Monitor_check_verbose_mode());
};

function Monitor_output_autoscrollcmd() {
Expand Down Expand Up @@ -174,10 +164,10 @@ function SendCustomCommandFailed(error_code, response) {
error_code === 0
? translate_text_item("Connection error")
: stdErrMsg(
error_code,
HTMLDecode(response),
translate_text_item("Error"),
);
error_code,
HTMLDecode(response),
translate_text_item("Error"),
);
Monitor_output_Update(`${errMsg}\n`);

conErr(error_code, HTMLDecode(response), "cmd Error");
Expand Down
16 changes: 6 additions & 10 deletions www/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ function files_build_file_line(index, actions) {
content += "</tr></table>";
content += "</div>";
if (is_clickable) {
actions.push({
id: fliId,
type: "click",
method: files_click_file(index),
});
actions.push({ id: fliId, type: "click", method: (event) => files_click_file(index) });
}
let sizecol = "col-md-2 col-sm-2 filesize";
let timecol = "col-md-2 col-sm-2";
Expand All @@ -156,19 +152,19 @@ function files_build_file_line(index, actions) {
content += "<div class='pull-right'>";
if (entry.isprintable) {
content += `<button id='${fliId}_print_btn' ${btnCls} ${btnPad}>${get_icon_svg("play", "1em", "1em")}</button>`;
actions.push({ id: `${fliId}_print_btn`, type: "click", method: files_print(index) });
actions.push({ id: `${fliId}_print_btn`, type: "click", method: (event) => files_print(index) });
}
content += "&nbsp;";
if (!entry.isdir) {
content += `<button id='${fliId}_download_btn' ${btnCls} ${btnPad}>${get_icon_svg("download", "1em", "1em")}</button>`;
actions.push({ id: `${fliId}_download_btn`, type: "click", method: files_download(index) });
actions.push({ id: `${fliId}_download_btn`, type: "click", method: (event) => files_download(index) });
}
if (files_showdeletebutton(index)) {
content += `<button id='${fliId}_delete_btn' class='btn btn-xs btn-danger' ${btnPad}>${get_icon_svg("trash", "1em", "1em")}</button>`;
actions.push({ id: `${fliId}_delete_btn`, type: "click", method: files_delete(index) });
actions.push({ id: `${fliId}_delete_btn`, type: "click", method: (event) => files_delete(index) });
}
content += `<button id='${fliId}_rename_btn' ${btnCls} ${btnPad}>${get_icon_svg("wrench", "1em", "1em")}</button>`;
actions.push({ id: `${fliId}_rename_btn`, type: "click", method: files_rename(index) });
actions.push({ id: `${fliId}_rename_btn`, type: "click", method: (event) => files_rename(index) });
content += "</div>";
content += "</div>";
content += "</div>";
Expand Down Expand Up @@ -518,7 +514,7 @@ function files_build_display_filelist(displaylist = true) {
content += `<li id='${liId}' class='list-group-item list-group-hover' style='cursor:pointer'>`;
content += `<span>${get_icon_svg("level-up")}</span>&nbsp;&nbsp;<span translate>Up...</span>`;
content += "</li>";
actions.push({ id: liId, type: "click", method: files_go_levelup() });
actions.push({ id: liId, type: "click", method: (event) => files_go_levelup() });
}
for (let index = 0; index < files_file_list.length; index++) {
if (!files_file_list[index].isdir)
Expand Down
60 changes: 30 additions & 30 deletions www/js/grblpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ const grblpanel = () => {
// GRBL reporting
id("report_none").addEventListener("change", (event) => onReportType(event));
id("report_auto").addEventListener("change", (event) => onReportType(event));
id("grblpanel_autoreport_interval").addEventListener("change", (event) => onAutoReportIntervalChange(),);
id("grblpanel_autoreport_interval").addEventListener("change", (event) => onAutoReportIntervalChange());
id("report_poll").addEventListener("change", (event) => onReportType(event));
id("grblpanel_interval_status").addEventListener("change", (event) => onstatusIntervalChange(),);
id("grblpanel_interval_status").addEventListener("change", (event) => onstatusIntervalChange());

id("clear_status_btn").addEventListener("click", (event) => SendPrinterCommand("$X", true, null, null, 114, 1),);
id("sd_pause_btn").addEventListener("click", (event) => SendRealtimeCmd(0x21),);
id("sd_resume_btn").addEventListener("click", (event) => SendRealtimeCmd(0x7e),);
id("clear_status_btn").addEventListener("click", (event) => SendPrinterCommand("$X", true, null, null, 114, 1));
id("sd_pause_btn").addEventListener("click", (event) => SendRealtimeCmd(0x21));
id("sd_resume_btn").addEventListener("click", (event) => SendRealtimeCmd(0x7e));
id("sd_reset_btn").addEventListener("click", (event) => grbl_reset());

id("grblpanel_F10_minus").addEventListener("click", (event) => SendRealtimeCmd(0x92),);
id("grblpanel_F1_minus").addEventListener("click", (event) => SendRealtimeCmd(0x94),);
id("grblpanel_F0").addEventListener("click", (event) => SendRealtimeCmd(0x90),);
id("grblpanel_F1_plus").addEventListener("click", (event) => SendRealtimeCmd(0x93),);
id("grblpanel_F10_plus").addEventListener("click", (event) => SendRealtimeCmd(0x91),);
id("grblpanel_F10_minus").addEventListener("click", (event) => SendRealtimeCmd(0x92));
id("grblpanel_F1_minus").addEventListener("click", (event) => SendRealtimeCmd(0x94));
id("grblpanel_F0").addEventListener("click", (event) => SendRealtimeCmd(0x90));
id("grblpanel_F1_plus").addEventListener("click", (event) => SendRealtimeCmd(0x93));
id("grblpanel_F10_plus").addEventListener("click", (event) => SendRealtimeCmd(0x91));

id("grblpanel_S10_minus").addEventListener("click", (event) => SendRealtimeCmd(0x9b),);
id("grblpanel_S1_minus").addEventListener("click", (event) => SendRealtimeCmd(0x9d),);
id("grblpanel_S0").addEventListener("click", (event) => SendRealtimeCmd(0x99),);
id("grblpanel_S1_plus").addEventListener("click", (event) => SendRealtimeCmd(0x9c),);
id("grblpanel_S10_plus").addEventListener("click", (event) => SendRealtimeCmd(0x9a),);
id("grblpanel_S10_minus").addEventListener("click", (event) => SendRealtimeCmd(0x9b));
id("grblpanel_S1_minus").addEventListener("click", (event) => SendRealtimeCmd(0x9d));
id("grblpanel_S0").addEventListener("click", (event) => SendRealtimeCmd(0x99));
id("grblpanel_S1_plus").addEventListener("click", (event) => SendRealtimeCmd(0x9c));
id("grblpanel_S10_plus").addEventListener("click", (event) => SendRealtimeCmd(0x9a));

id("grblpanel_spindle").addEventListener("click", (event) => SendRealtimeCmd(0x9e),);
id("grblpanel_flood").addEventListener("click", (event) => SendRealtimeCmd(0xa0),);
id("grblpanel_mist").addEventListener("click", (event) => SendRealtimeCmd(0xa1),);
id("grblpanel_spindle").addEventListener("click", (event) => SendRealtimeCmd(0x9e));
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_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),);
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_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));

id("grblpanel_probemaxtravel").addEventListener("change", (event) => onprobemaxtravelChange(),);
id("grblpanel_probefeedrate").addEventListener("change", (event) => onprobefeedrateChange(),);
id("grblpanel_proberetract").addEventListener("change", (event) => onproberetractChange(),);
id("grblpanel_probetouchplatethickness").addEventListener("change", (event) => onprobetouchplatethicknessChange(),);
id("grblpanel_probemaxtravel").addEventListener("change", (event) => onprobemaxtravelChange());
id("grblpanel_probefeedrate").addEventListener("change", (event) => onprobefeedrateChange());
id("grblpanel_proberetract").addEventListener("change", (event) => onproberetractChange());
id("grblpanel_probetouchplatethickness").addEventListener("change", (event) => onprobetouchplatethicknessChange());

id("probingbtn").addEventListener("click", (event) => StartProbeProcess());

id("grblcontroltablink").addEventListener("click", (event) => opentab(event, "grblcontroltab", "grbluitabscontent", "grbluitablinks"),);
id("grblspindletablink").addEventListener("click", (event) => opentab(event, "grblspindletab", "grbluitabscontent", "grbluitablinks"),);
id("grblpanel_probetablink").addEventListener("click", (event) => opentab(event, "grblprobetab", "grbluitabscontent", "grbluitablinks"),);
id("grblcontroltablink").addEventListener("click", (event) => opentab(event, "grblcontroltab", "grbluitabscontent", "grbluitablinks"));
id("grblspindletablink").addEventListener("click", (event) => opentab(event, "grblspindletab", "grbluitabscontent", "grbluitablinks"));
id("grblpanel_probetablink").addEventListener("click", (event) => opentab(event, "grblprobetab", "grbluitabscontent", "grbluitablinks"));

id("global_reset_btn").addEventListener("click", (event) => grbl_reset());
};
Expand Down
70 changes: 13 additions & 57 deletions www/js/macrodlg.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,11 @@ function build_color_selection(index, actions) {
content += "</g>";
content += "</svg>";
content += "</button>";
actions.push({
id: `macro_color_line${index}_btn`,
type: "click",
method: (event) => showhide_drop_menu(event),
});
actions.push({ id: `macro_color_line${index}_btn`, type: "click", method: (event) => showhide_drop_menu(event) });
content += `<div class='dropmenu-content ${menu_pos}' style='min-width:auto; padding-left: 4px;padding-right: 4px;'>`;
for ((col) in ["default", "primary", "info", "warning", "danger"]) {
content += `<button id='macro_select_color_${col}${index}_btn' class='btn btn-${col}'>&nbsp;</button>`;
actions.push({
id: `macro_select_color_${col}${index}_btn`,
type: "click",
method: (event) => macro_select_color(event, col, index),
});
actions.push({ id: `macro_select_color_${col}${index}_btn`, type: "click", method: (event) => macro_select_color(event, col, index) });
};
content += "</div>";
content += "</div>";
Expand All @@ -66,30 +58,14 @@ function build_target_selection(index, actions) {
content += "</g>";
content += "</svg>";
content += "</button>";
actions.push({
id: `macro_target_line${index}_btn`,
type: "click",
method: (event) => showhide_drop_menu(event),
});
actions.push({ id: `macro_target_line${index}_btn`, type: "click", method: (event) => showhide_drop_menu(event) });
content += `<div class='dropmenu-content ${menu_pos}' style='min-width:auto'>`;
content += `<a id='macro_select_targetESP${index}_link' href=#>ESP</a>`;
content += `<a id='macro_select_targetSD${index}_link' href=#>SD</a>`;
content += `<a id='macro_select_targetURI${index}_link' href=#>URI</a>`;
actions.push({
id: `macro_select_targetESP${index}_link`,
type: "click",
method: (event) => macro_select_target(event, "ESP", index),
});
actions.push({
id: `macro_select_targetSD${index}_link`,
type: "click",
method: (event) => macro_select_target(event, "SD", index),
});
actions.push({
id: `macro_select_targetURI${index}_link`,
type: "click",
method: (event) => macro_select_target(event, "URI", index),
});
actions.push({ id: `macro_select_targetESP${index}_link`, type: "click", method: (event) => macro_select_target(event, "ESP", index) });
actions.push({ id: `macro_select_targetSD${index}_link`, type: "click", method: (event) => macro_select_target(event, "SD", index) });
actions.push({ id: `macro_select_targetURI${index}_link`, type: "click", method: (event) => macro_select_target(event, "URI", index) });

content += "</div>";
content += "</div>";
Expand All @@ -110,22 +86,14 @@ function build_glyph_selection(index, actions) {
content += "</g>";
content += "</svg>";
content += "</button>";
actions.push({
id: `macro_glyph_line${index}_btn`,
type: "click",
method: (event) => showhide_drop_menu(event),
});
actions.push({ id: `macro_glyph_line${index}_btn`, type: "click", method: (event) => showhide_drop_menu(event) });
content += `<div class='dropmenu-content ${menu_pos}' style='min-width:30em'>`;
for (const key in list_icon) {
if (key === "plus") {
continue;
}
content += `<button id='macro_glyph_select${index}_btn' class='btn btn-default btn-xs'><span>${get_icon_svg(key)}</span></button>`;
actions.push({
id: `macro_glyph_select${index}_btn`,
type: "click",
method: (event) => macro_select_glyph(event, key, index),
});
actions.push({ id: `macro_glyph_select${index}_btn`, type: "click", method: (event) => macro_select_glyph(event, key, index) });
}
content += "</div>";
content += "</div>";
Expand All @@ -142,16 +110,8 @@ function build_filename_selection(index, actions) {
content += `<span id='icon_macro_status_line_${index}' style='color:#a94442; position:absolute;bottom:4px;left:7.5em;${noFilename ? "display:none" : ""}'>${get_icon_svg("remove")}</span>`;
content += "</input></span>";

actions.push({
id: mflId,
type: "keyup",
method: macro_filename_OnKeyUp(index),
});
actions.push({
id: mflId,
type: "change",
method: (event, index) => on_macro_filename(event, index),
});
actions.push({ id: mflId, type: "keyup", method: (event) => macro_filename_OnKeyUp(index) });
actions.push({ id: mflId, type: "change", method: (event) => on_macro_filename(event, index) });

return content;
}
Expand All @@ -171,7 +131,7 @@ function build_dlg_macrolist_line(index) {
content += buildTdVertMiddle(
`<button id='${btnId}' class='${btnClass}' style='${btnStyle}>${get_icon_svg(noEC ? "plus" : "trash")}</button>`,
);
actions.push({ id: btnId, type: "click", method: macro_reset_button(index) });
actions.push({ id: btnId, type: "click", method: (event) => macro_reset_button(index) });
if (noEC) {
content += "<td colspan='5'></td>";
} else {
Expand All @@ -180,11 +140,7 @@ function build_dlg_macrolist_line(index) {
content += buildTdVertMiddle(
`<input type='text' id='${inpId}' style='width:4em' class='form-control' value='${entryName}'/>`,
);
actions.push({
id: inpId,
type: "change",
method: (event, index) => on_macro_name(event, index),
});
actions.push({ id: inpId, type: "change", method: (event) => on_macro_name(event, index) });
content += buildTdVertMiddle(build_glyph_selection(index, actions));
content += buildTdVertMiddle(build_color_selection(index, actions));
content += buildTdVertMiddle(build_target_selection(index, actions));
Expand All @@ -193,7 +149,7 @@ function build_dlg_macrolist_line(index) {

setHTML(`macro_line_${index}`, content);
actions.forEach((action) => {
id(action.id).addEventListener(action.type, (event) => action.method);
id(action.id).addEventListener(action.type, action.method);
});
}

Expand Down
14 changes: 7 additions & 7 deletions www/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
const navbar = () => {
id("toggleLockUI").addEventListener("click", (event) => ontoggleLock());

id("showPreferencesDlg").addEventListener("click", (event) => showpreferencesdlg(),);
id("showPreferencesDlg").addEventListener("click", (event) => showpreferencesdlg());
id("showSetupDlg").addEventListener("click", (event) => setupdlg());
id("showCreditsDlg").addEventListener("click", (event) => creditsdlg());

// Note: for `maintab` see dashtab.html
id("maintablink").addEventListener("click", (event) => opentab(event, "maintab", "mainuitabscontent", "mainuitablinks"),);
id("camtablink").addEventListener("click", (event) => opentab(event, "cameratab", "mainuitabscontent", "mainuitablinks"),);
id("configtablink").addEventListener("click", (event) => opentab(event, "configtab", "mainuitabscontent", "mainuitablinks"),);
id("settingtablink").addEventListener("click", (event) => opentab(event, "settingstab", "mainuitabscontent", "mainuitablinks"),);
id("tablettablink").addEventListener("click", (event) => opentab(event, "tablettab", "mainuitabscontent", "mainuitablinks"),);
id("maintablink").addEventListener("click", (event) => opentab(event, "maintab", "mainuitabscontent", "mainuitablinks"));
id("camtablink").addEventListener("click", (event) => opentab(event, "cameratab", "mainuitabscontent", "mainuitablinks"));
id("configtablink").addEventListener("click", (event) => opentab(event, "configtab", "mainuitabscontent", "mainuitablinks"));
id("settingtablink").addEventListener("click", (event) => opentab(event, "settingstab", "mainuitabscontent", "mainuitablinks"));
id("tablettablink").addEventListener("click", (event) => opentab(event, "tablettab", "mainuitabscontent", "mainuitablinks"));

id("password_menu").addEventListener("click", (event) => changepassworddlg());
id("showLoginDlg").addEventListener("click", (event) => logindlg());
id("logout_menu").addEventListener("click", (event) => confirmdlg(translate_text_item("Disconnection requested"), translate_text_item("Please confirm disconnection."), DisconnectLogin,),);
id("logout_menu").addEventListener("click", (event) => confirmdlg(translate_text_item("Disconnection requested"), translate_text_item("Please confirm disconnection."), DisconnectLogin,));

cameratab();
configtab();
Expand Down
6 changes: 1 addition & 5 deletions www/js/scanwifidlg.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ function process_scanWifi_answer(response_text) {
content += `<td style='text-align:center;vertical-align:middle'>${protIcon}</td>`;
content += `<td><button id="${btnId}" class='btn btn-primary'>${get_icon_svg("ok")}</button></td>`;
content += "</tr>";
actions.push({
id: btnId,
type: "click",
method: select_ap_ssid(escapedSSID),
});
actions.push({ id: btnId, type: "click", method: (event) => select_ap_ssid(escapedSSID) });
}
}
} catch (e) {
Expand Down
Loading
Loading