From c8ae6e7dde875726bc647bf0ff33f341e3429347 Mon Sep 17 00:00:00 2001 From: ntoff Date: Sat, 10 Mar 2018 04:35:55 +1000 Subject: [PATCH] delete onEventDisconnected unregister it delete it, remove it, make it gone. I dunno what's right anymore --- octoprint_estop/static/js/estop.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/octoprint_estop/static/js/estop.js b/octoprint_estop/static/js/estop.js index 8d6cee8..55219ee 100644 --- a/octoprint_estop/static/js/estop.js +++ b/octoprint_estop/static/js/estop.js @@ -54,21 +54,11 @@ $(function() { self.updateSettingsValues(); } - self.updateSettingsValues = function () { //lazy way of making sure we have the latest version of the settings + self.updateSettingsValues = function () { self.estopCommand(self.settings.settings.plugins.estop.estopCommand()); self.estopReconnect(self.settings.settings.plugins.estop.estopReconnect()); } - self.onEventDisconnected = function () { - if (self.estopReconnect() && self.emergencyCalled()) { - self.timedReconnect = setTimeout(function() { //reconnect 3 seconds after detecting the printer is offline - self.emergencyCalled(false); - OctoPrint.connection.connect(); - - }, 3*1000); //3 seconds - } - } - self.sendEstopCommand = function () { if (self.enableEstop()) { self.estopCommand(self.settings.settings.plugins.estop.estopCommand()); @@ -76,7 +66,15 @@ $(function() { if (self.estopReconnect()) { self.emergencyCalled(true); - OctoPrint.connection.disconnect(); //normally octoprint would probably disconnect anyway, just calling this here in case the printer is in a blocking loop + OctoPrint.connection.disconnect(); + self.onEventDisconnected = function () { + self.timedReconnect = setTimeout(function() { + self.emergencyCalled(false); + delete self.onEventDisconnected; + OctoPrint.connection.connect(); + + }, 3*1000); //3 seconds + } } } }