1/** 2* Copyright 2012 QODIO 3* Author: Ingi Petursson Jacobsen 4* No usage of this code is allowed 5* 6*/ 7 8// JavaScript Document 9function VirtualKeyboard(targetElement, targetInput) { 10 this.targetElement = $(targetElement)[0]; 11 this.targetInput = $(targetInput)[0]; 12 this.isIE = /*@cc_on!@*/false; 13 // this.isIE6 = /*@if(@_jscript_version == 5.6)!@end@*/false; 14 // this.isIElt8 = /*@if(@_jscript_version < 5.8)!@end@*/false; 15 // this.isWebKit = new RegExp("KHTML").test(navigator.userAgent); 16 this.isOpera = new RegExp("Opera").test(navigator.userAgent); 17 // this.isMoz = (!this.isWebKit && navigator.product === "Gecko"); 18 this.CtrlAltIsPressed = false; 19 this.ShiftIsPressed = false; 20 this.CapsLockIsPressed = false; 21 this.PressedDeadkey = null; 22 this.Language = 'fo'; 23 this.ChosenLayout = null; 24 this.oncharacterpress = function () { 25 //this.targetInput.onkeyup(); 26 //console.log(this); 27 //alert('key'); 28 }; 29 this.onreturnpress = function () { 30 //this.targetInput.onkeyup(); 31 //console.log(this); 32 //alert('return'); 33 }; 34 35 this.Layouts = {}; 36 this.Layouts['fo'] = { 37 name: "Faroese", 38 originalName: "F\u00f8royskt", 39 keys: [ 40 [["½", "§"], ["1", "!"], ["2", '"', "@"], ["3", "#", "£"], ["4", "¤", "$"], ["5", "%", "â¬"], ["6", "&"], ["7", "/", "{"], ["8", "(", "["], ["9", ")", "]"], ["0", "=", "}"], ["+", "?"], ["´", "`", "|"], ["Bksp", "Bksp"]], 41 [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E", "â¬"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["Ã¥", "à ", "¨"], ["ð", "ð", "~"], ["'", "*"]], 42 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["æ", "Ã"], ["ø", "Ã", "^"], ["Enter", "Enter"]], 43 [["Shift", "Shift"], ["<", ">", "\\"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M", "µ"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 44 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 45 ], 46 lang: ["fo"], 47 deadkeys: [ 48 ["´", [ ["a", "á"], ["e", "é"], ["i", "Ã"], ["o", "ó"], ["u", "ú"], ["y", "ý"], 49 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"], ["Y", "Ã"] ]], 50 ["`", [ ["a", "à "], ["e", "è"], ["i", "ì"], ["o", "ò"], ["u", "ù"], 51 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"] ]], 52 ["¨", [ ["a", "ä"], ["e", "ë"], ["i", "ï"], ["o", "ö"], ["u", "ü"], ["y", "ÿ"], 53 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"] ]], 54 ["^", [ ["a", "â"], ["e", "ê"], ["i", "î"], ["o", "ô"], ["u", "û"], ["w", "ŵ"], ["y", "Å·"], 55 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"], ["W", "Å´"], ["Y", "Ŷ"] ]], 56 ["~", [ ["a", "ã"], ["n", "ñ"], ["o", "õ"], 57 ["A", "Ã"], ["N", "Ã"], ["O", "Ã"] ]] 58 ] }; 59 60 this.Layouts['da'] = { 61 englishName: "Danish", 62 name: "Dansk", 63 keys: [ 64 [["½", "§"], ["1", "!"], ["2", '"', "@"], ["3", "#", "£"], ["4", "¤", "$"], ["5", "%", "â¬"], ["6", "&"], ["7", "/", "{"], ["8", "(", "["], ["9", ")", "]"], ["0", "=", "}"], ["+", "?"], ["´", "`", "|"], ["Bksp", "Bksp"]], 65 [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E", "â¬"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["Ã¥", "à "], ["¨", "^", "~"], ["'", "*"]], 66 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["æ", "Ã"], ["ø", "Ã"], ["Enter", "Enter"]], 67 [["Shift", "Shift"], ["<", ">", "\\"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M", "µ"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 68 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 69 ], 70 lang: ["da"], 71 deadkeys: [ 72 ["´", [ ["a", "á"], ["e", "é"], ["i", "Ã"], ["o", "ó"], ["u", "ú"], ["y", "ý"], 73 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"], ["Y", "Ã"] ]], 74 ["`", [ ["a", "à "], ["e", "è"], ["i", "ì"], ["o", "ò"], ["u", "ù"], 75 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"] ]], 76 ["¨", [ ["a", "ä"], ["e", "ë"], ["i", "ï"], ["o", "ö"], ["u", "ü"], ["y", "ÿ"],
77 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"] ]], 78 ["^", [ ["a", "â"], ["e", "ê"], ["i", "î"], ["o", "ô"], ["u", "û"], ["w", "ŵ"], ["y", "Å·"], 79 ["A", "Ã"], ["E", "Ã"], ["I", "Ã"], ["O", "Ã"], ["U", "Ã"], ["W", "Å´"], ["Y", "Ŷ"] ]], 80 ["~", [ ["a", "ã"], ["n", "ñ"], ["o", "õ"], 81 ["A", "Ã"], ["N", "Ã"], ["O", "Ã"] ]] 82 ] }; 83 84 this.Layouts['de'] = { 85 englishName: "German", 86 name: "Deutsch", 87 keys: [ 88 [["^", "\u00b0"], ["1", "!"], ["2", '"', "\u00b2"], ["3", "\u00a7", "\u00b3"], ["4", "$"], ["5", "%"], ["6", "&"], ["7", "/", "{"], ["8", "(", "["], ["9", ")", "]"], ["0", "=", "}"], ["\u00df", "?", "\\"], ["\u00b4", "`"], ["Bksp", "Bksp"]], 89 [["Tab", "Tab"], ["q", "Q", "@"], ["w", "W"], ["e", "E", "\u20ac"], ["r", "R"], ["t", "T"], ["z", "Z"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["\u00fc", "\u00dc"], ["+", "*", "~"], ["#", "'"]], 90 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["\u00f6", "\u00d6"], ["\u00e4", "\u00c4"], ["Enter", "Enter"]], 91 [["Shift", "Shift"], ["<", ">", "\u00a6"], ["y", "Y"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M", "\u00b5"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 92 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 93 ], 94 lang: ["de"], 95 deadkeys: [] }; 96 97 this.Layouts['ru'] = { 98 englishName: "Italiano", 99 name: "\u0420\u0443\u0441\u0441\u043a\u0438\u0439", 100 keys: [ 101 [["\u0451", "\u0401"], ["1", "!"], ["2", '"'], ["3", "\u2116"], ["4", ";"], ["5", "%"], ["6", ":"], ["7", "?"], ["8", "*"], ["9", "("], ["0", ")"], ["-", "_"], ["=", "+"], ["Bksp", "Bksp"]], 102 [["Tab", "Tab"], ["\u0439", "\u0419"], ["\u0446", "\u0426"], ["\u0443", "\u0423"], ["\u043A", "\u041A"], ["\u0435", "\u0415"], ["\u043D", "\u041D"], ["\u0433", "\u0413"], ["\u0448", "\u0428"], ["\u0449", "\u0429"], ["\u0437", "\u0417"], ["\u0445", "\u0425"], ["\u044A", "\u042A"], ["\\", "/"]], 103 [["Caps", "Caps", "Caps", "Caps"], ["\u0444", "\u0424"], ["\u044B", "\u042B"], ["\u0432", "\u0412"], ["\u0430", "\u0410"], ["\u043F", "\u041F"], ["\u0440", "\u0420"], ["\u043E", "\u041E"], ["\u043B", "\u041B"], ["\u0434", "\u0414"], ["\u0436", "\u0416"], ["\u044D", "\u042D"], ["Enter", "Enter"]], 104 [["Shift", "Shift"], ["/", "|"], ["\u044F", "\u042F"], ["\u0447", "\u0427"], ["\u0441", "\u0421"], ["\u043C", "\u041C"], ["\u0438", "\u0418"], ["\u0442", "\u0422"], ["\u044C", "\u042C"], ["\u0431", "\u0411"], ["\u044E", "\u042E"], [".", ","], ["Shift", "Shift"]], 105 [["disabled"], [" ", " ", " ", " "], ["disabled"]] 106 ], 107 lang: ["ru"], 108 deadkeys: [] }; 109 110 this.Layouts['en'] = { 111 englishName: "English", 112 name: "English", 113 keys: [ 114 [["`", "~"], ["1", "!"], ["2", '@'], ["3", "#"], ["4", "$"], ["5", "%"], ["6", "^"], ["7", "&"], ["8", "*"], ["9", "("], ["0", ")"], ["-", "_"], ["=", "+"], ["Bksp", "Bksp"]], 115 [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E", "â¬"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["[", "{"], ["]", "}"], ["\\", "|"]], 116 [["Caps", "Caps", "Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], [";", ":"], ["'", "\""], ["Enter", "Enter"]], 117 [["Shift", "Shift"], ["\\", "|"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M"], [",", "<"], [".", ">"], ["/", "?"], ["Shift", "Shift"]], 118 [["disabled"], [" ", " ", " ", " "], ["disabled"]] 119 ], 120 lang: ["en"], 121 deadkeys: [] }; 122 123 this.Layouts['es'] = { 124 englishName: "Spanish", 125 name: "Espa\u00f1ol", 126 keys: [ 127 [["\u00ba", "\u00aa", "\\"], ["1", "!", "|"], ["2", '"', "@"], ["3", "'", "#"], ["4", "$", "~"], ["5", "%", "\u20ac"], ["6", "&", "\u00ac"], ["7", "/"], ["8", "("], ["9", ")"], ["0", "="], ["'", "?"], ["\u00a1", "\u00bf"], ["Bksp", "Bksp"]], 128 [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["`", "^", "["], ["+", "*", "]"], ["\u00e7", "\u00c7", "}"]], 129 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["\u00f1", "\u00d1"], ["\u00b4", "\u00a8", "{"], ["Enter", "Enter"]], 130 [["Shift", "Shift"], ["<", ">"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 131 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 132 ], 133 lang: ["es"], 134 deadkeys: [] }; 135 136 this.Layouts['fr'] = { 137 englishName: "French", 138 name: "Fran\u00e7ais", 139 keys: [ 140 [["\u00b2", "\u00b3"], ["&", "1"], ["\u00e9", "2", "~"], ['"', "3", "#"], ["'", "4", "{"], ["(", "5", "["], ["-", "6", "|"], ["\u00e8", "7", "`"], ["_", "8", "\\"], ["\u00e7", "9", "^"], ["\u00e0", "0", "@"], [")", "\u00b0", "]"], ["=", "+", "}"], ["Bksp", "Bksp"]], 141 [["Tab", "Tab"], ["a", "A"], ["z", "Z"], ["e", "E", "\u20ac"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["^", "\u00a8"], ["$", "\u00a3", "\u00a4"], ["*", "\u03bc"]], 142 [["Caps", "Caps", "Caps", "Caps"], ["q", "Q"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["m", "M"], ["\u00f9", "%"], ["
142Enter", "Enter"]], 143 [["Shift", "Shift"], ["<", ">"], ["w", "W"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], [",", "?"], [";", "."], [":", "/"], ["!", "\u00a7"], ["Shift", "Shift"]], 144 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 145 ], 146 lang: ["fr"], 147 deadkeys: [] }; 148 149 this.Layouts['it'] = { 150 englishName: "Italian", 151 name: "Italiano", 152 keys: [ 153 [["\\", "|"], ["1", "!"], ["2", '"'], ["3", "\u00a3"], ["4", "$", "\u20ac"], ["5", "%"], ["6", "&"], ["7", "/"], ["8", "("], ["9", ")"], ["0", "="], ["'", "?"], ["\u00ec", "^"], ["Bksp", "Bksp"]], 154 [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E", "\u20ac"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["\u00e8", "\u00e9", "[", "{"], ["+", "*", "]", "}"], ["\u00f9", "\u00a7"]], 155 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["\u00f2", "\u00e7", "@"], ["\u00e0", "\u00b0", "#"], ["Enter", "Enter"]], 156 [["Shift", "Shift"], ["<", ">"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 157 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 158 ], 159 lang: ["it"], 160 deadkeys: [] }; 161 162 this.Layouts['jp'] = { 163 englishName: "Japanese", 164 name: "æ¥æ¬", 165 keys: [ 166 [["\\", "|"], ["1", "!"], ["2", '"'], ["3", "\u00a3"], ["4", "$", "\u20ac"], ["5", "%"], ["6", "&"], ["7", "/"], ["8", "("], ["9", ")"], ["0", "="], ["'", "?"], ["\u00ec", "^"], ["Bksp", "Bksp"]], 167 [["Tab", "Tab"], ["q", "Q"], ["æ¬", "W"], ["e", "E", "\u20ac"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["\u00e8", "\u00e9", "[", "{"], ["+", "*", "]", "}"], ["\u00f9", "\u00a7"]], 168 [["Caps", "Caps", "Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], ["\u00f2", "\u00e7", "@"], ["\u00e0", "\u00b0", "#"], ["Enter", "Enter"]], 169 [["TEST", "Shift"], ["<", ">"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M"], [",", ";"], [".", ":"], ["-", "_"], ["Shift", "Shift"]], 170 [["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"], [" ", " ", " ", " "], ["Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt", "Ctrl + Alt"]] 171 ], 172 lang: ["jp"], 173 deadkeys: [] }; 174 175 176 177 178 function findDeadKeyIndex(sCharacter, aDeadkeys) { 179 var iDeadkeyArrayIndex = null; 180 for (var i = 0; i < aDeadkeys.length; i++) { 181 if (sCharacter === aDeadkeys[i][0]) { 182 iDeadkeyArrayIndex = i; 183 break; 184 } 185 } 186 return iDeadkeyArrayIndex; 187 } 188 189 function findDeadKeyAlternative(sCharacter, aDeadkeyCharacters, sDefaultCharacter) { 190 sDefaultCharacter = sDefaultCharacter === undefined ? '' : sDefaultCharacter; 191 for (var k = 0; k < aDeadkeyCharacters.length; k++) { 192 if (aDeadkeyCharacters[k][0] === sCharacter) { 193 return aDeadkeyCharacters[k][1]; 194 } 195 } 196 return sDefaultCharacter; 197 } 198 199 function insertCharacter(sCharacter, oKeyboard, SkipDeadKeyCheck) { 200 SkipDeadKeyCheck = SkipDeadKeyCheck !== undefined ? SkipDeadKeyCheck : false; 201 if (sCharacter !== undefined && sCharacter !== '') { 202 var iDeadkeyArrayIndex = findDeadKeyIndex(sCharacter, oKeyboard.ChosenLayout.deadkeys); 203 if (!SkipDeadKeyCheck && oKeyboard.ChosenLayout.deadkeys[iDeadkeyArrayIndex] !== undefined && oKeyboard.ChosenLayout.deadkeys[iDeadkeyArrayIndex][0] === sCharacter) { 204 oKeyboard.PressedDeadkey = oKeyboard.PressedDeadkey !== sCharacter ? sCharacter : null; 205 oKeyboard.refreshLayout(); 206 } else { 207 $(oKeyboard.targetInput).insertAtCaret(sCharacter); 208 oKeyboard.oncharacterpress(); 209 if (oKeyboard.PressedDeadkey !== null || oKeyboard.ShiftIsPressed || oKeyboard.CtrlAltIsPresse) { 210 oKeyboard.PressedDeadkey = null; 211 oKeyboard.ShiftIsPressed = false; 212 oKeyboard.CtrlAltIsPresse = false; 213 oKeyboard.refreshLayout(); 214 } 215 } 216 } 217 } 218 219 this.backspace = function() { 220 this.targetInput.focus(); 221 if (this.targetInput.setSelectionRange && !this.targetInput.readOnly) { 222 var rng = [this.targetInput.selectionStart, this.targetInput.selectionEnd]; 223 if (rng[0] < rng[1]) rng[0]++; 224 this.targetInput.value = this.targetInput.value.substr(0, rng[0] - 1) + this.targetInput.value.substr(rng[1]); 225 this.targetInput.setSelectionRange(rng[0] - 1, rng[0] - 1); 226 } else if (this.targetInput.createTextRange && !this.targetInput.readOnly) { 227 try { 228 this.targetInput.range.select(); 229 } catch(e) { 230 this.targetInput.range = document.selection.createRange(); 231 } 232 if (!this.targetInput.range.text.length) { 233 this.targetInput.range.moveStart('character', -1); 234 } 235 this.targetInput.range.text = ""; 236 } else { 237 this.targetInput.value = this.targetInput.value.substr(0, this.targetInput.value.length - 1); 238 } 239 this.targetInput.focus(); 240 return true; 241 242 }; 243 244 this.resetKeyboard = function() { 245 this.PressedDeadkey = null; 246 }; 247 248 this.changeLanguage = function(sLanguage) { 249 this.resetKeyboard(); 250 this.Language = sLanguage; 251 this.refreshLayout(); 252 }; 253 254 this.refreshLayout = function() { 255 this.ChosenLayout = this.Layouts[this.Language]; 256 var iDeadkeyArrayIndex = findDeadKeyIndex(this.PressedDeadkey, this.ChosenLayout.deadkeys); 257 var aDeadkey = iDeadkeyArrayIndex !== null ? this.ChosenLayout.deadkeys[iDeadkeyArrayIndex][1] : null; 258 259 $(this.targetElement).empty(); 260 for (var i=0; i < this.ChosenLayout.keys.length; i++) { 261 var oRow = document.createElement('div'); 262 for (var j=0; j < this.ChosenLayout.keys[i].length; j++) { 263 var oKey = this.ChosenLayout.keys[i][j];
264 var oButton = document.createElement('button'); 265 oButton.Keyboard = this; 266 if (!this.ShiftIsPressed && !this.CapsLockIsPressed && !this.CtrlAltIsPressed) { 267 oButton.Character = oKey[0]; 268 } else if ((this.ShiftIsPressed || this.CapsLockIsPressed) && !this.CtrlAltIsPressed) { 269 oButton.Character = oKey[1]; 270 } else if (!this.ShiftIsPressed && !this.CapsLockIsPressed && this.CtrlAltIsPressed) { 271 oButton.Character = oKey[2]; 272 } else if ((this.ShiftIsPressed || this.CapsLockIsPressed) && this.CtrlAltIsPressed) { 273 oButton.Character = oKey[3]; 274 } 275 if (this.PressedDeadkey !== null) { 276 if (oButton.Character !== this.PressedDeadkey && oButton.Character !== "Ctrl + Alt" && oButton.Character !== "Caps") { 277 findDeadKeyAlternative(oButton.Character, aDeadkey); 278 if (this.CtrlAltIsPressed) { 279 oButton.Character = (this.ShiftIsPressed||this.CapsLockIsPressed) ? oKey[1] : oKey[0]; 280 } 281 oButton.Character = findDeadKeyAlternative(oButton.Character, aDeadkey, ''); 282 } 283 } 284 285 switch (i + ',' + j) { 286 case '0,13': //Backspace 287 $(oButton).css('width', '58px'); 288 $(oButton).html('<i class="fas fa-long-arrow-alt-left"></i>'); 289 $(oButton).click(function() { 290 this.Keyboard.backspace(); 291 this.Keyboard.oncharacterpress(); 292 }); 293 break; 294 case '1,0': //Tab 295 $(oButton).css('width', '57px'); 296 $(oButton).html('<i class="fas fa-long-arrow-alt-right"></i>'); 297 $(oButton).click(function() { 298 $(this.Keyboard.targetInput).insertAtCaret('\t'); 299 }); 300 break; 301 /*case '1,13': //Ping 302 $(oButton).css('width', '43px'); 303 $(oButton).html(oButton.Character); 304 $(oButton).click(function() { 305 insertCharacter(this.Character, this.Keyboard); 306 }); 307 break;*/ 308 case '2,0': //Caps lock 309 $(oButton).css('width', '64px'); 310 $(oButton).html(oButton.Character); 311 //$(oButton).html('<div class="sprite_keyboard-capslock"></div>'); 312 if (this.CapsLockIsPressed) { 313 $(oButton).addClass('toggled') 314 } 315 $(oButton).click(function() { 316 this.Keyboard.CapsLockIsPressed = !this.Keyboard.CapsLockIsPressed; 317 this.Keyboard.refreshLayout(); 318 }); 319 break; 320 case '2,12': //Enter 321 $(oButton).css('width', '69px'); 322 $(oButton).html('<i class="fas fa-level-down-alt fa-rotate-90"></i>'); 323 //$(oButton).html(oButton.Character); 324 $(oButton).click(function() { 325 this.Keyboard.onreturnpress(); 326 }); 327 break; 328 case '3,0': //Left Shift 329 $(oButton).css('width', '67px'); 330 $(oButton).html('<i class="fas fa-arrow-up"></i>'); 331 if (this.ShiftIsPressed) { 332 $(oButton).addClass('toggled') 333 } 334 $(oButton).click(function() { 335 this.Keyboard.ShiftIsPressed = !this.Keyboard.ShiftIsPressed; 336 this.Keyboard.refreshLayout(); 337 }); 338 break; 339 case '3,12': //Right Shift 340 $(oButton).css('width', '66px'); 341 $(oButton).html('<i class="fas fa-arrow-up"></i>'); 342 if (this.ShiftIsPressed) { 343 $(oButton).addClass('toggled') 344 } 345 $(oButton).click(function() { 346 this.Keyboard.ShiftIsPressed = !this.Keyboard.ShiftIsPressed; 347 this.Keyboard.refreshLayout(); 348 }); 349 break; 350 case '4,0': //Left Ctrl+Alt 351 $(oButton).css('width', '85px'); 352 if (oKey[0] !== 'disabled') { 353 $(oButton).html(oButton.Character); 354 if (this.CtrlAltIsPressed) { 355 $(oButton).addClass('toggled') 356 } 357 $(oButton).click(function() { 358 this.Keyboard.CtrlAltIsPressed = !this.Keyboard.CtrlAltIsPressed; 359 this.Keyboard.refreshLayout(); 360 }); 361 } else { 362 oButton.Character = ''; 363 $(oButton).addClass('disabled') 364 } 365 break; 366 case '4,1': //Space 367 $(oButton).css('width', '398px'); 368 $(oButton).html(oButton.Character); 369 $(oButton).click(function() { 370 this.Character = this.Keyboard.PressedDeadkey !== null ? this.Keyboard.PressedDeadkey : this.Character; 371 insertCharacter(this.Character, this.Keyboard, true); 372 });
373 break; 374 case '4,2': //Right Ctrl+Alt 375 $(oButton).css('width', '86px'); 376 if (oButton.Character !== 'disabled') { 377 $(oButton).html(oButton.Character); 378 if (this.CtrlAltIsPressed) { 379 $(oButton).addClass('toggled') 380 } 381 $(oButton).click(function() { 382 this.Keyboard.CtrlAltIsPressed = !this.Keyboard.CtrlAltIsPressed; 383 this.Keyboard.refreshLayout(); 384 }); 385 } else { 386 oButton.Character = ''; 387 $(oButton).addClass('disabled') 388 } 389 break; 390 default: 391 // TODO: check deadkey array for deadkey alternatives 392 $(oButton).html(oButton.Character); 393 if (this.PressedDeadkey !== null) { 394 if (oButton.Character === this.PressedDeadkey) { 395 $(oButton).addClass('toggled') 396 } 397 } 398 $(oButton).click(function() { 399 insertCharacter(this.Character, this.Keyboard); 400 }); 401 break; 402 } 403 $(oRow).append(oButton); 404 } 405 $(targetElement).append(oRow); 406 } 407 } 408} 409 410/*! 411 * jQuery insertAtCaret 412 * Allows inserting text where the caret is in a textarea 413 * Copyright (c) 2003-2010 phpMyAdmin devel team 414 * Version: 1.0 415 * Developed by the phpMyAdmin devel team. Modified by Alex King and variaas 416 * http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript 417 * http://www.mail-archive.com/[email protected]/msg08708.html 418 * Licensed under the GPL license: 419 * http://www.gnu.org/licenses/gpl.html 420 */ 421(function($) { 422 423 $.fn.insertAtCaret = function (myValue) { 424 425 return this.each(function() { 426 427 // IE support 428 if (document.selection) { 429 430 this.focus(); 431 var sel = document.selection.createRange(); 432 sel.text = myValue; 433 this.focus(); 434 435 // MOZILLA/NETSCAPE support 436 } else if (this.selectionStart || this.selectionStart === '0') { 437 438 var startPos = this.selectionStart; 439 var endPos = this.selectionEnd; 440 var scrollTop = this.scrollTop; 441 this.value = this.value.substring(0, startPos)+ myValue+ this.value.substring(endPos,this.value.length); 442 this.focus(); 443 this.selectionStart = startPos + myValue.length; 444 this.selectionEnd = startPos + myValue.length; 445 this.scrollTop = scrollTop; 446 447 // If not supported properly, add to end of target input field 448 } else { 449 this.value += myValue; 450 this.focus(); 451 } 452 }); 453 }; 454 455})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.