virtual-keypad 5.13.5 → 5.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/receiver.html +43 -28
- package/package.json +1 -1
- package/src/keypad.js +10 -5
- package/src/keypadPeer.js +7 -3
- package/src/maxKeySize.js +2 -2
- package/src/receiver.js +2 -2
package/dist/receiver.html
CHANGED
|
@@ -31,46 +31,61 @@
|
|
|
31
31
|
|
|
32
32
|
html,
|
|
33
33
|
body {
|
|
34
|
+
font-size: calc(1em + 1vw);
|
|
34
35
|
margin: 0;
|
|
35
36
|
padding: 0;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
#container {
|
|
36
40
|
height: 100vh;
|
|
37
41
|
width: 100vw;
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-rows: 1fr 3fr;
|
|
44
|
+
grid-template-columns: auto;
|
|
45
|
+
padding: 1em;
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/* background-color: #eee; */
|
|
47
|
+
#display-and-buttons {
|
|
48
|
+
display: flex;
|
|
49
|
+
min-width: 50vh;
|
|
50
|
+
overflow-y: auto;
|
|
51
|
+
border: 3px solid black;
|
|
52
|
+
border-radius: 10px;
|
|
48
53
|
}
|
|
49
54
|
#display {
|
|
50
55
|
overflow-x: wrap;
|
|
51
|
-
max-width: 75vw;
|
|
52
56
|
word-break: break-all;
|
|
57
|
+
padding: 0;
|
|
58
|
+
width: 70%;
|
|
59
|
+
/* max-height: 100%; */
|
|
60
|
+
overflow-y: auto;
|
|
61
|
+
}
|
|
62
|
+
#display-control-buttons {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
width: 30%;
|
|
66
|
+
padding: 2rem;
|
|
53
67
|
}
|
|
54
|
-
/* -------------------------------------------------------------------------- */
|
|
55
|
-
/* color: #FF9A00; */
|
|
56
|
-
/* color: #666; */
|
|
57
68
|
</style>
|
|
58
69
|
</head>
|
|
59
70
|
<body>
|
|
60
|
-
<div id="
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
<div id="container">
|
|
72
|
+
<div id="info">
|
|
73
|
+
<h1>Set up keypad</h1>
|
|
74
|
+
<p>
|
|
75
|
+
Scan the QR code from the device you'd like to use as a keypad. This
|
|
76
|
+
receiver just echoes keypresses; provide a different on-data callback to
|
|
77
|
+
customize how the receiver handles keypresses.
|
|
78
|
+
</p>
|
|
79
|
+
</div>
|
|
80
|
+
<div id="display-and-buttons">
|
|
81
|
+
<div id="display"></div>
|
|
82
|
+
<div id="display-control-buttons">
|
|
83
|
+
<button id="toggle-disable" style="display: none">Disable keys.</button>
|
|
84
|
+
<button id="randomize-alphabet" style="display: none">
|
|
85
|
+
Randomize character set.
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
74
89
|
</div>
|
|
75
90
|
<script>
|
|
76
91
|
if (window.location !== window.parent.location) {
|
|
@@ -93,7 +108,7 @@
|
|
|
93
108
|
onErrorReconnectMessage: "Custom error message",
|
|
94
109
|
};
|
|
95
110
|
let ondata_callback = (data) => {
|
|
96
|
-
|
|
111
|
+
receiver.displayUpdate(`[data] ${data.response}`, true);
|
|
97
112
|
console.log(data);
|
|
98
113
|
};
|
|
99
114
|
const disableSomeKeys = (ev) => {
|
package/package.json
CHANGED
package/src/keypad.js
CHANGED
|
@@ -8,7 +8,7 @@ class Keypad extends KeypadPeer {
|
|
|
8
8
|
keypadUrl: keypadUrl,
|
|
9
9
|
targetElementId: null,
|
|
10
10
|
visualResponseFeedback: false,
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
12
|
) {
|
|
13
13
|
super({
|
|
14
14
|
keypadUrl: keypadParameters.keypadUrl,
|
|
@@ -18,7 +18,7 @@ class Keypad extends KeypadPeer {
|
|
|
18
18
|
this.receiverPeerId = null;
|
|
19
19
|
|
|
20
20
|
const parametersFromURL = this.parseParams(
|
|
21
|
-
new URLSearchParams(window.location.search)
|
|
21
|
+
new URLSearchParams(window.location.search),
|
|
22
22
|
);
|
|
23
23
|
// this.alphabet = this.checkAlphabet(parametersFromURL.alphabet);
|
|
24
24
|
// this.font = parametersFromURL.font;
|
|
@@ -83,7 +83,7 @@ class Keypad extends KeypadPeer {
|
|
|
83
83
|
// Keypad has received data to update the keypad
|
|
84
84
|
if (!data.hasOwnProperty("alphabet") && !data.hasOwnProperty("font")) {
|
|
85
85
|
console.error(
|
|
86
|
-
'Error in parsing data received! Must set "alphabet" or "font" properties'
|
|
86
|
+
'Error in parsing data received! Must set "alphabet" or "font" properties',
|
|
87
87
|
);
|
|
88
88
|
} else {
|
|
89
89
|
this.alphabet = data.alphabet ?? this.alphabet;
|
|
@@ -190,6 +190,11 @@ class Keypad extends KeypadPeer {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
window.onresize = () => {
|
|
193
|
+
console.count("Window resized.");
|
|
194
|
+
applyMaxKeySize(this.alphabet?.length);
|
|
195
|
+
};
|
|
196
|
+
if (window.visualViewport) window.visualViewport.onresize = () => {
|
|
197
|
+
console.count("VisualViewport resized.");
|
|
193
198
|
applyMaxKeySize(this.alphabet?.length);
|
|
194
199
|
};
|
|
195
200
|
};
|
|
@@ -264,7 +269,7 @@ class Keypad extends KeypadPeer {
|
|
|
264
269
|
e.preventDefault();
|
|
265
270
|
const elementEndedOn = document.elementFromPoint(
|
|
266
271
|
e.changedTouches[0].clientX,
|
|
267
|
-
e.changedTouches[0].clientY
|
|
272
|
+
e.changedTouches[0].clientY,
|
|
268
273
|
);
|
|
269
274
|
switch (elementEndedOn?.className) {
|
|
270
275
|
case "response-button-label noselect":
|
|
@@ -338,7 +343,7 @@ class Keypad extends KeypadPeer {
|
|
|
338
343
|
});
|
|
339
344
|
};
|
|
340
345
|
interResponseKeypadMessaging = (
|
|
341
|
-
interResponseMessage = "Please fix your gaze on the + mark on your computer screen."
|
|
346
|
+
interResponseMessage = "Please fix your gaze on the + mark on your computer screen.",
|
|
342
347
|
) => {
|
|
343
348
|
// Change header text to reflect WAIT message
|
|
344
349
|
const header = document.getElementById("keypad-header");
|
package/src/keypadPeer.js
CHANGED
|
@@ -95,9 +95,13 @@ export class KeypadPeer {
|
|
|
95
95
|
onPeerDisconnected = () => {
|
|
96
96
|
this.displayUpdate(this.onErrorReconnectMessage);
|
|
97
97
|
// Workaround for peer.reconnect deleting previous id
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
try {
|
|
99
|
+
this.peer.id = this.lastPeerId;
|
|
100
|
+
this.peer._lastServerId = this.lastPeerId;
|
|
101
|
+
this.peer.reconnect();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.log(e);
|
|
104
|
+
}
|
|
101
105
|
};
|
|
102
106
|
onPeerClose = () => {
|
|
103
107
|
this.displayUpdate("Connection closed");
|
package/src/maxKeySize.js
CHANGED
|
@@ -58,12 +58,12 @@ export const applyMaxKeySize = (numberOfKeys) => {
|
|
|
58
58
|
const { keyHeightPx, cols, rows, widthPx, heightPx } = getKeysDimensions(
|
|
59
59
|
keysElem,
|
|
60
60
|
numberOfKeys,
|
|
61
|
-
aspect
|
|
61
|
+
aspect,
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
const keyElems = [...keysElem.getElementsByClassName("response-button")];
|
|
65
65
|
const controlKeyElemsMask = keyElems.map(
|
|
66
|
-
(e) => e.parentNode.id === "keypad-control-keys"
|
|
66
|
+
(e) => e.parentNode.id === "keypad-control-keys",
|
|
67
67
|
);
|
|
68
68
|
const gridCoords = keyElems
|
|
69
69
|
.filter((k, i) => !controlKeyElemsMask[i])
|
package/src/receiver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { QRCode } from "qrcode";
|
|
2
2
|
var QRCode = require("qrcode");
|
|
3
|
-
import "./receiver.css";
|
|
3
|
+
// import "./receiver.css";
|
|
4
4
|
import { KeypadPeer } from "./keypadPeer.js";
|
|
5
5
|
|
|
6
6
|
const doNothing = () => undefined;
|
|
@@ -209,7 +209,7 @@ class Receiver extends KeypadPeer {
|
|
|
209
209
|
}
|
|
210
210
|
this.conn = connection;
|
|
211
211
|
console.log("Connection: ", connection);
|
|
212
|
-
this.displayUpdate("
|
|
212
|
+
this.displayUpdate("[Connection established]", true);
|
|
213
213
|
this.#ready();
|
|
214
214
|
};
|
|
215
215
|
#ready = () => {
|