summaryrefslogtreecommitdiff
path: root/web/share/js/kvm
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-12-11 21:09:49 +0200
committerMaxim Devaev <[email protected]>2024-12-11 21:09:49 +0200
commite014cbcedff6d7e96a1d5d6417ed5b9362d927c5 (patch)
treeff050e6b282eb65feebb4ee5cc9d92c9f36f2796 /web/share/js/kvm
parentadbd4f242b4478dd1a67de1afb3ba799de57f2d5 (diff)
pikvm/pikvm#858, pikvm/pikvm#1249: Added slow typing mode for /api/hid/print
Diffstat (limited to 'web/share/js/kvm')
-rw-r--r--web/share/js/kvm/paste.js6
-rw-r--r--web/share/js/kvm/recorder.js14
2 files changed, 14 insertions, 6 deletions
diff --git a/web/share/js/kvm/paste.js b/web/share/js/kvm/paste.js
index 3fe1d62c..f42fa22c 100644
--- a/web/share/js/kvm/paste.js
+++ b/web/share/js/kvm/paste.js
@@ -34,6 +34,7 @@ export function Paste(__recorder) {
var __init__ = function() {
tools.storage.bindSimpleSwitch($("hid-pak-ask-switch"), "hid.pak.ask", true);
+ tools.storage.bindSimpleSwitch($("hid-pak-slow-switch"), "hid.pak.slow", false);
tools.storage.bindSimpleSwitch($("hid-pak-secure-switch"), "hid.pak.secure", false, function(value) {
$("hid-pak-text").style.setProperty("-webkit-text-security", (value ? "disc" : "none"));
});
@@ -67,10 +68,11 @@ export function Paste(__recorder) {
tools.el.setEnabled($("hid-pak-keymap-selector"), false);
let keymap = $("hid-pak-keymap-selector").value;
+ let slow = $("hid-pak-slow-switch").checked;
tools.debug(`HID: paste-as-keys ${keymap}: ${text}`);
- tools.httpPost("/api/hid/print", {"limit": 0, "keymap": keymap}, function(http) {
+ tools.httpPost("/api/hid/print", {"limit": 0, "keymap": keymap, "slow": slow}, function(http) {
tools.el.setEnabled($("hid-pak-text"), true);
tools.el.setEnabled($("hid-pak-button"), true);
tools.el.setEnabled($("hid-pak-keymap-selector"), true);
@@ -80,7 +82,7 @@ export function Paste(__recorder) {
} else if (http.status !== 200) {
wm.error("HID paste error", http.responseText);
} else if (http.status === 200) {
- __recorder.recordPrintEvent(text, keymap);
+ __recorder.recordPrintEvent(text, keymap, slow);
}
}, text, "text/plain");
};
diff --git a/web/share/js/kvm/recorder.js b/web/share/js/kvm/recorder.js
index 822aa972..5d9d1553 100644
--- a/web/share/js/kvm/recorder.js
+++ b/web/share/js/kvm/recorder.js
@@ -67,8 +67,8 @@ export function Recorder() {
__recordEvent(event);
};
- self.recordPrintEvent = function(text, keymap) {
- __recordEvent({"event_type": "print", "event": {"text": text, "keymap": keymap}});
+ self.recordPrintEvent = function(text, keymap, slow) {
+ __recordEvent({"event_type": "print", "event": {"text": text, "keymap": keymap, "slow": slow}});
};
self.recordAtxButtonEvent = function(button) {
@@ -159,9 +159,12 @@ export function Recorder() {
} else if (event.event_type === "print") {
__checkType(event.event.text, "string", "Non-string print text");
- if (event.event.keymap) {
+ if (event.event.keymap !== undefined) {
__checkType(event.event.keymap, "string", "Non-string keymap");
}
+ if (event.event.slow !== undefined) {
+ __checkType(event.event.slow, "boolean", "Non-bool slow");
+ }
} else if (event.event_type === "key") {
__checkType(event.event.key, "string", "Non-string key code");
@@ -284,9 +287,12 @@ export function Recorder() {
} else if (event.event_type === "print") {
let params = {"limit": 0};
- if (event.event.keymap) {
+ if (event.event.keymap !== undefined) {
params["keymap"] = event.event.keymap;
}
+ if (event.event.slow !== undefined) {
+ params["slow"] = event.event.slow;
+ }
tools.httpPost("/api/hid/print", params, function(http) {
if (http.status === 413) {
wm.error("Too many text for paste!");