js_lis 1.0.19 → 1.0.22

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.
Files changed (2) hide show
  1. package/VirtualKeyboard.js +35 -18
  2. package/package.json +1 -1
@@ -43,17 +43,32 @@ export class VirtualKeyboard {
43
43
  }
44
44
 
45
45
  decodeText(encryptedData) {
46
+ if (!encryptedData || !encryptedData.encrypted || !encryptedData.iv) {
47
+ if (encryptedData === "\t") {
48
+ return "\t";
49
+ } else {
50
+ return " ";
51
+ }
52
+ }
53
+
54
+ try {
46
55
  const decrypted = CryptoJS.AES.decrypt(
47
- { ciphertext: CryptoJS.enc.Base64.parse(encryptedData.encrypted) },
48
- CryptoJS.enc.Hex.parse(this.secretKey),
49
- {
50
- iv: CryptoJS.enc.Base64.parse(encryptedData.iv),
51
- mode: CryptoJS.mode.CBC,
52
- padding: CryptoJS.pad.Pkcs7
53
- }
56
+ { ciphertext: CryptoJS.enc.Base64.parse(encryptedData.encrypted) },
57
+ CryptoJS.enc.Hex.parse(this.secretKey),
58
+ {
59
+ iv: CryptoJS.enc.Base64.parse(encryptedData.iv),
60
+ mode: CryptoJS.mode.CBC,
61
+ padding: CryptoJS.pad.Pkcs7
62
+ }
54
63
  );
55
64
  return decrypted.toString(CryptoJS.enc.Utf8);
65
+ } catch (error) {
66
+ console.error("Error decoding text:", error);
67
+ return " ";
68
+ }
56
69
  }
70
+
71
+
57
72
 
58
73
  getLayoutName(layout) {
59
74
  switch (layout) {
@@ -144,9 +159,11 @@ export class VirtualKeyboard {
144
159
  keyElement.className += ' space';
145
160
  }
146
161
 
147
- if (key === 'backspace') {
148
- keyElement.className += ' backspacew';
149
- }
162
+ if (key === 'backspace' || key === 'Backspace') {
163
+ keyElement.className += ' backspacew';
164
+ keyElement.innerHTML = '<i class="fa fa-backspace"></i>';
165
+ }
166
+
150
167
 
151
168
  keyElement.onclick = (e) => {
152
169
  e.preventDefault();
@@ -296,7 +313,7 @@ export class VirtualKeyboard {
296
313
  Object.values(this.ThaiAlphabetShift).includes(currentChar)
297
314
  ) {
298
315
  // เปลี่ยนกลับเมื่อปิด Shift
299
- const originalKey = Object.keys(ThaiAlphabetShift).find(
316
+ const originalKey = Object.keys(this.ThaiAlphabetShift).find(
300
317
  (key) => this.ThaiAlphabetShift[key] === currentChar
301
318
  );
302
319
  if (originalKey) {
@@ -307,18 +324,18 @@ export class VirtualKeyboard {
307
324
 
308
325
  if (
309
326
  this.capsLockActive &&
310
- this.currentLayout === "th" &&
327
+ this.currentLayout === "en" &&
311
328
  this.EngAlphabetShift[currentChar]
312
329
  ) {
313
330
  key.textContent = this.EngAlphabetShift[currentChar];
314
331
  key.dataset.key = this.EngAlphabetShift[currentChar];
315
332
  } else if (
316
333
  !this.capsLockActive &&
317
- this.currentLayout === "th" &&
334
+ this.currentLayout === "en" &&
318
335
  Object.values(this.EngAlphabetShift).includes(currentChar)
319
336
  ) {
320
337
  // เปลี่ยนกลับเมื่อปิด Shift
321
- const originalKey = Object.keys(EngAlphabetShift).find(
338
+ const originalKey = Object.keys(this.EngAlphabetShift).find(
322
339
  (key) => this.EngAlphabetShift[key] === currentChar
323
340
  );
324
341
  if (originalKey) {
@@ -362,7 +379,7 @@ export class VirtualKeyboard {
362
379
  Object.values(this.ThaiAlphabetShift).includes(currentChar)
363
380
  ) {
364
381
  // เปลี่ยนกลับเมื่อปิด Shift
365
- const originalKey = Object.keys(ThaiAlphabetShift).find(
382
+ const originalKey = Object.keys(this.ThaiAlphabetShift).find(
366
383
  (key) => this.ThaiAlphabetShift[key] === currentChar
367
384
  );
368
385
  if (originalKey) {
@@ -373,18 +390,18 @@ export class VirtualKeyboard {
373
390
 
374
391
  if (
375
392
  this.shiftActive &&
376
- this.currentLayout === "th" &&
393
+ this.currentLayout === "en" &&
377
394
  this.EngAlphabetShift[currentChar]
378
395
  ) {
379
396
  key.textContent = this.EngAlphabetShift[currentChar];
380
397
  key.dataset.key = this.EngAlphabetShift[currentChar];
381
398
  } else if (
382
399
  !this.shiftActive &&
383
- this.currentLayout === "th" &&
400
+ this.currentLayout === "en" &&
384
401
  Object.values(this.EngAlphabetShift).includes(currentChar)
385
402
  ) {
386
403
  // เปลี่ยนกลับเมื่อปิด Shift
387
- const originalKey = Object.keys(EngAlphabetShift).find(
404
+ const originalKey = Object.keys(this.EngAlphabetShift).find(
388
405
  (key) => this.EngAlphabetShift[key] === currentChar
389
406
  );
390
407
  if (originalKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_lis",
3
- "version": "1.0.19",
3
+ "version": "1.0.22",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"