Pārlūkot izejas kodu

Makes the keyboard shortcut class more readable.

master
fo 11 gadus atpakaļ
vecāks
revīzija
60ef0f033b
1 mainītis faili ar 5 papildinājumiem un 3 dzēšanām
  1. 5
    3
      keyboard_shortcut.js

+ 5
- 3
keyboard_shortcut.js Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt