2014-09-08 17:01:10 +00:00
|
|
|
var KeyboardShortcut = (function(my) {
|
2014-09-10 08:32:26 +00:00
|
|
|
//maps keycode to character, id of popover for given function and function
|
2014-09-08 17:01:10 +00:00
|
|
|
var shortcuts = {
|
|
|
|
67: {
|
|
|
|
character: "C",
|
|
|
|
id: "toggleChatPopover",
|
|
|
|
function: BottomToolbar.toggleChat
|
|
|
|
},
|
|
|
|
70: {
|
|
|
|
character: "F",
|
|
|
|
id: "filmstripPopover",
|
|
|
|
function: BottomToolbar.toggleFilmStrip
|
|
|
|
},
|
|
|
|
77: {
|
|
|
|
character: "M",
|
|
|
|
id: "mutePopover",
|
|
|
|
function: toggleAudio
|
|
|
|
},
|
|
|
|
84: {
|
|
|
|
character: "T",
|
|
|
|
function: function() {
|
|
|
|
if(!isAudioMuted()) {
|
|
|
|
toggleAudio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
86: {
|
|
|
|
character: "V",
|
|
|
|
id: "toggleVideoPopover",
|
|
|
|
function: toggleVideo
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onkeyup = function(e) {
|
2014-09-12 11:42:33 +00:00
|
|
|
if(!($(":focus").is("input[type=text]") || $(":focus").is("textarea"))) {
|
2014-09-08 17:01:10 +00:00
|
|
|
var keycode = e.which;
|
|
|
|
if (typeof shortcuts[keycode] === "object") {
|
|
|
|
shortcuts[keycode].function();
|
2014-09-15 11:21:18 +00:00
|
|
|
} else if (keycode >= "0".charCodeAt(0) && keycode <= "9".charCodeAt(0)) {
|
2014-09-08 17:01:10 +00:00
|
|
|
var remoteVideos = $(".videocontainer:not(#mixedstream)"),
|
2014-09-15 12:44:02 +00:00
|
|
|
videoWanted = keycode - "0".charCodeAt(0) + 1;
|
2014-09-08 17:01:10 +00:00
|
|
|
if (remoteVideos.length > videoWanted) {
|
|
|
|
remoteVideos[videoWanted].click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onkeydown = function(e) {
|
|
|
|
if($("#chatspace").css("display") === "none") {
|
2014-09-10 08:32:26 +00:00
|
|
|
if(e.which === "T".charCodeAt(0)) {
|
2014-09-08 17:01:10 +00:00
|
|
|
if(isAudioMuted()) {
|
|
|
|
toggleAudio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-09-10 08:32:26 +00:00
|
|
|
|
2014-09-08 17:01:10 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param id indicates the popover associated with the shortcut
|
|
|
|
* @returns {string} the keyboard shortcut used for the id given
|
|
|
|
*/
|
|
|
|
my.getShortcut = function(id) {
|
|
|
|
for(var keycode in shortcuts) {
|
|
|
|
if(shortcuts.hasOwnProperty(keycode)) {
|
|
|
|
if (shortcuts[keycode].id === id) {
|
|
|
|
return " (" + shortcuts[keycode].character + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
};
|
|
|
|
return my;
|
|
|
|
}(KeyboardShortcut || {}));
|