From 5aa5400c2ff4528040ee8263701dba459ee00a73 Mon Sep 17 00:00:00 2001 From: James Leach Date: Wed, 13 Feb 2019 10:57:21 -0600 Subject: [PATCH] Use of .split to create an array of strings which is sent to OctoPrint.control.sendGcode instead of a single string. This allows multiple-line Gcode to be interpreted properly. --- octoprint_klipper/static/js/klipper.js | 4 +++- octoprint_klipper/static/js/klipper_param_macro.js | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/octoprint_klipper/static/js/klipper.js b/octoprint_klipper/static/js/klipper.js index 26902b3..1f366f0 100644 --- a/octoprint_klipper/static/js/klipper.js +++ b/octoprint_klipper/static/js/klipper.js @@ -58,7 +58,9 @@ $(function() { if (macro.macro().match(paramObjRegex) == null) { OctoPrint.control.sendGcode( - macro.macro().replace(/(?:\r\n|\r|\n)/g, " ") + // Use .split to create an array of strings which is sent to + // OctoPrint.control.sendGcode instead of a single string. + macro.macro().split(/\r\n|\r|\n/) ); } else { self.paramMacroViewModel.process(macro); diff --git a/octoprint_klipper/static/js/klipper_param_macro.js b/octoprint_klipper/static/js/klipper_param_macro.js index 45ff631..bd1507d 100644 --- a/octoprint_klipper/static/js/klipper_param_macro.js +++ b/octoprint_klipper/static/js/klipper_param_macro.js @@ -60,11 +60,9 @@ $(function() { i++; return self.parameters()[i]["value"]; } - + // Use .split to create an array of strings which is sent to + // OctoPrint.control.sendGcode instead of a single string. expanded = self.macro.replace(paramObjRegex, replaceParams) -// expanded = "[\"" + expanded + "\"]" -// expanded = expanded.replace(/(?:\r\n|\r|\n)/g, "\",\""); - // Split using RegEx - cleaner expanded = expanded.split(/\r\n|\r|\n/); OctoPrint.control.sendGcode(expanded);