wrap it in a try catch
Hopefully when something in my plugin breaks (that's when, not if) it won't take down all of octoprint's UI.
This commit is contained in:
parent
56f73ad6ab
commit
99364df94e
@ -22,35 +22,40 @@ $(function() {
|
|||||||
sendFanSpeed = function () {
|
sendFanSpeed = function () {
|
||||||
self.control.sendCustomCommand({ command: "M106 S" + self.fanPWM() });
|
self.control.sendCustomCommand({ command: "M106 S" + self.fanPWM() });
|
||||||
};
|
};
|
||||||
//extra classes
|
try {
|
||||||
$("#control > div.jog-panel").eq(0).addClass("controls");
|
//extra classes
|
||||||
$("#control > div.jog-panel").eq(1).addClass("tools");
|
$("#control > div.jog-panel").eq(0).addClass("controls");
|
||||||
$("#control > div.jog-panel").eq(2).addClass("general");
|
$("#control > div.jog-panel").eq(1).addClass("tools");
|
||||||
//If !TouchUI then remove standard buttons + add slider + new buttons
|
$("#control > div.jog-panel").eq(2).addClass("general");
|
||||||
if ($("#touch body").length ==0 ) {
|
//If !TouchUI then remove standard buttons + add slider + new buttons
|
||||||
//add ID to buttons
|
if ($("#touch body").length ==0 ) {
|
||||||
$("#control > div.general").find("button").eq(0).attr("id", "motors-off");
|
//add ID to buttons
|
||||||
$("#control > div.general").find("button").eq(1).attr("id", "fan-on");
|
$("#control > div.general").find("button").eq(0).attr("id", "motors-off");
|
||||||
$("#control > div.general").find("button").eq(2).attr("id", "fan-off");
|
$("#control > div.general").find("button").eq(1).attr("id", "fan-on");
|
||||||
//remove original fan on/off buttons
|
$("#control > div.general").find("button").eq(2).attr("id", "fan-off");
|
||||||
$("#fan-on").remove();
|
//remove original fan on/off buttons
|
||||||
$("#fan-off").remove();
|
$("#fan-on").remove();
|
||||||
//add new fan controls
|
$("#fan-off").remove();
|
||||||
$("#control > div.jog-panel.general").find("button").eq(0).before("\
|
//add new fan controls
|
||||||
<input type=\"number\" style=\"width: 90px\" data-bind=\"slider: {min: 00, max: 100, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
$("#control > div.jog-panel.general").find("button").eq(0).before("\
|
||||||
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan on") + ":<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
<input type=\"number\" style=\"width: 90px\" data-bind=\"slider: {min: 00, max: 100, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
||||||
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendCustomCommand({ type: 'command', commands: ['M106 S0'] }) }\">" + gettext("Fan off") + "</button>\
|
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan on") + ":<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
||||||
");
|
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendCustomCommand({ type: 'command', commands: ['M106 S0'] }) }\">" + gettext("Fan off") + "</button>\
|
||||||
} else { //if TouchUI is active we only add the speed input + fan on button in a new section.
|
");
|
||||||
console.log("Fan Speed Slider: NOTICE! TouchUI is active, adding simplified control.");
|
} else { //if TouchUI is active we only add the speed input + fan on button in a new section.
|
||||||
$("#control > div.jog-panel.general").after("\
|
console.log("Fan Speed Slider: NOTICE! TouchUI is active, adding simplified control.");
|
||||||
<div id=\"control-fan-slider\" class=\"jog-panel filament\" data-bind=\"visible: loginState.isUser\">\
|
$("#control > div.jog-panel.general").after("\
|
||||||
<div>\
|
<div id=\"control-fan-slider\" class=\"jog-panel filament\" data-bind=\"visible: loginState.isUser\">\
|
||||||
<input type=\"number\" style=\"width: 150px\" data-bind=\"slider: {min: 00, max: 255, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
<div>\
|
||||||
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan Speed(%)") + "</button>\
|
<input type=\"number\" style=\"width: 150px\" data-bind=\"slider: {min: 00, max: 255, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
||||||
|
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan Speed(%)") + "</button>\
|
||||||
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
");
|
||||||
");
|
}
|
||||||
|
}
|
||||||
|
catch(error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
//retrieve settings
|
//retrieve settings
|
||||||
self.onBeforeBinding = function() {
|
self.onBeforeBinding = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user