Ver código fonte

Makes the keyboard shortcut class more readable.

j8
fo 10 anos atrás
pai
commit
60ef0f033b
1 arquivos alterados com 5 adições e 3 exclusões
  1. 5
    3
      keyboard_shortcut.js

+ 5
- 3
keyboard_shortcut.js Ver arquivo

@@ -1,4 +1,5 @@
1 1
 var KeyboardShortcut = (function(my) {
2
+    //maps keycode to character, id of popover for given function and function
2 3
     var shortcuts = {
3 4
         67: {
4 5
             character: "C",
@@ -35,9 +36,9 @@ var KeyboardShortcut = (function(my) {
35 36
             var keycode = e.which;
36 37
             if (typeof shortcuts[keycode] === "object") {
37 38
                 shortcuts[keycode].function();
38
-            } else if (keycode >= 49 && keycode <= 57) {
39
+            } else if (keycode >= "1".charCodeAt(0) && keycode <= "9".charCodeAt(0)) {
39 40
                 var remoteVideos = $(".videocontainer:not(#mixedstream)"),
40
-                    videoWanted = keycode - 48;
41
+                    videoWanted = keycode - "0".charCodeAt(0);
41 42
                 if (remoteVideos.length > videoWanted) {
42 43
                     remoteVideos[videoWanted].click();
43 44
                 }
@@ -47,13 +48,14 @@ var KeyboardShortcut = (function(my) {
47 48
 
48 49
     window.onkeydown = function(e) {
49 50
         if($("#chatspace").css("display") === "none") {
50
-            if(e.which === 84) {
51
+            if(e.which === "T".charCodeAt(0)) {
51 52
                 if(isAudioMuted()) {
52 53
                     toggleAudio();
53 54
                 }
54 55
             }
55 56
         }
56 57
     };
58
+    
57 59
     /**
58 60
      *  
59 61
      * @param id indicates the popover associated with the shortcut

Carregando…
Cancelar
Salvar