Parcourir la source

Fixes display name escape problem (Issue #54). Fixes selecting of remote video when clicking the display name.

master
yanas il y a 11 ans
Parent
révision
e27da40bb2
2 fichiers modifiés avec 34 ajouts et 19 suppressions
  1. 23
    16
      app.js
  2. 11
    3
      css/videolayout_default.css

+ 23
- 16
app.js Voir le fichier

224
         if (data.stream.id === 'mixedmslabel') return;
224
         if (data.stream.id === 'mixedmslabel') return;
225
         var videoTracks = data.stream.getVideoTracks();
225
         var videoTracks = data.stream.getVideoTracks();
226
         console.log("waiting..", videoTracks, selector[0]);
226
         console.log("waiting..", videoTracks, selector[0]);
227
+
227
         if (videoTracks.length === 0 || selector[0].currentTime > 0) {
228
         if (videoTracks.length === 0 || selector[0].currentTime > 0) {
228
             RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
229
             RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
229
 
230
 
1002
     resizeThumbnails();
1003
     resizeThumbnails();
1003
 };
1004
 };
1004
 
1005
 
1005
-function resizeThumbnails() {
1006
-    // Calculate the available height, which is the inner window height minus
1006
+var calculateThumbnailSize = function() {
1007
+ // Calculate the available height, which is the inner window height minus
1007
     // 39px for the header minus 2px for the delimiter lines on the top and
1008
     // 39px for the header minus 2px for the delimiter lines on the top and
1008
     // bottom of the large video, minus the 36px space inside the remoteVideos
1009
     // bottom of the large video, minus the 36px space inside the remoteVideos
1009
     // container used for highlighting shadow.
1010
     // container used for highlighting shadow.
1021
         availableWidth = Math.floor(availableHeight * aspectRatio);
1022
         availableWidth = Math.floor(availableHeight * aspectRatio);
1022
     }
1023
     }
1023
 
1024
 
1025
+    return [availableWidth, availableHeight];
1026
+};
1027
+
1028
+function resizeThumbnails() {
1029
+    var thumbnailSize = calculateThumbnailSize();
1030
+    var width = thumbnailSize[0];
1031
+    var height = thumbnailSize[1];
1032
+
1024
     // size videos so that while keeping AR and max height, we have a nice fit
1033
     // size videos so that while keeping AR and max height, we have a nice fit
1025
-    $('#remoteVideos').height(availableHeight);
1026
-    $('#remoteVideos>span').width(availableWidth);
1027
-    $('#remoteVideos>span').height(availableHeight);
1034
+    $('#remoteVideos').height(height);
1035
+    $('#remoteVideos>span').width(width);
1036
+    $('#remoteVideos>span').height(height);
1028
 }
1037
 }
1029
 
1038
 
1030
 $(document).ready(function () {
1039
 $(document).ready(function () {
1480
  * Shows the display name for the given video.
1489
  * Shows the display name for the given video.
1481
  */
1490
  */
1482
 function showDisplayName(videoSpanId, displayName) {
1491
 function showDisplayName(videoSpanId, displayName) {
1483
-    var escDisplayName = Util.escapeHtml(displayName);
1484
-
1485
     var nameSpan = $('#' + videoSpanId + '>span.displayname');
1492
     var nameSpan = $('#' + videoSpanId + '>span.displayname');
1486
 
1493
 
1487
     // If we already have a display name for this video.
1494
     // If we already have a display name for this video.
1489
         var nameSpanElement = nameSpan.get(0);
1496
         var nameSpanElement = nameSpan.get(0);
1490
 
1497
 
1491
         if (nameSpanElement.id === 'localDisplayName'
1498
         if (nameSpanElement.id === 'localDisplayName'
1492
-            && $('#localDisplayName').html() !== escDisplayName)
1493
-            $('#localDisplayName').html(escDisplayName);
1499
+            && $('#localDisplayName').text() !== displayName)
1500
+            $('#localDisplayName').text(displayName);
1494
         else
1501
         else
1495
-            $('#' + videoSpanId + '_name').html(escDisplayName);
1502
+            $('#' + videoSpanId + '_name').text(displayName);
1496
     }
1503
     }
1497
     else {
1504
     else {
1498
         var editButton = null;
1505
         var editButton = null;
1500
         if (videoSpanId === 'localVideoContainer') {
1507
         if (videoSpanId === 'localVideoContainer') {
1501
             editButton = createEditDisplayNameButton();
1508
             editButton = createEditDisplayNameButton();
1502
         }
1509
         }
1503
-        if (escDisplayName.length) {
1510
+        if (displayName.length) {
1504
             nameSpan = document.createElement('span');
1511
             nameSpan = document.createElement('span');
1505
             nameSpan.className = 'displayname';
1512
             nameSpan.className = 'displayname';
1506
-            nameSpan.innerHTML = escDisplayName;
1513
+            nameSpan.innerText = displayName;
1507
             $('#' + videoSpanId)[0].appendChild(nameSpan);
1514
             $('#' + videoSpanId)[0].appendChild(nameSpan);
1508
         }
1515
         }
1509
 
1516
 
1518
             editableText.className = 'displayname';
1525
             editableText.className = 'displayname';
1519
             editableText.id = 'editDisplayName';
1526
             editableText.id = 'editDisplayName';
1520
 
1527
 
1521
-            if (escDisplayName.length)
1528
+            if (displayName.length)
1522
                 editableText.value
1529
                 editableText.value
1523
-                    = escDisplayName.substring(0, escDisplayName.indexOf(' (me)'));
1530
+                    = displayName.substring(0, displayName.indexOf(' (me)'));
1524
 
1531
 
1525
             editableText.setAttribute('style', 'display:none;');
1532
             editableText.setAttribute('style', 'display:none;');
1526
             editableText.setAttribute('placeholder', 'ex. Jane Pink');
1533
             editableText.setAttribute('placeholder', 'ex. Jane Pink');
1535
 
1542
 
1536
                 var inputDisplayNameHandler = function(name) {
1543
                 var inputDisplayNameHandler = function(name) {
1537
                     if (nickname !== name) {
1544
                     if (nickname !== name) {
1538
-                        nickname = Util.escapeHtml(name);
1545
+                        nickname = name;
1539
                         window.localStorage.displayname = nickname;
1546
                         window.localStorage.displayname = nickname;
1540
                         connection.emuc.addDisplayNameToPresence(nickname);
1547
                         connection.emuc.addDisplayNameToPresence(nickname);
1541
                         connection.emuc.sendPresence();
1548
                         connection.emuc.sendPresence();
1544
                     }
1551
                     }
1545
 
1552
 
1546
                     if (!$('#localDisplayName').is(":visible")) {
1553
                     if (!$('#localDisplayName').is(":visible")) {
1547
-                        $('#localDisplayName').html(nickname + " (me)");
1554
+                        $('#localDisplayName').text(nickname + " (me)");
1548
                         $('#localDisplayName').show();
1555
                         $('#localDisplayName').show();
1549
                         $('#editDisplayName').hide();
1556
                         $('#editDisplayName').hide();
1550
                     }
1557
                     }

+ 11
- 3
css/videolayout_default.css Voir le fichier

61
 }
61
 }
62
 
62
 
63
 #remoteVideos .videocontainer>video {
63
 #remoteVideos .videocontainer>video {
64
-    border-radius:6px;
64
+    border-radius:4px;
65
 }
65
 }
66
 
66
 
67
 .flipVideoX {
67
 .flipVideoX {
150
     white-space: nowrap;
150
     white-space: nowrap;
151
     z-index: 2;
151
     z-index: 2;
152
     box-sizing: border-box;
152
     box-sizing: border-box;
153
-    border-bottom-left-radius:6px;
154
-    border-bottom-right-radius:6px;
153
+    border-bottom-left-radius:4px;
154
+    border-bottom-right-radius:4px;
155
 }
155
 }
156
 
156
 
157
 #localVideoContainer>span.displayname:hover {
157
 #localVideoContainer>span.displayname:hover {
158
     cursor: text;
158
     cursor: text;
159
 }
159
 }
160
 
160
 
161
+.videocontainer>span.displayname {
162
+    pointer-events: none;
163
+}
164
+
165
+#localDisplayName {
166
+    pointer-events: auto !important;
167
+}
168
+
161
 .videocontainer>a.displayname {
169
 .videocontainer>a.displayname {
162
     display: inline-block;
170
     display: inline-block;
163
     position: absolute;
171
     position: absolute;

Chargement…
Annuler
Enregistrer