1/** 2 * http://www.openjs.com/scripts/events/keyboard_shortcuts/ 3 * Version : 2.01.B 4 * By Binny V A 5 * License : BSD 6 */ 7shortcut = { 8 'all_shortcuts': {}, //All the shortcuts are stored in this array 9 'add': function (shortcut_combination, callback, opt) { 10 //Provide a set of default options 11 var default_options = { 12 'type': 'keydown', 13 'propagate': false, 14 'disable_in_input': false, 15 'target': document, 16 'keycode': false 17 } 18 if (!opt) 19 opt = default_options; 20 else { 21 for (var dfo in default_options) { 22 if (typeof opt[dfo] == 'undefined') 23 opt[dfo] = default_options[dfo]; 24 } 25 } 26 27 var ele = opt.target; 28 if (typeof opt.target == 'string') 29 ele = document.getElementById(opt.target); 30 var ths = this; 31 shortcut_combination = shortcut_combination.toLowerCase(); 32 33 //The function to be called at keypress 34 var func = function (e) { 35 e = e || window.event; 36 37 if (opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields 38 var element; 39 if (e.target) 40 element = e.target; 41 else if (e.srcElement) 42 element = e.srcElement; 43 if (element.nodeType == 3) 44 element = element.parentNode; 45 46 if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') 47 return; 48 } 49 50 //Find Which key is pressed 51 if (e.keyCode) 52 code = e.keyCode; 53 else if (e.which) 54 code = e.which; 55 var character = String.fromCharCode(code).toLowerCase(); 56 57 if (code == 188) 58 character = ","; //If the user presses , when the type is onkeydown 59 if (code == 190) 60 character = "."; //If the user presses , when the type is onkeydown 61 62 var keys = shortcut_combination.split("+"); 63 //Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked 64 var kp = 0; 65 66 //Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken 67 var shift_nums = { 68 "`": "~", 69 "1": "!", 70 "2": "@", 71 "3": "#", 72 "4": "$", 73 "5": "%", 74 "6": "^", 75 "7": "&", 76 "8": "*", 77 "9": "(", 78 "0": ")", 79 "-": "_", 80 "=": "+", 81 ";": ":", 82 "'": "\"", 83 ",": "<", 84 ".": ">", 85 "/": "?", 86 "\\": "|" 87 } 88 //Special Keys - and their codes 89 var special_keys = { 90 'esc': 27, 91 'escape': 27, 92 'tab': 9, 93 'space': 32, 94 'return': 13, 95 'enter': 13, 96 'backspace': 8, 97 'scrolllock': 145, 98 'scroll_lock': 145, 99 'scroll': 145, 100 'capslock': 20, 101 'caps_lock': 20, 102 'caps': 20, 103 'numlock': 144, 104 'num_lock': 144, 105 'num': 144, 106 'pause': 19, 107 'break': 19, 108 'insert': 45, 109 'home': 36, 110 'delete': 46, 111 'end': 35, 112 'pageup': 33, 113 'page_up': 33, 114 'pu': 33, 115 'pagedown': 34, 116 'page_down': 34, 117 'pd': 34, 118 'left': 37, 119 'up': 38, 120 'right': 39, 121 'down': 40, 122 'f1': 112, 123 'f2': 113, 124 'f3': 114, 125 'f4': 115, 126 'f5': 116, 127 'f6': 117, 128 'f7': 118, 129 'f8': 119, 130 'f9': 120, 131 'f10': 121, 132 'f11': 122, 133 'f12': 123 134 } 135 136 var modifiers = {
137 shift: {wanted: false, pressed: false}, 138 ctrl: {wanted: false, pressed: false}, 139 alt: {wanted: false, pressed: false}, 140 meta: {wanted: false, pressed: false} //Meta is Mac specific 141 }; 142 143 if (e.ctrlKey) 144 modifiers.ctrl.pressed = true; 145 if (e.shiftKey) 146 modifiers.shift.pressed = true; 147 if (e.altKey) 148 modifiers.alt.pressed = true; 149 if (e.metaKey) 150 modifiers.meta.pressed = true; 151 152 for (var i = 0; k = keys[i], i < keys.length; i++) { 153 //Modifiers 154 if (k == 'ctrl' || k == 'control') { 155 kp++; 156 modifiers.ctrl.wanted = true; 157 158 } else if (k == 'shift') { 159 kp++; 160 modifiers.shift.wanted = true; 161 162 } else if (k == 'alt') { 163 kp++; 164 modifiers.alt.wanted = true; 165 } else if (k == 'meta') { 166 kp++; 167 modifiers.meta.wanted = true; 168 } else if (k.length > 1) { //If it is a special key 169 if (special_keys[k] == code) 170 kp++; 171 172 } else if (opt['keycode']) { 173 if (opt['keycode'] == code) 174 kp++; 175 176 } else { //The special keys did not match 177 if (character == k) 178 kp++; 179 else { 180 if (shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase 181 character = shift_nums[character]; 182 if (character == k) 183 kp++; 184 } 185 } 186 } 187 } 188 189 if (kp == keys.length && 190 modifiers.ctrl.pressed == modifiers.ctrl.wanted && 191 modifiers.shift.pressed == modifiers.shift.wanted && 192 modifiers.alt.pressed == modifiers.alt.wanted && 193 modifiers.meta.pressed == modifiers.meta.wanted) { 194 callback(e); 195 196 if (!opt['propagate']) { //Stop the event 197 //e.cancelBubble is supported by IE - this will kill the bubbling process. 198 e.cancelBubble = true; 199 e.returnValue = false; 200 201 //e.stopPropagation works in Firefox. 202 if (e.stopPropagation) { 203 e.stopPropagation(); 204 e.preventDefault(); 205 } 206 return false; 207 } 208 } 209 } 210 this.all_shortcuts[shortcut_combination] = { 211 'callback': func, 212 'target': ele, 213 'event': opt['type'] 214 }; 215 //Attach the function with the event 216 if (ele.addEventListener) 217 ele.addEventListener(opt['type'], func, false); 218 else if (ele.attachEvent) 219 ele.attachEvent('on' + opt['type'], func); 220 else 221 ele['on' + opt['type']] = func; 222 }, 223 //Remove the shortcut - just specify the shortcut and I will remove the binding 224 'remove': function (shortcut_combination) { 225 shortcut_combination = shortcut_combination.toLowerCase(); 226 var binding = this.all_shortcuts[shortcut_combination]; 227 delete(this.all_shortcuts[shortcut_combination]) 228 if (!binding) 229 return; 230 var type = binding['event']; 231 var ele = binding['target']; 232 var callback = binding['callback']; 233 234 if (ele.detachEvent) 235 ele.detachEvent('on' + type, callback); 236 else if (ele.removeEventListener) 237 ele.removeEventListener(type, callback, false); 238 else 239 ele['on' + type] = false; 240 } 241} 242 243 var elementBody = document.querySelector('body'); 244 var elementBtnIncreaseFont = document.getElementById('increase-font'); 245 var elementBtnDecreaseFont = document.getElementById('decrease-font'); 246 // Padrão de tamanho, equivale a 100% do valor definido no Body 247 var fontSize = 100; 248 // Valor de incremento ou decremento, equivale a 10% do valor do Body 249 var increaseDecrease = 10; 250 251 252 shortcut.add("Alt+H", function() { 253 window.location.assign("index.php"); 254 }); 255 256 shortcut.add("Alt+Shift+1", function() { 257 window.location.assign("acessibilidade.php"); 258 }); 259 260 shortcut.add("Alt+9", function() { 261 window.scrollTo(0, 0); 262 }); 263 264 shortcut.add("Alt+C", function() { 265 window.location.href = '#ancora'; 266 }); 267 shortcut.add("Alt+A", function(){ 268 fontSize = fontSize + increaseDecrease; 269 elementBody.style.fontSize = fontSize + '%'; 270 }); 271 272 shortcut.add("Alt+Shift+D", function(){ 273 fontSize = fontSize - increaseDecrease; 274 elementBody.style.fontSize = fontSize + '%' 275 }); 276 277 shortcut.add("Alt+N", function(){ 278 fontSize = 100; 279 elementBody.style.fontSize = fontSize + '%' 280 });
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.