summaryrefslogtreecommitdiff
path: root/web/js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-10-05 12:55:55 +0300
committerDevaev Maxim <[email protected]>2018-10-05 12:55:55 +0300
commitbbaf99c1b4a19ec6438f794bc045777443cbaaf2 (patch)
tree3622036af0412f0affdff3bf90c8ef451a0e9df3 /web/js
parent54cc8393a7e632eb0a1c85cc02dcf7130fe53766 (diff)
imroved pak
Diffstat (limited to 'web/js')
-rw-r--r--web/js/hid.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/web/js/hid.js b/web/js/hid.js
index ca535157..24f5bfbc 100644
--- a/web/js/hid.js
+++ b/web/js/hid.js
@@ -41,12 +41,8 @@ function Hid() {
window.onpagehide = __releaseAll;
window.onblur = __releaseAll;
- if (window.navigator.clipboard && window.navigator.clipboard.readText) {
- __chars_to_codes = __buildCharsToCodes();
- tools.setOnClick($("pak-button"), __pasteAsKeysFromClipboard);
- } else {
- $("pak-button").title = $("pak-led").title = "Your browser does not support the Clipboard API.\nUse Google Chrome or Chromium.";
- }
+ __chars_to_codes = __buildCharsToCodes();
+ tools.setOnClick($("pak-button"), __pasteAsKeys);
Array.prototype.forEach.call(document.querySelectorAll("[data-shortcut]"), function(el_shortcut) {
tools.setOnClick(el_shortcut, () => __emitShortcut(el_shortcut.getAttribute("data-shortcut").split(" ")));
@@ -59,7 +55,7 @@ function Hid() {
__ws = ws;
__keyboard.setSocket(ws);
__mouse.setSocket(ws);
- $("pak-button").disabled = !(window.navigator.clipboard && window.navigator.clipboard.readText && ws);
+ $("pak-text").disabled = $("pak-button").disabled = !ws;
};
var __releaseAll = function() {
@@ -131,12 +127,8 @@ function Hid() {
return chars_to_codes;
};
- var __pasteAsKeysFromClipboard = function() {
- window.navigator.clipboard.readText().then(__pasteAsKeys);
- };
-
- var __pasteAsKeys = function(text) {
- text = text.replace(/[^\x00-\x7F]/g, ""); // eslint-disable-line no-control-regex
+ var __pasteAsKeys = function() {
+ var text = $("pak-text").value.replace(/[^\x00-\x7F]/g, ""); // eslint-disable-line no-control-regex
if (text) {
var clipboard_codes = [];
var codes_count = 0;
@@ -157,6 +149,7 @@ function Hid() {
ui.confirm(confirm_msg).then(function(ok) {
if (ok) {
+ $("pak-text").disabled = true;
$("pak-button").disabled = true;
$("pak-led").className = "led-pak-typing";
$("pak-led").title = "Autotyping...";
@@ -170,6 +163,8 @@ function Hid() {
if (index < clipboard_codes.length && __ws) {
iterate();
} else {
+ $("pak-text").value = "";
+ $("pak-text").disabled = false;
$("pak-button").disabled = false;
$("pak-led").className = "led-off";
$("pak-led").title = "";
@@ -177,6 +172,8 @@ function Hid() {
});
};
iterate();
+ } else {
+ $("pak-text").value = "";
}
});
}