#6 UI Updates senden und anzeigen
This commit is contained in:
parent
8a188b5854
commit
0a7aea4f35
@ -5,114 +5,6 @@ $(function() {
|
|||||||
self.loginState = parameters[0];
|
self.loginState = parameters[0];
|
||||||
self.settings = parameters[1];
|
self.settings = parameters[1];
|
||||||
self.printer = parameters[2];
|
self.printer = parameters[2];
|
||||||
|
|
||||||
|
|
||||||
self.mystromswitchEnabled = ko.observable();
|
|
||||||
|
|
||||||
self.testButtonChangeStatus = function (stat) {
|
|
||||||
$("#tester_mystromswitch_gcode").prop("disabled", stat);
|
|
||||||
$("#tester_mystromswitch_api").prop("disabled", stat);
|
|
||||||
$("#tester_mystromswitch_api_custom").prop("disabled", stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.eventChangeCheckToRadio = function (id, listOff) {
|
|
||||||
$(id).on("change", function () {
|
|
||||||
if ($(this).prop("checked") == true)
|
|
||||||
{
|
|
||||||
listOff.forEach(function(element) {
|
|
||||||
if (id != element.id)
|
|
||||||
{
|
|
||||||
if ($(element.id).prop("checked") == true)
|
|
||||||
{
|
|
||||||
$(element.id).unbind("change");
|
|
||||||
$(element.id).trigger("click");
|
|
||||||
self.eventChangeCheckToRadio(element.id, listOff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#tester_mystromswitch_gcode").on("click", function () {
|
|
||||||
self.settings.saveData();
|
|
||||||
$(this).children("i").show();
|
|
||||||
setTimeout(function (current) {
|
|
||||||
$.ajax({
|
|
||||||
url: API_BASEURL + "plugin/mystromswitch",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
data: JSON.stringify({
|
|
||||||
command: "shutdown",
|
|
||||||
mode: 1,
|
|
||||||
eventView : true
|
|
||||||
}),
|
|
||||||
contentType: "application/json; charset=UTF-8"
|
|
||||||
}).done(function() {
|
|
||||||
current.children("i").hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
}, 1000, $(this));
|
|
||||||
|
|
||||||
});
|
|
||||||
$("#tester_mystromswitch_api").on("click", function () {
|
|
||||||
self.settings.saveData();
|
|
||||||
$(this).children("i").show();
|
|
||||||
setTimeout(function (current) {
|
|
||||||
$.ajax({
|
|
||||||
url: API_BASEURL + "plugin/mystromswitch",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
data: JSON.stringify({
|
|
||||||
command: "shutdown",
|
|
||||||
mode: 2,
|
|
||||||
eventView : true
|
|
||||||
}),
|
|
||||||
contentType: "application/json; charset=UTF-8"
|
|
||||||
}).done(function() {
|
|
||||||
current.children("i").hide();
|
|
||||||
});
|
|
||||||
}, 1000, $(this));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#tester_mystromswitch_api_custom").on("click", function () {
|
|
||||||
self.settings.saveData();
|
|
||||||
$(this).children("i").show();
|
|
||||||
setTimeout(function (current) {
|
|
||||||
$.ajax({
|
|
||||||
url: API_BASEURL + "plugin/mystromswitch",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
data: JSON.stringify({
|
|
||||||
command: "shutdown",
|
|
||||||
mode: 3,
|
|
||||||
eventView : true
|
|
||||||
}),
|
|
||||||
contentType: "application/json; charset=UTF-8"
|
|
||||||
}).done(function() {
|
|
||||||
current.children("i").hide();
|
|
||||||
});
|
|
||||||
}, 1000, $(this));
|
|
||||||
|
|
||||||
});
|
|
||||||
self.listOffMode = [
|
|
||||||
{"id" : "#mystromswitch_mode_shutdown_gcode"},
|
|
||||||
{"id" : "#mystromswitch_mode_shutdown_api"},
|
|
||||||
{"id" : "#mystromswitch_mode_shutdown_api_custom"},
|
|
||||||
]
|
|
||||||
self.listOffHTTPMethode = [
|
|
||||||
{"id" : "#mystromswitch_api_custom_GET"},
|
|
||||||
{"id" : "#mystromswitch_api_custom_POST"},
|
|
||||||
{"id" : "#mystromswitch_api_custom_PUT"}
|
|
||||||
]
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_gcode", self.listOffMode);
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_api", self.listOffMode);
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_mode_shutdown_api_custom", self.listOffMode);
|
|
||||||
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_api_custom_GET", self.listOffHTTPMethode);
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_api_custom_POST", self.listOffHTTPMethode);
|
|
||||||
self.eventChangeCheckToRadio("#mystromswitch_api_custom_PUT", self.listOffHTTPMethode);
|
|
||||||
|
|
||||||
// Hack to remove automatically added Cancel button
|
// Hack to remove automatically added Cancel button
|
||||||
// See https://github.com/sciactive/pnotify/issues/141
|
// See https://github.com/sciactive/pnotify/issues/141
|
||||||
|
Loading…
Reference in New Issue
Block a user