virtual-keypad 5.11.3 → 5.12.0
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 +1 -1
- package/package.json +1 -1
- package/src/keypad.css +5 -48
- package/src/keypad.js +2 -2
- package/src/maxKeySize.js +38 -22
- package/src/receiver.js +2 -1
package/dist/receiver.html
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
let keypad_options = {
|
|
76
76
|
// Specify a 'keypadUrl' field to redirect to a keypad hosted elsewhere
|
|
77
77
|
// FUTURE should be able to have a visual keypress or not from here
|
|
78
|
-
alphabet: [..."
|
|
78
|
+
alphabet: [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789".split(""), "RETURN", "SPACE"], // Set of symbols to display; array perfered
|
|
79
79
|
font: "Arial", // Supported font, in which to display letters
|
|
80
80
|
targetElementId: "display", // id of the the div where messages should be displayed
|
|
81
81
|
visualResponseFeedback: false,
|
package/package.json
CHANGED
package/src/keypad.css
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
}
|
|
18
18
|
#keypad-header {
|
|
19
19
|
height: 100%;
|
|
20
|
-
/* min-height: 5vh; */
|
|
21
20
|
font-size: 1.5rem;
|
|
22
21
|
font-weight: 700;
|
|
23
22
|
text-align: center;
|
|
@@ -25,11 +24,6 @@
|
|
|
25
24
|
grid-row: 1;
|
|
26
25
|
overflow-y: auto;
|
|
27
26
|
|
|
28
|
-
/* padding: 0.5em;
|
|
29
|
-
margin-top: 0.5em;
|
|
30
|
-
margin-left: 0.5em;
|
|
31
|
-
margin-right: 0.5em; */
|
|
32
|
-
|
|
33
27
|
border-radius: 0.5em;
|
|
34
28
|
|
|
35
29
|
box-shadow: inset 2px 2px 4px #888888,
|
|
@@ -47,31 +41,6 @@
|
|
|
47
41
|
#keypad-keys {
|
|
48
42
|
/* Second row, within the keypad grid (ie whole page) */
|
|
49
43
|
grid-row: 2;
|
|
50
|
-
|
|
51
|
-
padding: 10px;
|
|
52
|
-
|
|
53
|
-
margin: 15px;
|
|
54
|
-
|
|
55
|
-
/* overflow-y: auto;
|
|
56
|
-
overflow-x: visible; */
|
|
57
|
-
|
|
58
|
-
/* width: 100%;
|
|
59
|
-
height: 100%;
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-wrap: wrap-reverse;
|
|
62
|
-
flex-direction: row;
|
|
63
|
-
column-gap: 5px;
|
|
64
|
-
row-gap: 5px; */
|
|
65
|
-
|
|
66
|
-
/* Horizontal shift of buttons */
|
|
67
|
-
/* justify-content: center; */
|
|
68
|
-
|
|
69
|
-
/* Vertical shift of buttons */
|
|
70
|
-
/* align-items: center; */
|
|
71
|
-
|
|
72
|
-
/* Hide scrollbar */
|
|
73
|
-
/* -ms-overflow-style: none;
|
|
74
|
-
scrollbar-width: none; */
|
|
75
44
|
}
|
|
76
45
|
/* Hide scrollbar */
|
|
77
46
|
/* #keypad-keys::-webkit-scrollbar {
|
|
@@ -79,14 +48,7 @@
|
|
|
79
48
|
} */
|
|
80
49
|
|
|
81
50
|
.response-button {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/* width: 100%;
|
|
85
|
-
height: 100%;
|
|
86
|
-
max-width: min(25vw, 25vh, 150px);
|
|
87
|
-
max-height: min(25vw, 25vh, 150px);
|
|
88
|
-
min-width: 32px;
|
|
89
|
-
min-height: 32px;
|
|
51
|
+
/* border: 1px solid red; */
|
|
90
52
|
cursor: pointer;
|
|
91
53
|
|
|
92
54
|
/* Center text within button */
|
|
@@ -97,13 +59,13 @@
|
|
|
97
59
|
/* Curve corners of buttons */
|
|
98
60
|
border-radius: min(25px, 15%);
|
|
99
61
|
|
|
100
|
-
/* Make buttons square */
|
|
101
|
-
aspect-ratio: 1;
|
|
102
|
-
|
|
103
62
|
/* Style button text */
|
|
104
|
-
font-size: 3rem;
|
|
63
|
+
/* font-size: 3rem; */
|
|
64
|
+
font-size: xx-large;
|
|
105
65
|
font-weight: 700;
|
|
106
66
|
|
|
67
|
+
padding: 0;
|
|
68
|
+
margin: 0;
|
|
107
69
|
|
|
108
70
|
box-shadow: 1px 1px 2px #888888,
|
|
109
71
|
-1px -1px 2px #fff;
|
|
@@ -111,7 +73,6 @@
|
|
|
111
73
|
.response-button:active {
|
|
112
74
|
box-shadow: 1px 2px 2px 1px #999;
|
|
113
75
|
background-color: #aaa;
|
|
114
|
-
font-size: large;
|
|
115
76
|
}
|
|
116
77
|
|
|
117
78
|
/* Only do on a hover-enabled device, ie not a phone/tablet */
|
|
@@ -122,10 +83,6 @@
|
|
|
122
83
|
}
|
|
123
84
|
}
|
|
124
85
|
|
|
125
|
-
/* .response-button:active {
|
|
126
|
-
background-color: steelblue;
|
|
127
|
-
box-shadow: 1px 5px 5px 1px lightslategray;
|
|
128
|
-
} */
|
|
129
86
|
|
|
130
87
|
.response-button-label {
|
|
131
88
|
text-align: center;
|
package/src/keypad.js
CHANGED
|
@@ -252,9 +252,9 @@ class Keypad extends KeypadPeer {
|
|
|
252
252
|
e.changedTouches[0].clientX,
|
|
253
253
|
e.changedTouches[0].clientY
|
|
254
254
|
);
|
|
255
|
-
switch (elementEndedOn
|
|
255
|
+
switch (elementEndedOn?.className) {
|
|
256
256
|
case "response-button-label noselect":
|
|
257
|
-
buttonResponseFn(elementEndedOn
|
|
257
|
+
buttonResponseFn(elementEndedOn?.parentElement); // e.target.click();
|
|
258
258
|
break;
|
|
259
259
|
case "response-button":
|
|
260
260
|
buttonResponseFn(elementEndedOn); // e.target.click();
|
package/src/maxKeySize.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
const getKeysDimensions = (elem, n, aspect=0.5) => {
|
|
3
2
|
/**** translation of maxKeySize.m, original provided courtesy of Prof Denis Pelli ****/
|
|
4
3
|
let keyHeightPx;
|
|
@@ -8,7 +7,7 @@ const getKeysDimensions = (elem, n, aspect=0.5) => {
|
|
|
8
7
|
const heightPx = elem.clientHeight;
|
|
9
8
|
let screenArea=widthPx*heightPx
|
|
10
9
|
|
|
11
|
-
keyHeightPx= (-1+Math.sqrt(1+4*n*heightPx/widthPx))/(2*n/widthPx);
|
|
10
|
+
keyHeightPx = (-1+Math.sqrt(1+4*n*heightPx/widthPx))/(2*n/widthPx);
|
|
12
11
|
keyHeightPx = (-1+Math.sqrt(1+4*n*heightPx*aspect/widthPx))/(2*aspect*n/widthPx);
|
|
13
12
|
|
|
14
13
|
while (n > (Math.floor(heightPx/keyHeightPx - 1)*Math.floor(widthPx/(aspect*keyHeightPx)))){
|
|
@@ -37,6 +36,7 @@ const getKeysDimensions = (elem, n, aspect=0.5) => {
|
|
|
37
36
|
|
|
38
37
|
export const applyMaxKeySize = (numberOfKeys) => {
|
|
39
38
|
const aspect = 1;
|
|
39
|
+
let margin = 5;
|
|
40
40
|
const keysElem = document.getElementById("keypad");
|
|
41
41
|
const {keyHeightPx, cols, rows, widthPx, heightPx} = getKeysDimensions(keysElem, numberOfKeys, aspect);
|
|
42
42
|
const keyElems = [...keysElem.getElementsByClassName("response-button")];
|
|
@@ -49,41 +49,57 @@ export const applyMaxKeySize = (numberOfKeys) => {
|
|
|
49
49
|
const verticalMarginOffset = Math.floor(freeHeight/2);
|
|
50
50
|
const horizontalMarginOffset = Math.floor(freeWidth/2);
|
|
51
51
|
|
|
52
|
+
let keyFontSize;
|
|
52
53
|
let j=0;
|
|
53
54
|
keyElems.forEach((k,i) => {
|
|
54
55
|
k.style.position = "fixed";
|
|
55
56
|
const controlKey = controlKeyElemsMask[i];
|
|
56
57
|
let top, left, width;
|
|
57
58
|
if (controlKey) {
|
|
58
|
-
top =
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
top = heightPx-keyHeightPx;
|
|
60
|
+
width = widthPx/2 - horizontalMarginOffset - margin;
|
|
61
|
+
const m = horizontalMarginOffset + margin*0.5;
|
|
62
|
+
left = (k.id.toLowerCase().includes("space") ? m : m + width + margin);
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
k.style.width = "auto";
|
|
64
|
-
k.style.whiteSpace = "nowrap";
|
|
65
|
-
// Set to a nominal font size, s
|
|
66
|
-
const s = 20;
|
|
67
|
-
let w = k.getBoundingClientRect().width;
|
|
68
|
-
console.log("!. ~ file: maxKeySize.js:70 ~ keyElems.forEach ~ w:", w)
|
|
69
|
-
k.style.fontSize = s + "px";
|
|
70
|
-
// Measure width of elem, w
|
|
71
|
-
w = k.getBoundingClientRect().width;
|
|
72
|
-
const r = 1/(w/width)
|
|
73
|
-
// Set font size to s*r
|
|
74
|
-
const f = Math.floor(s*r);
|
|
64
|
+
const f = getLargeFontSize(k, width, keyHeightPx-margin);
|
|
75
65
|
k.style.fontSize = f + "px";
|
|
66
|
+
k.style.borderRadius = "25px";
|
|
67
|
+
k.style.height = (keyHeightPx - margin)+ "px";
|
|
76
68
|
} else {
|
|
77
|
-
|
|
69
|
+
const height = keyHeightPx - margin;
|
|
70
|
+
width = height*aspect;
|
|
78
71
|
const [y,x] = gridCoords[j];
|
|
79
72
|
j += 1;
|
|
80
|
-
top = y*
|
|
81
|
-
left = x*width+horizontalMarginOffset;
|
|
73
|
+
top = y*height + ((y+1)*margin) + verticalMarginOffset - margin/2;
|
|
74
|
+
left = x*width + ((x+1)*margin) + horizontalMarginOffset - margin/2;
|
|
75
|
+
if (!keyFontSize) {
|
|
76
|
+
keyFontSize = getLargeFontSize(k, width, height);
|
|
77
|
+
}
|
|
78
|
+
k.style.height = height + "px";
|
|
79
|
+
k.style.fontSize = height/2 + "px";
|
|
82
80
|
}
|
|
83
81
|
k.style.width = width + "px";
|
|
84
|
-
k.style.height = keyHeightPx + "px";
|
|
85
82
|
k.style.top = top + "px";
|
|
86
83
|
k.style.left = left + "px";
|
|
87
84
|
k.style.visibility = "visible";
|
|
88
85
|
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getLargeFontSize = (k, width, height) => {
|
|
89
|
+
k.style.height = "auto";
|
|
90
|
+
k.style.width = "auto";
|
|
91
|
+
k.style.whiteSpace = "nowrap";
|
|
92
|
+
|
|
93
|
+
// Set to a nominal font size, s
|
|
94
|
+
const s = 20;
|
|
95
|
+
k.style.fontSize = s + "px";
|
|
96
|
+
// Measure width of elem, w
|
|
97
|
+
const w = k.getBoundingClientRect().width;
|
|
98
|
+
const h = k.getBoundingClientRect().height
|
|
99
|
+
const rW = 1/(w/width)
|
|
100
|
+
const rH = 1/(h/height)
|
|
101
|
+
const r = Math.min(rW, rH)
|
|
102
|
+
// Set font size to s*r
|
|
103
|
+
const f = Math.floor(s*r);
|
|
104
|
+
return f;
|
|
89
105
|
};
|
package/src/receiver.js
CHANGED
|
@@ -141,7 +141,8 @@ class Receiver extends KeypadPeer {
|
|
|
141
141
|
|
|
142
142
|
let queryString = this.queryStringFromObject(params);
|
|
143
143
|
const uri = this.keypadUrl + queryString;
|
|
144
|
-
this.
|
|
144
|
+
this.qrURL = uri;
|
|
145
|
+
console.log(this.qrURL);
|
|
145
146
|
|
|
146
147
|
// Display QR code for the participant to scan
|
|
147
148
|
const qrCanvas = document.createElement("canvas");
|