summaryrefslogtreecommitdiff
path: root/web/share/js/kvm/recorder.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/share/js/kvm/recorder.js')
-rw-r--r--web/share/js/kvm/recorder.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/share/js/kvm/recorder.js b/web/share/js/kvm/recorder.js
index f2ca6d5c..93def77d 100644
--- a/web/share/js/kvm/recorder.js
+++ b/web/share/js/kvm/recorder.js
@@ -71,6 +71,10 @@ export function Recorder() {
__recordEvent({"event_type": "print", "event": {"text": text}});
};
+ self.recordAtxButtonEvent = function(button) {
+ __recordEvent({"event_type": "atx_button", "event": {"button": button}});
+ };
+
self.recordGpioSwitchEvent = function(channel, to) {
__recordEvent({"event_type": "gpio_switch", "event": {"channel": channel, "state": to}});
};
@@ -171,6 +175,8 @@ export function Recorder() {
__checkType(event.event.delta, "object", "Non-object mouse wheel delta");
__checkInt(event.event.delta.x, "Non-int mouse delta X");
__checkInt(event.event.delta.y, "Non-int mouse delta Y");
+ } else if (event.event_type === "atx_button") {
+ __checkType(event.event.button, "string", "Non-string ATX button");
} else if (event.event_type === "gpio_switch") {
__checkType(event.event.channel, "string", "Non-string GPIO channel");
__checkType(event.event.state, "boolean", "Non-bool GPIO state");
@@ -212,9 +218,11 @@ export function Recorder() {
while (index < __events.length) {
__setCounters(__events.length - index + 1, __events_time - time);
let event = __events[index];
+
if (event.event_type === "delay") {
__play_timer = setTimeout(() => __runEvents(index + 1, time + event.event.millis), event.event.millis);
return;
+
} else if (event.event_type === "print") {
let http = tools.makeRequest("POST", "/api/hid/print?limit=0", function() {
if (http.readyState === 4) {
@@ -230,6 +238,20 @@ export function Recorder() {
}
}, event.event.text, "text/plain");
return;
+
+ } else if (event.event_type === "atx_button") {
+ let http = tools.makeRequest("POST", `/api/atx/click?button=${event.event.button}`, function() {
+ if (http.readyState === 4) {
+ if (http.status !== 200) {
+ wm.error("ATX error:<br>", http.responseText);
+ __stopProcess();
+ } else if (http.status === 200) {
+ __play_timer = setTimeout(() => __runEvents(index + 1, time), 0);
+ }
+ }
+ });
+ return;
+
} else if (["gpio_switch", "gpio_pulse"].includes(event.event_type)) {
let path = "/api/gpio";
if (event.event_type === "gpio_switch") {
@@ -248,9 +270,11 @@ export function Recorder() {
}
});
return;
+
} else if (["key", "mouse_button", "mouse_move", "mouse_wheel"].includes(event.event_type)) {
__ws.send(JSON.stringify(event));
}
+
index += 1;
}
if ($("hid-recorder-loop-switch").checked) {