Makes the keyboard shortcut class more readable.

This commit is contained in:
fo 2014-09-10 11:32:26 +03:00
parent 682ecf5874
commit 60ef0f033b
1 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
var KeyboardShortcut = (function(my) { var KeyboardShortcut = (function(my) {
//maps keycode to character, id of popover for given function and function
var shortcuts = { var shortcuts = {
67: { 67: {
character: "C", character: "C",
@ -35,9 +36,9 @@ var KeyboardShortcut = (function(my) {
var keycode = e.which; var keycode = e.which;
if (typeof shortcuts[keycode] === "object") { if (typeof shortcuts[keycode] === "object") {
shortcuts[keycode].function(); shortcuts[keycode].function();
} else if (keycode >= 49 && keycode <= 57) { } else if (keycode >= "1".charCodeAt(0) && keycode <= "9".charCodeAt(0)) {
var remoteVideos = $(".videocontainer:not(#mixedstream)"), var remoteVideos = $(".videocontainer:not(#mixedstream)"),
videoWanted = keycode - 48; videoWanted = keycode - "0".charCodeAt(0);
if (remoteVideos.length > videoWanted) { if (remoteVideos.length > videoWanted) {
remoteVideos[videoWanted].click(); remoteVideos[videoWanted].click();
} }
@ -47,13 +48,14 @@ var KeyboardShortcut = (function(my) {
window.onkeydown = function(e) { window.onkeydown = function(e) {
if($("#chatspace").css("display") === "none") { if($("#chatspace").css("display") === "none") {
if(e.which === 84) { if(e.which === "T".charCodeAt(0)) {
if(isAudioMuted()) { if(isAudioMuted()) {
toggleAudio(); toggleAudio();
} }
} }
} }
}; };
/** /**
* *
* @param id indicates the popover associated with the shortcut * @param id indicates the popover associated with the shortcut