|
@@ -2,7 +2,12 @@
|
2
|
2
|
/* application specific logic */
|
3
|
3
|
var connection = null;
|
4
|
4
|
var authenticatedUser = false;
|
|
5
|
+/* Popup window that show login page */
|
5
|
6
|
var authenticationWindow = null;
|
|
7
|
+/* Initial "authentication required" dialog */
|
|
8
|
+var authDialog = null;
|
|
9
|
+/* Loop retry ID that wits for other user to create the room */
|
|
10
|
+var authRetryId = null;
|
6
|
11
|
var activecall = null;
|
7
|
12
|
var nickname = null;
|
8
|
13
|
var sharedKey = '';
|
|
@@ -187,6 +192,17 @@ function doJoin() {
|
187
|
192
|
|
188
|
193
|
function doJoinAfterFocus() {
|
189
|
194
|
|
|
195
|
+ // Close authentication dialog if opened
|
|
196
|
+ if (authDialog) {
|
|
197
|
+ messageHandler.closeDialog();
|
|
198
|
+ authDialog = null;
|
|
199
|
+ }
|
|
200
|
+ // Clear retry interval, so that we don't call 'doJoinAfterFocus' twice
|
|
201
|
+ if (authRetryId) {
|
|
202
|
+ window.clearTimeout(authRetryId);
|
|
203
|
+ authRetryId = null;
|
|
204
|
+ }
|
|
205
|
+
|
190
|
206
|
var roomjid;
|
191
|
207
|
roomjid = roomName;
|
192
|
208
|
|
|
@@ -879,38 +895,62 @@ $(document).bind('passwordrequired.main', function (event) {
|
879
|
895
|
});
|
880
|
896
|
|
881
|
897
|
$(document).bind('auth_required.moderator', function () {
|
|
898
|
+
|
|
899
|
+ // This is the loop that will wait for the room to be created by
|
|
900
|
+ // someone else. 'auth_required.moderator' will bring us back here.
|
|
901
|
+ authRetryId = window.setTimeout(
|
|
902
|
+ function () {
|
|
903
|
+ Moderator.allocateConferenceFocus(roomName, doJoinAfterFocus);
|
|
904
|
+ }, 5000);
|
|
905
|
+ // Show prompt only if it's not open
|
|
906
|
+ if (authDialog !== null) {
|
|
907
|
+ return;
|
|
908
|
+ }
|
882
|
909
|
// extract room name from 'room@muc.server.net'
|
883
|
910
|
var room = roomName.substr(0, roomName.indexOf('@'));
|
884
|
911
|
|
885
|
|
- messageHandler.openDialog(
|
|
912
|
+ authDialog = messageHandler.openDialog(
|
886
|
913
|
'Stop',
|
887
|
|
- 'Authentication is required to create room:<br/>' + room,
|
|
914
|
+ 'Authentication is required to create room:<br/><b>' + room +
|
|
915
|
+ '</b></br> You can either authenticate to create the room or ' +
|
|
916
|
+ 'just wait for someone else to do so.',
|
888
|
917
|
true,
|
889
|
918
|
{
|
890
|
|
- Authenticate: 'authNow',
|
891
|
|
- Close: 'close'
|
|
919
|
+ Authenticate: 'authNow'
|
892
|
920
|
},
|
893
|
921
|
function (onSubmitEvent, submitValue) {
|
894
|
|
- console.info('On submit: ' + submitValue, submitValue);
|
|
922
|
+
|
|
923
|
+ // Do not close the dialog yet
|
|
924
|
+ onSubmitEvent.preventDefault();
|
|
925
|
+
|
|
926
|
+ // Open login popup
|
895
|
927
|
if (submitValue === 'authNow') {
|
896
|
928
|
authenticateClicked();
|
897
|
|
- } else {
|
898
|
|
- Toolbar.showAuthenticateButton(true);
|
899
|
929
|
}
|
900
|
930
|
}
|
901
|
931
|
);
|
902
|
932
|
});
|
903
|
933
|
|
904
|
934
|
function authenticateClicked() {
|
|
935
|
+ // If auth window exists just bring it to the front
|
|
936
|
+ if (authenticationWindow) {
|
|
937
|
+ authenticationWindow.focus();
|
|
938
|
+ return;
|
|
939
|
+ }
|
905
|
940
|
// Get authentication URL
|
906
|
941
|
Moderator.getAuthUrl(function (url) {
|
907
|
942
|
// Open popup with authentication URL
|
908
|
943
|
authenticationWindow = messageHandler.openCenteredPopup(
|
909
|
944
|
url, 910, 660,
|
|
945
|
+ // On closed
|
910
|
946
|
function () {
|
|
947
|
+ // Close authentication dialog if opened
|
|
948
|
+ if (authDialog) {
|
|
949
|
+ messageHandler.closeDialog();
|
|
950
|
+ authDialog = null;
|
|
951
|
+ }
|
911
|
952
|
// On popup closed - retry room allocation
|
912
|
|
- Moderator.allocateConferenceFocus(
|
913
|
|
- roomName, doJoinAfterFocus);
|
|
953
|
+ Moderator.allocateConferenceFocus(roomName, doJoinAfterFocus);
|
914
|
954
|
authenticationWindow = null;
|
915
|
955
|
});
|
916
|
956
|
if (!authenticationWindow) {
|
|
@@ -1587,21 +1627,15 @@ function hangup() {
|
1587
|
1627
|
|
1588
|
1628
|
}
|
1589
|
1629
|
|
1590
|
|
- $.prompt("Session Terminated",
|
|
1630
|
+ messageHandler.openDialog(
|
|
1631
|
+ "Session Terminated",
|
|
1632
|
+ "You hung up the call",
|
|
1633
|
+ true,
|
|
1634
|
+ { "Join again": true },
|
|
1635
|
+ function(event, value, message, formVals)
|
1591
|
1636
|
{
|
1592
|
|
- title: "You hung up the call",
|
1593
|
|
- persistent: true,
|
1594
|
|
- buttons: {
|
1595
|
|
- "Join again": true
|
1596
|
|
- },
|
1597
|
|
- closeText: '',
|
1598
|
|
- submit: function(event, value, message, formVals)
|
1599
|
|
- {
|
1600
|
|
- window.location.reload();
|
1601
|
|
- return false;
|
1602
|
|
- }
|
1603
|
|
-
|
|
1637
|
+ window.location.reload();
|
|
1638
|
+ return false;
|
1604
|
1639
|
}
|
1605
|
1640
|
);
|
1606
|
|
-
|
1607
|
1641
|
}
|