您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

toolbar.js 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /* global $, buttonClick, config, lockRoom, messageHandler, Moderator, roomUrl,
  2. setSharedKey, sharedKey, Util */
  3. var Toolbar = (function (my) {
  4. /**
  5. * Disables and enables some of the buttons.
  6. */
  7. my.setupButtonsFromConfig = function () {
  8. if (config.disablePrezi)
  9. {
  10. $("#prezi_button").css({display: "none"});
  11. }
  12. };
  13. /**
  14. * Opens the lock room dialog.
  15. */
  16. my.openLockDialog = function () {
  17. // Only the focus is able to set a shared key.
  18. if (Moderator.isModerator()) {
  19. if (sharedKey) {
  20. messageHandler.openMessageDialog(null,
  21. "This conversation is currently protected by" +
  22. " a password. Only the owner of the conference" +
  23. " could set a password.",
  24. false,
  25. "Password");
  26. } else {
  27. messageHandler.openMessageDialog(null,
  28. "This conversation isn't currently protected by" +
  29. " a password. Only the owner of the conference" +
  30. " could set a password.",
  31. false,
  32. "Password");
  33. }
  34. } else {
  35. if (sharedKey) {
  36. messageHandler.openTwoButtonDialog(null,
  37. "Are you sure you would like to remove your password?",
  38. false,
  39. "Remove",
  40. function (e, v) {
  41. if (v) {
  42. setSharedKey('');
  43. lockRoom(false);
  44. }
  45. });
  46. } else {
  47. messageHandler.openTwoButtonDialog(null,
  48. '<h2>Set a password to lock your room</h2>' +
  49. '<input id="lockKey" type="text"' +
  50. 'placeholder="your password" autofocus>',
  51. false,
  52. "Save",
  53. function (e, v) {
  54. if (v) {
  55. var lockKey = document.getElementById('lockKey');
  56. if (lockKey.value) {
  57. setSharedKey(Util.escapeHtml(lockKey.value));
  58. lockRoom(true);
  59. }
  60. }
  61. },
  62. function () {
  63. document.getElementById('lockKey').focus();
  64. }
  65. );
  66. }
  67. }
  68. };
  69. /**
  70. * Opens the invite link dialog.
  71. */
  72. my.openLinkDialog = function () {
  73. var inviteLink;
  74. if (roomUrl === null) {
  75. inviteLink = "Your conference is currently being created...";
  76. } else {
  77. inviteLink = encodeURI(roomUrl);
  78. }
  79. messageHandler.openTwoButtonDialog(
  80. "Share this link with everyone you want to invite",
  81. '<input id="inviteLinkRef" type="text" value="' +
  82. inviteLink + '" onclick="this.select();" readonly>',
  83. false,
  84. "Invite",
  85. function (e, v) {
  86. if (v) {
  87. if (roomUrl) {
  88. inviteParticipants();
  89. }
  90. }
  91. },
  92. function () {
  93. if (roomUrl) {
  94. document.getElementById('inviteLinkRef').select();
  95. } else {
  96. document.getElementById('jqi_state0_buttonInvite')
  97. .disabled = true;
  98. }
  99. }
  100. );
  101. };
  102. /**
  103. * Invite participants to conference.
  104. */
  105. function inviteParticipants() {
  106. if (roomUrl === null)
  107. return;
  108. var sharedKeyText = "";
  109. if (sharedKey && sharedKey.length > 0) {
  110. sharedKeyText =
  111. "This conference is password protected. Please use the " +
  112. "following pin when joining:%0D%0A%0D%0A" +
  113. sharedKey + "%0D%0A%0D%0A";
  114. }
  115. var conferenceName = roomUrl.substring(roomUrl.lastIndexOf('/') + 1);
  116. var subject = "Invitation to a Jitsi Meet (" + conferenceName + ")";
  117. var body = "Hey there, I%27d like to invite you to a Jitsi Meet" +
  118. " conference I%27ve just set up.%0D%0A%0D%0A" +
  119. "Please click on the following link in order" +
  120. " to join the conference.%0D%0A%0D%0A" +
  121. roomUrl +
  122. "%0D%0A%0D%0A" +
  123. sharedKeyText +
  124. "Note that Jitsi Meet is currently" +
  125. " only supported by Chromium," +
  126. " Google Chrome and Opera, so you need" +
  127. " to be using one of these browsers.%0D%0A%0D%0A" +
  128. "Talk to you in a sec!";
  129. if (window.localStorage.displayname) {
  130. body += "%0D%0A%0D%0A" + window.localStorage.displayname;
  131. }
  132. window.open("mailto:?subject=" + subject + "&body=" + body, '_blank');
  133. }
  134. /**
  135. * Opens the settings dialog.
  136. */
  137. my.openSettingsDialog = function () {
  138. messageHandler.openTwoButtonDialog(
  139. '<h2>Configure your conference</h2>' +
  140. '<input type="checkbox" id="initMuted">' +
  141. 'Participants join muted<br/>' +
  142. '<input type="checkbox" id="requireNicknames">' +
  143. 'Require nicknames<br/><br/>' +
  144. 'Set a password to lock your room:' +
  145. '<input id="lockKey" type="text" placeholder="your password"' +
  146. 'autofocus>',
  147. null,
  148. false,
  149. "Save",
  150. function () {
  151. document.getElementById('lockKey').focus();
  152. },
  153. function (e, v) {
  154. if (v) {
  155. if ($('#initMuted').is(":checked")) {
  156. // it is checked
  157. }
  158. if ($('#requireNicknames').is(":checked")) {
  159. // it is checked
  160. }
  161. /*
  162. var lockKey = document.getElementById('lockKey');
  163. if (lockKey.value) {
  164. setSharedKey(lockKey.value);
  165. lockRoom(true);
  166. }
  167. */
  168. }
  169. }
  170. );
  171. };
  172. /**
  173. * Toggles the application in and out of full screen mode
  174. * (a.k.a. presentation mode in Chrome).
  175. */
  176. my.toggleFullScreen = function () {
  177. var fsElement = document.documentElement;
  178. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  179. //Enter Full Screen
  180. if (fsElement.mozRequestFullScreen) {
  181. fsElement.mozRequestFullScreen();
  182. }
  183. else {
  184. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  185. }
  186. } else {
  187. //Exit Full Screen
  188. if (document.mozCancelFullScreen) {
  189. document.mozCancelFullScreen();
  190. } else {
  191. document.webkitCancelFullScreen();
  192. }
  193. }
  194. };
  195. /**
  196. * Unlocks the lock button state.
  197. */
  198. my.unlockLockButton = function () {
  199. if ($("#lockIcon").hasClass("icon-security-locked"))
  200. buttonClick("#lockIcon", "icon-security icon-security-locked");
  201. };
  202. /**
  203. * Updates the lock button state to locked.
  204. */
  205. my.lockLockButton = function () {
  206. if ($("#lockIcon").hasClass("icon-security"))
  207. buttonClick("#lockIcon", "icon-security icon-security-locked");
  208. };
  209. // Shows or hides the 'recording' button.
  210. my.showRecordingButton = function (show) {
  211. if (!config.enableRecording) {
  212. return;
  213. }
  214. if (show) {
  215. $('#recording').css({display: "inline"});
  216. }
  217. else {
  218. $('#recording').css({display: "none"});
  219. }
  220. };
  221. // Sets the state of the recording button
  222. my.setRecordingButtonState = function (isRecording) {
  223. if (isRecording) {
  224. $('#recordButton').removeClass("icon-recEnable");
  225. $('#recordButton').addClass("icon-recEnable active");
  226. } else {
  227. $('#recordButton').removeClass("icon-recEnable active");
  228. $('#recordButton').addClass("icon-recEnable");
  229. }
  230. };
  231. // Shows or hides SIP calls button
  232. my.showSipCallButton = function (show) {
  233. if (config.hosts.call_control && show) {
  234. $('#sipCallButton').css({display: "inline"});
  235. } else {
  236. $('#sipCallButton').css({display: "none"});
  237. }
  238. };
  239. /**
  240. * Sets the state of the button. The button has blue glow if desktop
  241. * streaming is active.
  242. * @param active the state of the desktop streaming.
  243. */
  244. my.changeDesktopSharingButtonState = function (active) {
  245. var button = $("#desktopsharing > a");
  246. if (active)
  247. {
  248. button.addClass("glow");
  249. }
  250. else
  251. {
  252. button.removeClass("glow");
  253. }
  254. };
  255. return my;
  256. }(Toolbar || {}));