js_lis 2.0.0 → 2.0.1

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.
@@ -37,6 +37,8 @@ export class VirtualKeyboard {
37
37
  return "Thai keyboard";
38
38
  case "numpad":
39
39
  return "Numpad Keyboard";
40
+ case "symbols":
41
+ return "Symbols Keyboard";
40
42
  default:
41
43
  return "Unknown Layout";
42
44
  }
@@ -94,7 +96,7 @@ export class VirtualKeyboard {
94
96
  layoutSelector.id = "layout-selector";
95
97
  layoutSelector.onchange = (e) => this.changeLayout(e.target.value);
96
98
 
97
- const layouts = ["full", "en", "th", "numpad"];
99
+ const layouts = ["full", "en", "th", "numpad", "symbols"];
98
100
  layouts.forEach((layout) => {
99
101
  const option = document.createElement("option");
100
102
  option.value = layout;
@@ -177,7 +179,7 @@ export class VirtualKeyboard {
177
179
  if (keyPressed === "scr" || keyPressed === "scrambled") {
178
180
  if (this.currentLayout === "en") {
179
181
  if (this.isScrambled) {
180
- this.unscrambleEnglishKeys();
182
+ this.unscrambleKeys();
181
183
  } else {
182
184
  this.scrambleEnglishKeys();
183
185
  }
@@ -191,7 +193,7 @@ export class VirtualKeyboard {
191
193
 
192
194
  if (this.currentLayout === "th") {
193
195
  if (this.isScrambled) {
194
- this.unscrambleEnglishKeys();
196
+ this.unscrambleKeys();
195
197
  } else {
196
198
  this.scrambleThaiKeys();
197
199
  }
@@ -205,7 +207,7 @@ export class VirtualKeyboard {
205
207
 
206
208
  if (this.currentLayout === "numpad") {
207
209
  if (this.isScrambled) {
208
- this.unscrambleEnglishKeys();
210
+ this.unscrambleKeys();
209
211
  } else {
210
212
  this.scrambleKeyboard();
211
213
  }
@@ -214,6 +216,18 @@ export class VirtualKeyboard {
214
216
  key.classList.toggle("active", this.isScrambled);
215
217
  });
216
218
  }
219
+
220
+ if (this.currentLayout === "symbols") {
221
+ if (this.isScrambled) {
222
+ this.unscrambleKeys();
223
+ } else {
224
+ this.scrambleSymbols();
225
+ }
226
+ this.isScrambled = !this.isScrambled;
227
+ document.querySelectorAll('.key[data-key="scr"]').forEach((key) => {
228
+ key.classList.toggle("active", this.isScrambled);
229
+ });
230
+ }
217
231
  return;
218
232
  }
219
233
 
@@ -412,7 +426,7 @@ export class VirtualKeyboard {
412
426
  }
413
427
 
414
428
  // [4]
415
- unscrambleEnglishKeys() {
429
+ unscrambleKeys() {
416
430
  this.keys = this.originalKeys;
417
431
  this.render();
418
432
  }
@@ -574,6 +588,19 @@ export class VirtualKeyboard {
574
588
  });
575
589
  }
576
590
 
591
+ // []
592
+ scrambleSymbols() {
593
+ const keys = document.querySelectorAll(
594
+ ":not([data-key='std']):not([data-key='scr']).key:not([data-key=backspace]"
595
+ );
596
+ const numbers = "@#$%^&*()_+~`{}|\\:'<>?/[]±§¶!€£¥¢©®™℅‰†".split("");
597
+ this.shuffleArray(numbers);
598
+ keys.forEach((key, index) => {
599
+ key.textContent = numbers[index];
600
+ key.dataset.key = numbers[index];
601
+ });
602
+ }
603
+
577
604
  // [14] จัดการการลากคีย์บอร์ด
578
605
  startDrag(event) {
579
606
  this.isDragging = true;
@@ -595,4 +622,4 @@ export class VirtualKeyboard {
595
622
  keyboard.style.top = `${event.clientY - this.offsetY}px`;
596
623
  }
597
624
  }
598
- }
625
+ }
package/layouts.js CHANGED
@@ -28,5 +28,12 @@ export const layouts = {
28
28
  ["7", "8", "9", "."],
29
29
  ["(", "0", ")", "="],
30
30
  ["backspace"]
31
+ ],
32
+ symbols: [
33
+ ['scr', '@', '#', '$', '%', '^', '&', '*', '(', ')'],
34
+ ['_', '+', '~', '`', '{', '}', '|', '\\', ':', '!'],
35
+ ["'", '<', '>', '?', '/', '[', ']', '±', '§', '¶'],
36
+ ['€', '£', '¥', '¢', '©', '®', '™', '℅', '‰', '†'],
37
+ ["backspace"]
31
38
  ]
32
- };
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_lis",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"