♻️ skipUntilthis => skipUntilThis

Also made some comparisons a bit more resilient.
This commit is contained in:
Gina Häußge committed 2021-02-23 17:06:13 +01:00
1 parent 0dc452e445
commit ac2e25f6d6
4 files changed
+8 -9

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ The plugin supports the following configuration keys:
* ``mobileSizeThreshold``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases
or release candidates). Defaults to ``false``.
* ``sizeThreshold``: Unique instance identifier, auto generated on first activation
* ``skipUntilthis``: If this string is provided the GCode Viewer will search for this string, and if found, skip all gcode up until this string. This can be used to skip prime nozzle gcode in the preview
* ``skipUntilThis``: If this string is provided the GCode Viewer will search for this string, and if found, skip all gcode up until this string. This can be used to skip prime nozzle gcode in the preview
.. _sec-bundledplugins-gcodeviewer-sourcecode:
@@ -49,7 +49,7 @@ class GcodeviewerPlugin(
return {
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
"sizeThreshold": 20 * 1024 * 1024, # 20MB
"skipUntilthis": None,
"skipUntilThis": None,
}
def get_settings_version(self):
@@ -476,15 +476,14 @@ $(function () {
self.showGCodeViewer = function (response, rstatus) {
// Slice of the gcode
if (self.settings.settings.plugins.gcodeviewer.skipUntilthis() != "") {
var findThis =
self.settings.settings.plugins.gcodeviewer.skipUntilthis() + "";
var findThis = self.settings.settings.plugins.gcodeviewer.skipUntilThis();
if (findThis && findThis !== "") {
var indexPos = response.indexOf("\n" + findThis);
// Try windows newlines if not found
if (indexPos == -1) {
if (indexPos === -1) {
indexPos = response.indexOf("\r" + findThis);
}
if (indexPos != -1) {
if (indexPos !== -1) {
// Slice and make sure we comment out any string left back after slicing - so if a user configures something like "G1" we dont end up with a snippet of gcode commands
// Yes it would be prettier to parse it line by line and remove the entire line, that is very slow and uses mem - this way we find the string, and remove it
response = ";" + response.slice(indexPos + findThis.length + 1);
@@ -20,9 +20,9 @@
</div>
</div>
<div class="control-group" title="{{ _('Skip/Hide gcode until this string')}}">
<label class="control-label" for="settings-skipUntilthis">{{ _('Skip to this') }}</label>
<label class="control-label" for="settings-skipUntilThis">{{ _('Skip to this') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilthis" id="settings-skipUntilthis" placeholder="; layer 1">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilThis" id="settings-skipUntilThis" placeholder="; layer 1">
</div>
<div class="controls">
<span class="help-inline">