|
@@ -25,6 +25,11 @@ function init() {
|
25
|
25
|
RTCPeerconnection = TraceablePeerConnection;
|
26
|
26
|
|
27
|
27
|
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
|
28
|
+
|
|
29
|
+ if (nickname) {
|
|
30
|
+ connection.emuc.addDisplayNameToPresence(nickname);
|
|
31
|
+ }
|
|
32
|
+
|
28
|
33
|
if (connection.disco) {
|
29
|
34
|
// for chrome, add multistream cap
|
30
|
35
|
}
|
|
@@ -270,22 +275,34 @@ $(document).bind('setLocalDescription.jingle', function (event, sid) {
|
270
|
275
|
$(document).bind('joined.muc', function (event, jid, info) {
|
271
|
276
|
updateRoomUrl(window.location.href);
|
272
|
277
|
document.getElementById('localNick').appendChild(
|
273
|
|
- document.createTextNode(Strophe.getResourceFromJid(jid) + ' (you)')
|
|
278
|
+ document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
|
274
|
279
|
);
|
275
|
280
|
|
276
|
281
|
if (Object.keys(connection.emuc.members).length < 1) {
|
277
|
282
|
focus = new ColibriFocus(connection, config.hosts.bridge);
|
278
|
283
|
}
|
279
|
|
-
|
|
284
|
+
|
|
285
|
+ showFocusIndicator();
|
|
286
|
+
|
280
|
287
|
// Once we've joined the muc show the toolbar
|
281
|
288
|
showToolbar();
|
|
289
|
+
|
|
290
|
+ var displayName = '';
|
|
291
|
+ if (info.displayName)
|
|
292
|
+ displayName = info.displayName + ' (me)';
|
|
293
|
+
|
|
294
|
+ showDisplayName('localVideoContainer', displayName);
|
282
|
295
|
});
|
283
|
296
|
|
284
|
297
|
$(document).bind('entered.muc', function (event, jid, info, pres) {
|
285
|
298
|
console.log('entered', jid, info);
|
286
|
299
|
console.log(focus);
|
287
|
|
-
|
288
|
|
- var container = addRemoteVideoContainer('participant_' + Strophe.getResourceFromJid(jid));
|
|
300
|
+
|
|
301
|
+ var videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
302
|
+ var container = addRemoteVideoContainer(videoSpanId);
|
|
303
|
+
|
|
304
|
+ if (info.displayName)
|
|
305
|
+ showDisplayName(videoSpanId, info.displayName);
|
289
|
306
|
|
290
|
307
|
var nickfield = document.createElement('span');
|
291
|
308
|
nickfield.appendChild(document.createTextNode(Strophe.getResourceFromJid(jid)));
|
|
@@ -350,6 +367,13 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
|
350
|
367
|
//console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
|
351
|
368
|
ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
|
352
|
369
|
});
|
|
370
|
+
|
|
371
|
+ if (info.displayName) {
|
|
372
|
+ if (jid === connection.emuc.myroomjid)
|
|
373
|
+ showDisplayName('localVideoContainer', info.displayName + ' (me)');
|
|
374
|
+ else
|
|
375
|
+ showDisplayName('participant_' + Strophe.getResourceFromJid(jid), info.displayName);
|
|
376
|
+ }
|
353
|
377
|
});
|
354
|
378
|
|
355
|
379
|
$(document).bind('passwordrequired.muc', function (event, jid) {
|
|
@@ -371,7 +395,7 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
|
371
|
395
|
|
372
|
396
|
if (lockKey.value != null)
|
373
|
397
|
{
|
374
|
|
- setSharedKey(lockKey);
|
|
398
|
+ setSharedKey(lockKey.value);
|
375
|
399
|
connection.emuc.doJoin(jid, lockKey.value);
|
376
|
400
|
}
|
377
|
401
|
}
|
|
@@ -559,7 +583,9 @@ function toggleAudio() {
|
559
|
583
|
function resizeLarge() {
|
560
|
584
|
resizeChat();
|
561
|
585
|
var availableHeight = window.innerHeight;
|
562
|
|
- var chatspaceWidth = $('#chatspace').width();
|
|
586
|
+ var chatspaceWidth = $('#chatspace').is(":visible")
|
|
587
|
+ ? $('#chatspace').width()
|
|
588
|
+ : 0;
|
563
|
589
|
|
564
|
590
|
var numvids = $('#remoteVideos>video:visible').length;
|
565
|
591
|
if (numvids < 5)
|
|
@@ -631,6 +657,13 @@ function resizeChatConversation() {
|
631
|
657
|
}
|
632
|
658
|
|
633
|
659
|
$(document).ready(function () {
|
|
660
|
+ var storedDisplayName = window.localStorage.displayname;
|
|
661
|
+ if (storedDisplayName) {
|
|
662
|
+ nickname = storedDisplayName;
|
|
663
|
+
|
|
664
|
+ setChatConversationMode(true);
|
|
665
|
+ }
|
|
666
|
+
|
634
|
667
|
$('#nickinput').keydown(function(event) {
|
635
|
668
|
if (event.keyCode == 13) {
|
636
|
669
|
event.preventDefault();
|
|
@@ -638,10 +671,13 @@ $(document).ready(function () {
|
638
|
671
|
this.value = '';
|
639
|
672
|
if (!nickname) {
|
640
|
673
|
nickname = val;
|
641
|
|
- $('#nickname').css({visibility:"hidden"});
|
642
|
|
- $('#chatconversation').css({visibility:'visible'});
|
643
|
|
- $('#usermsg').css({visibility:'visible'});
|
644
|
|
- $('#usermsg').focus();
|
|
674
|
+ window.localStorage.displayname = nickname;
|
|
675
|
+
|
|
676
|
+ connection.emuc.addDisplayNameToPresence(nickname);
|
|
677
|
+ connection.emuc.sendPresence();
|
|
678
|
+
|
|
679
|
+ setChatConversationMode(true);
|
|
680
|
+
|
645
|
681
|
return;
|
646
|
682
|
}
|
647
|
683
|
}
|
|
@@ -743,7 +779,7 @@ function updateChatConversation(nick, message)
|
743
|
779
|
divClassName = "localuser";
|
744
|
780
|
else
|
745
|
781
|
divClassName = "remoteuser";
|
746
|
|
-
|
|
782
|
+
|
747
|
783
|
//replace links and smileys
|
748
|
784
|
message = processReplacements(message);
|
749
|
785
|
|
|
@@ -1072,11 +1108,11 @@ function closePageWarning() {
|
1072
|
1108
|
*/
|
1073
|
1109
|
function showFocusIndicator() {
|
1074
|
1110
|
if (focus != null) {
|
1075
|
|
- var localVideoToolbar = document.getElementById('localVideoToolbar');
|
|
1111
|
+ var indicatorSpan = $('#localVideoContainer .focusindicator');
|
1076
|
1112
|
|
1077
|
|
- if (localVideoToolbar.childNodes.length === 0)
|
|
1113
|
+ if (indicatorSpan.children().length == 0)
|
1078
|
1114
|
{
|
1079
|
|
- createFocusIndicatorElement(localVideoToolbar);
|
|
1115
|
+ createFocusIndicatorElement(indicatorSpan[0]);
|
1080
|
1116
|
}
|
1081
|
1117
|
}
|
1082
|
1118
|
else if (Object.keys(connection.jingle.sessions).length > 0) {
|
|
@@ -1121,12 +1157,11 @@ function scrollChatToBottom() {
|
1121
|
1157
|
}, 5);
|
1122
|
1158
|
}
|
1123
|
1159
|
|
1124
|
|
-
|
1125
|
1160
|
/*
|
1126
|
1161
|
* Toggles the application in and out of full screen mode
|
1127
|
1162
|
* (a.k.a. presentation mode in Chrome).
|
1128
|
1163
|
*/
|
1129
|
|
-function toggleFullScreen() {
|
|
1164
|
+function toggleFullScreen() {
|
1130
|
1165
|
var fsElement = document.documentElement;
|
1131
|
1166
|
|
1132
|
1167
|
if (!document.mozFullScreen && !document.webkitIsFullScreen){
|
|
@@ -1151,3 +1186,104 @@ function toggleFullScreen() {
|
1151
|
1186
|
}
|
1152
|
1187
|
}
|
1153
|
1188
|
}
|
|
1189
|
+
|
|
1190
|
+/**
|
|
1191
|
+ *
|
|
1192
|
+ */
|
|
1193
|
+function showDisplayName(videoSpanId, displayName) {
|
|
1194
|
+ var nameSpan = $('#' + videoSpanId + '>span.displayname');
|
|
1195
|
+
|
|
1196
|
+ // If we already have a display name for this video.
|
|
1197
|
+ if (nameSpan.length > 0) {
|
|
1198
|
+ var nameSpanElement = nameSpan.get(0);
|
|
1199
|
+
|
|
1200
|
+ if (nameSpanElement.id == 'localDisplayName'
|
|
1201
|
+ && $('#localDisplayName').html() != displayName)
|
|
1202
|
+ $('#localDisplayName').html(displayName);
|
|
1203
|
+ else
|
|
1204
|
+ $('#' + videoSpanId + '_name').html(displayName);
|
|
1205
|
+ }
|
|
1206
|
+ else {
|
|
1207
|
+ var editButton = null;
|
|
1208
|
+ if (videoSpanId == 'localVideoContainer') {
|
|
1209
|
+ editButton = createEditDisplayNameButton();
|
|
1210
|
+ }
|
|
1211
|
+
|
|
1212
|
+ if (displayName.length) {
|
|
1213
|
+ nameSpan = document.createElement('span');
|
|
1214
|
+ nameSpan.className = 'displayname';
|
|
1215
|
+ nameSpan.innerHTML = displayName;
|
|
1216
|
+ $('#' + videoSpanId)[0].appendChild(nameSpan);
|
|
1217
|
+ }
|
|
1218
|
+
|
|
1219
|
+ if (!editButton) {
|
|
1220
|
+ nameSpan.id = videoSpanId + '_name';
|
|
1221
|
+ }
|
|
1222
|
+ else {
|
|
1223
|
+ nameSpan.id = 'localDisplayName';
|
|
1224
|
+ $('#' + videoSpanId)[0].appendChild(editButton);
|
|
1225
|
+
|
|
1226
|
+ var editableText = document.createElement('input');
|
|
1227
|
+ editableText.className = 'displayname';
|
|
1228
|
+ editableText.id = 'editDisplayName';
|
|
1229
|
+
|
|
1230
|
+ if (displayName.length)
|
|
1231
|
+ editableText.value = displayName.substring(0, displayName.indexOf(' (me)'));
|
|
1232
|
+
|
|
1233
|
+ editableText.setAttribute('style', 'display:none;');
|
|
1234
|
+ editableText.setAttribute('placeholder', 'ex. Jane Pink');
|
|
1235
|
+ $('#' + videoSpanId)[0].appendChild(editableText);
|
|
1236
|
+
|
|
1237
|
+ $('#localVideoContainer .displayname').bind("click", function(e) {
|
|
1238
|
+ e.preventDefault();
|
|
1239
|
+ $('#localDisplayName').hide();
|
|
1240
|
+ $('#editDisplayName').show();
|
|
1241
|
+ $('#editDisplayName').focus();
|
|
1242
|
+ $('#editDisplayName').select();
|
|
1243
|
+
|
|
1244
|
+ var inputDisplayNameHandler = function(name) {
|
|
1245
|
+ if (nickname != name) {
|
|
1246
|
+ nickname = name;
|
|
1247
|
+ window.localStorage.displayname = nickname;
|
|
1248
|
+ connection.emuc.addDisplayNameToPresence(nickname);
|
|
1249
|
+ connection.emuc.sendPresence();
|
|
1250
|
+ }
|
|
1251
|
+
|
|
1252
|
+ if (!$('#localDisplayName').is(":visible")) {
|
|
1253
|
+ $('#localDisplayName').html(name + " (me)");
|
|
1254
|
+ $('#localDisplayName').show();
|
|
1255
|
+ $('#editDisplayName').hide();
|
|
1256
|
+ }
|
|
1257
|
+ };
|
|
1258
|
+
|
|
1259
|
+ $('#editDisplayName').one("focusout", function (e) {
|
|
1260
|
+ inputDisplayNameHandler(this.value);
|
|
1261
|
+ });
|
|
1262
|
+
|
|
1263
|
+ $('#editDisplayName').on('keydown', function (e) {
|
|
1264
|
+ if (e.keyCode == 13) {
|
|
1265
|
+ e.preventDefault();
|
|
1266
|
+ inputDisplayNameHandler(this.value);
|
|
1267
|
+ }
|
|
1268
|
+ });
|
|
1269
|
+ });
|
|
1270
|
+ }
|
|
1271
|
+ }
|
|
1272
|
+}
|
|
1273
|
+
|
|
1274
|
+function createEditDisplayNameButton() {
|
|
1275
|
+ var editButton = document.createElement('a');
|
|
1276
|
+ editButton.className = 'displayname';
|
|
1277
|
+ editButton.innerHTML = '<i class="fa fa-pencil"></i>';
|
|
1278
|
+
|
|
1279
|
+ return editButton;
|
|
1280
|
+}
|
|
1281
|
+
|
|
1282
|
+function setChatConversationMode(isConversationMode) {
|
|
1283
|
+ if (isConversationMode) {
|
|
1284
|
+ $('#nickname').css({visibility:"hidden"});
|
|
1285
|
+ $('#chatconversation').css({visibility:'visible'});
|
|
1286
|
+ $('#usermsg').css({visibility:'visible'});
|
|
1287
|
+ $('#usermsg').focus();
|
|
1288
|
+ }
|
|
1289
|
+}
|