浏览代码

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

master
yanas 11 年前
父节点
当前提交
e27da40bb2
共有 2 个文件被更改,包括 34 次插入19 次删除
  1. 23
    16
      app.js
  2. 11
    3
      css/videolayout_default.css

+ 23
- 16
app.js 查看文件

@@ -224,6 +224,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
224 224
         if (data.stream.id === 'mixedmslabel') return;
225 225
         var videoTracks = data.stream.getVideoTracks();
226 226
         console.log("waiting..", videoTracks, selector[0]);
227
+
227 228
         if (videoTracks.length === 0 || selector[0].currentTime > 0) {
228 229
             RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
229 230
 
@@ -1002,8 +1003,8 @@ var resizeLargeVideoContainer = function () {
1002 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 1008
     // 39px for the header minus 2px for the delimiter lines on the top and
1008 1009
     // bottom of the large video, minus the 36px space inside the remoteVideos
1009 1010
     // container used for highlighting shadow.
@@ -1021,10 +1022,18 @@ function resizeThumbnails() {
1021 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 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 1039
 $(document).ready(function () {
@@ -1480,8 +1489,6 @@ function toggleFullScreen() {
1480 1489
  * Shows the display name for the given video.
1481 1490
  */
1482 1491
 function showDisplayName(videoSpanId, displayName) {
1483
-    var escDisplayName = Util.escapeHtml(displayName);
1484
-
1485 1492
     var nameSpan = $('#' + videoSpanId + '>span.displayname');
1486 1493
 
1487 1494
     // If we already have a display name for this video.
@@ -1489,10 +1496,10 @@ function showDisplayName(videoSpanId, displayName) {
1489 1496
         var nameSpanElement = nameSpan.get(0);
1490 1497
 
1491 1498
         if (nameSpanElement.id === 'localDisplayName'
1492
-            && $('#localDisplayName').html() !== escDisplayName)
1493
-            $('#localDisplayName').html(escDisplayName);
1499
+            && $('#localDisplayName').text() !== displayName)
1500
+            $('#localDisplayName').text(displayName);
1494 1501
         else
1495
-            $('#' + videoSpanId + '_name').html(escDisplayName);
1502
+            $('#' + videoSpanId + '_name').text(displayName);
1496 1503
     }
1497 1504
     else {
1498 1505
         var editButton = null;
@@ -1500,10 +1507,10 @@ function showDisplayName(videoSpanId, displayName) {
1500 1507
         if (videoSpanId === 'localVideoContainer') {
1501 1508
             editButton = createEditDisplayNameButton();
1502 1509
         }
1503
-        if (escDisplayName.length) {
1510
+        if (displayName.length) {
1504 1511
             nameSpan = document.createElement('span');
1505 1512
             nameSpan.className = 'displayname';
1506
-            nameSpan.innerHTML = escDisplayName;
1513
+            nameSpan.innerText = displayName;
1507 1514
             $('#' + videoSpanId)[0].appendChild(nameSpan);
1508 1515
         }
1509 1516
 
@@ -1518,9 +1525,9 @@ function showDisplayName(videoSpanId, displayName) {
1518 1525
             editableText.className = 'displayname';
1519 1526
             editableText.id = 'editDisplayName';
1520 1527
 
1521
-            if (escDisplayName.length)
1528
+            if (displayName.length)
1522 1529
                 editableText.value
1523
-                    = escDisplayName.substring(0, escDisplayName.indexOf(' (me)'));
1530
+                    = displayName.substring(0, displayName.indexOf(' (me)'));
1524 1531
 
1525 1532
             editableText.setAttribute('style', 'display:none;');
1526 1533
             editableText.setAttribute('placeholder', 'ex. Jane Pink');
@@ -1535,7 +1542,7 @@ function showDisplayName(videoSpanId, displayName) {
1535 1542
 
1536 1543
                 var inputDisplayNameHandler = function(name) {
1537 1544
                     if (nickname !== name) {
1538
-                        nickname = Util.escapeHtml(name);
1545
+                        nickname = name;
1539 1546
                         window.localStorage.displayname = nickname;
1540 1547
                         connection.emuc.addDisplayNameToPresence(nickname);
1541 1548
                         connection.emuc.sendPresence();
@@ -1544,7 +1551,7 @@ function showDisplayName(videoSpanId, displayName) {
1544 1551
                     }
1545 1552
 
1546 1553
                     if (!$('#localDisplayName').is(":visible")) {
1547
-                        $('#localDisplayName').html(nickname + " (me)");
1554
+                        $('#localDisplayName').text(nickname + " (me)");
1548 1555
                         $('#localDisplayName').show();
1549 1556
                         $('#editDisplayName').hide();
1550 1557
                     }

+ 11
- 3
css/videolayout_default.css 查看文件

@@ -61,7 +61,7 @@
61 61
 }
62 62
 
63 63
 #remoteVideos .videocontainer>video {
64
-    border-radius:6px;
64
+    border-radius:4px;
65 65
 }
66 66
 
67 67
 .flipVideoX {
@@ -150,14 +150,22 @@
150 150
     white-space: nowrap;
151 151
     z-index: 2;
152 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 157
 #localVideoContainer>span.displayname:hover {
158 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 169
 .videocontainer>a.displayname {
162 170
     display: inline-block;
163 171
     position: absolute;

正在加载...
取消
保存