Skip to content

Commit

Permalink
support keyboard layout emulation, now url only
Browse files Browse the repository at this point in the history
  • Loading branch information
noureddin committed Nov 1, 2023
1 parent 70005fb commit 8dfe50c
Show file tree
Hide file tree
Showing 6 changed files with 391 additions and 42 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ These are not changeable from the UI, only from the URL parameters; they are exp

- `cn`: at the end of a recitation, it appends a "phrase" from the next ayah if it's in the same sura.

- `emu=`, `emulate=`, or `emulation=`: to use a specific keyboard layout regardless of your currently activated layout, even if yours is an English layout. Currently supported layouts:

- `ibm`: the common Arabic layout on IBM PCs.
- `mac`: the common Arabic layout on Apple devices.
- `arak`: the [Arak](https://github.com/noureddin/arak) improved layout.
- `dv`: an experimental phonetic layout based on Dvorak.

- `dt`, or `disableteacher`: to remove teacher mode selector from the UI. The Teacher mode can still be set from the URL params. Useful to force a specific value for the option (e.g. no-teacher) in an embedding web app for example.

**Warning:** It's still changeable from the JavaScript console; I couldn't disable this yet.
Expand Down
154 changes: 154 additions & 0 deletions b.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,157 @@ function insert_in_field (el, ch) {
el.selectionStart = el.selectionEnd = st + ch.length
}

const mappings = {
arak: {
Backquote: ['`', '~'],
Minus: ['[', '{'],
Equal: [']', '}'],
KeyQ: ['ض', '"'],
KeyW: ['ع', 'غ'],
KeyE: ['ب', 'پ'],
KeyR: ['ح', 'َ'],
KeyT: ['س', 'ً'],
KeyY: ['خ', 'ٌ'],
KeyU: ['د', 'ُ'],
KeyI: ['أ', 'آ'],
KeyO: ['ك', 'گ'],
KeyP: ['ج', 'چ'],
BracketLeft: ['/', '؟'],
BracketRight: ['=', '+'],
KeyA: ['ه', '؛'],
KeyS: ['ي', '»'],
KeyD: ['م', '«'],
KeyF: ['ن', 'ْ'],
KeyG: ['ف', 'ڤ'],
KeyH: ['ت', 'ث'],
KeyJ: ['ل', 'ّ'],
KeyK: ['ا', 'ء'],
KeyL: ['و', 'ؤ'],
Semicolon: ['ر', '>'],
Quote: ['إ', '<'],
KeyZ: ['.', ':'],
KeyX: ['،', 'ـ'],
KeyC: ['ش', '_'],
KeyV: ['ق', '-'],
KeyB: ['ص', "'"],
KeyN: ['ذ', 'ٍ'],
KeyM: ['ة', 'ِ'],
Comma: ['ى', 'ئ'],
Period: ['ز', 'ژ'],
Slash: ['ط', 'ظ'],
},
dv: {
Backquote: ['`', '~'],
Minus: ['[', '{'],
Equal: [']', '}'],
KeyQ: ["'", '"'],
KeyW: ['،', '<'],
KeyE: ['.', '>'],
KeyR: ['ط', 'ظ'],
KeyT: ['ى', 'آ'],
KeyY: ['ف', 'ڤ'],
KeyU: ['غ', 'ـ'],
KeyI: ['ص', 'ض'],
KeyO: ['ر', '»'],
KeyP: ['ل', '«'],
BracketLeft: ['/', '؟'],
BracketRight: ['=', '+'],
KeyA: ['ا', 'أ'],
KeyS: ['ع', 'إ'],
KeyD: ['ه', 'ة'],
KeyF: ['و', 'ؤ'],
KeyG: ['ي', 'ئ'],
KeyH: ['د', 'َ'],
KeyJ: ['ح', 'ً'],
KeyK: ['ت', 'ٌ'],
KeyL: ['ن', 'ُ'],
Semicolon: ['س', 'ش'],
Quote: ['-', '_'],
KeyZ: ['؛', ':'],
KeyX: ['ق', 'ء'],
KeyC: ['ج', 'چ'],
KeyV: ['ك', 'گ'],
KeyB: ['خ', 'ْ'],
KeyN: ['ب', 'پ'],
KeyM: ['م', 'ّ'],
Comma: ['ث', 'ٍ'],
Period: ['ذ', 'ِ'],
Slash: ['ز', 'ژ'],
},
ibm: {
Backquote: ['ذ', 'ّ'],
Minus: ['-', '_'],
Equal: ['=', '+'],
KeyQ: ['ض', 'َ'],
KeyW: ['ص', 'ً'],
KeyE: ['ث', 'ُ'],
KeyR: ['ق', 'ٌ'],
KeyT: ['ف', 'لإ'],
KeyY: ['غ', 'إ'],
KeyU: ['ع', '`'],
KeyI: ['ه', '÷'],
KeyO: ['خ', '×'],
KeyP: ['ح', '؛'],
BracketLeft: ['ج', '<'],
BracketRight: ['د', '>'],
KeyA: ['ش', 'ِ'],
KeyS: ['س', 'ٍ'],
KeyD: ['ي', ']'],
KeyF: ['ب', '['],
KeyG: ['ل', 'لأ'],
KeyH: ['ا', 'أ'],
KeyJ: ['ت', 'ـ'],
KeyK: ['ن', '،'],
KeyL: ['م', '/'],
Semicolon: ['ك', ':'],
Quote: ['ط', '"'],
KeyZ: ['ئ', '~'],
KeyX: ['ء', 'ْ'],
KeyC: ['ؤ', '}'],
KeyV: ['ر', '{'],
KeyB: ['لا', 'لآ'],
KeyN: ['ى', 'آ'],
KeyM: ['ة', "'"],
Comma: ['و', ','],
Period: ['ز', '.'],
Slash: ['ظ', '؟'],
},
mac: {
Backquote: ['§', '±'],
Minus: ['-', '_'],
Equal: ['=', '+'],
KeyQ: ['ض', 'َ'],
KeyW: ['ص', 'ً'],
KeyE: ['ث', 'ِ'],
KeyR: ['ق', 'ٍ'],
KeyT: ['ف', 'ُ'],
KeyY: ['غ', 'ٌ'],
KeyU: ['ع', 'ْ'],
KeyI: ['ه', 'ّ'],
KeyO: ['خ', ']'],
KeyP: ['ح', '['],
BracketLeft: ['ج', '}'],
BracketRight: ['ة', '{'],
KeyA: ['ش', '»'],
KeyS: ['س', '«'],
KeyD: ['ي', 'ى'],
KeyF: ['ب', ''],
KeyG: ['ل', ''],
KeyH: ['ا', 'آ'],
KeyJ: ['ت', ''],
KeyK: ['ن', ''],
KeyL: ['م', ''],
Semicolon: ['ك', ':'],
Quote: ['؛', '"'],
KeyZ: ['ظ', ''],
KeyX: ['ط', ''],
KeyC: ['ذ', 'ئ'],
KeyV: ['د', 'ء'],
KeyB: ['ز', 'أ'],
KeyN: ['ر', 'إ'],
KeyM: ['و', 'ؤ'],
Comma: ['،', '>'],
Period: ['.', '<'],
Slash: ['/', '؟'],
},
}
Loading

0 comments on commit 8dfe50c

Please sign in to comment.