Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Authentication.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Initial "authentication required" dialog */
  2. var authDialog = null;
  3. /* Loop retry ID that wits for other user to create the room */
  4. var authRetryId = null;
  5. var authenticationWindow = null;
  6. var Authentication = {
  7. openAuthenticationDialog: function (roomName, intervalCallback, callback) {
  8. // This is the loop that will wait for the room to be created by
  9. // someone else. 'auth_required.moderator' will bring us back here.
  10. authRetryId = window.setTimeout(intervalCallback , 5000);
  11. // Show prompt only if it's not open
  12. if (authDialog !== null) {
  13. return;
  14. }
  15. // extract room name from 'room@muc.server.net'
  16. var room = roomName.substr(0, roomName.indexOf('@'));
  17. authDialog = messageHandler.openDialog(
  18. 'Stop',
  19. 'Authentication is required to create room:<br/><b>' + room +
  20. '</b></br> You can either authenticate to create the room or ' +
  21. 'just wait for someone else to do so.',
  22. true,
  23. {
  24. Authenticate: 'authNow'
  25. },
  26. function (onSubmitEvent, submitValue) {
  27. // Do not close the dialog yet
  28. onSubmitEvent.preventDefault();
  29. // Open login popup
  30. if (submitValue === 'authNow') {
  31. callback();
  32. }
  33. }
  34. );
  35. },
  36. closeAuthenticationWindow:function () {
  37. if (authenticationWindow) {
  38. authenticationWindow.close();
  39. authenticationWindow = null;
  40. }
  41. },
  42. focusAuthenticationWindow: function () {
  43. // If auth window exists just bring it to the front
  44. if (authenticationWindow) {
  45. authenticationWindow.focus();
  46. return;
  47. }
  48. },
  49. closeAuthenticationDialog: function () {
  50. // Close authentication dialog if opened
  51. if (authDialog) {
  52. APP.UI.messageHandler.closeDialog();
  53. authDialog = null;
  54. }
  55. },
  56. createAuthenticationWindow: function (callback, url) {
  57. authenticationWindow = messageHandler.openCenteredPopup(
  58. url, 910, 660,
  59. // On closed
  60. function () {
  61. // Close authentication dialog if opened
  62. if (authDialog) {
  63. messageHandler.closeDialog();
  64. authDialog = null;
  65. }
  66. callback();
  67. authenticationWindow = null;
  68. });
  69. return authenticationWindow;
  70. },
  71. stopInterval: function () {
  72. // Clear retry interval, so that we don't call 'doJoinAfterFocus' twice
  73. if (authRetryId) {
  74. window.clearTimeout(authRetryId);
  75. authRetryId = null;
  76. }
  77. }
  78. };
  79. module.exports = Authentication;