You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

keyboard_shortcut.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. var KeyboardShortcut = (function(my) {
  2. var shortcuts = {
  3. 67: {
  4. character: "C",
  5. id: "toggleChatPopover",
  6. function: BottomToolbar.toggleChat
  7. },
  8. 70: {
  9. character: "F",
  10. id: "filmstripPopover",
  11. function: BottomToolbar.toggleFilmStrip
  12. },
  13. 77: {
  14. character: "M",
  15. id: "mutePopover",
  16. function: toggleAudio
  17. },
  18. 84: {
  19. character: "T",
  20. function: function() {
  21. if(!isAudioMuted()) {
  22. toggleAudio();
  23. }
  24. }
  25. },
  26. 86: {
  27. character: "V",
  28. id: "toggleVideoPopover",
  29. function: toggleVideo
  30. }
  31. };
  32. window.onkeyup = function(e) {
  33. if($("#chatspace").css("display") === "none") {
  34. var keycode = e.which;
  35. if (typeof shortcuts[keycode] === "object") {
  36. shortcuts[keycode].function();
  37. } else if (keycode >= 49 && keycode <= 57) {
  38. var remoteVideos = $(".videocontainer:not(#mixedstream)"),
  39. videoWanted = keycode - 48;
  40. if (remoteVideos.length > videoWanted) {
  41. remoteVideos[videoWanted].click();
  42. }
  43. }
  44. }
  45. };
  46. window.onkeydown = function(e) {
  47. if($("#chatspace").css("display") === "none") {
  48. if(e.which === 84) {
  49. if(isAudioMuted()) {
  50. toggleAudio();
  51. }
  52. }
  53. }
  54. };
  55. /**
  56. *
  57. * @param id indicates the popover associated with the shortcut
  58. * @returns {string} the keyboard shortcut used for the id given
  59. */
  60. my.getShortcut = function(id) {
  61. for(var keycode in shortcuts) {
  62. if(shortcuts.hasOwnProperty(keycode)) {
  63. if (shortcuts[keycode].id === id) {
  64. return " (" + shortcuts[keycode].character + ")";
  65. }
  66. }
  67. }
  68. return "";
  69. };
  70. return my;
  71. }(KeyboardShortcut || {}));