瀏覽代碼

Separates display name and presence status. Triggers separate event for presence status.

master
paweldomas 11 年之前
父節點
當前提交
325af308f5
共有 3 個文件被更改,包括 49 次插入26 次删除
  1. 8
    1
      app.js
  2. 6
    0
      muc.js
  3. 35
    25
      videolayout.js

+ 8
- 1
app.js 查看文件

824
         VideoLayout.ensurePeerContainerExists(jid);
824
         VideoLayout.ensurePeerContainerExists(jid);
825
         VideoLayout.setDisplayName(
825
         VideoLayout.setDisplayName(
826
                 'participant_' + Strophe.getResourceFromJid(jid),
826
                 'participant_' + Strophe.getResourceFromJid(jid),
827
-                info.displayName, info.status);
827
+                info.displayName);
828
     }
828
     }
829
 
829
 
830
     if (focus !== null && info.displayName !== null) {
830
     if (focus !== null && info.displayName !== null) {
832
     }
832
     }
833
 });
833
 });
834
 
834
 
835
+$(document).bind('presence.status.muc', function (event, jid, info, pres) {
836
+
837
+    VideoLayout.setPresenceStatus(
838
+        'participant_' + Strophe.getResourceFromJid(jid), info.status);
839
+
840
+});
841
+
835
 $(document).bind('passwordrequired.muc', function (event, jid) {
842
 $(document).bind('passwordrequired.muc', function (event, jid) {
836
     console.log('on password required', jid);
843
     console.log('on password required', jid);
837
 
844
 

+ 6
- 0
muc.js 查看文件

131
         // Always trigger presence to update bindings
131
         // Always trigger presence to update bindings
132
         console.log('presence change from', from);
132
         console.log('presence change from', from);
133
         $(document).trigger('presence.muc', [from, member, pres]);
133
         $(document).trigger('presence.muc', [from, member, pres]);
134
+
135
+        // Trigger status message update
136
+        if (member.status) {
137
+            $(document).trigger('presence.status.muc', [from, member, pres]);
138
+        }
139
+
134
         return true;
140
         return true;
135
     },
141
     },
136
     onPresenceUnavailable: function (pres) {
142
     onPresenceUnavailable: function (pres) {

+ 35
- 25
videolayout.js 查看文件

323
     /**
323
     /**
324
      * Shows the display name for the given video.
324
      * Shows the display name for the given video.
325
      */
325
      */
326
-    my.setDisplayName = function(videoSpanId, displayName, statusMsg) {
326
+    my.setDisplayName = function(videoSpanId, displayName) {
327
         var nameSpan = $('#' + videoSpanId + '>span.displayname');
327
         var nameSpan = $('#' + videoSpanId + '>span.displayname');
328
         var defaultLocalDisplayName = "Me";
328
         var defaultLocalDisplayName = "Me";
329
         var defaultRemoteDisplayName = "Speaker";
329
         var defaultRemoteDisplayName = "Speaker";
330
 
330
 
331
-        var statusSpan = $('#' + videoSpanId + '>span.status');
332
-        if (!statusSpan.length)
333
-        {
334
-            //Add status span
335
-            statusSpan = document.createElement('span');
336
-            statusSpan.className = 'status';
337
-            statusSpan.id = videoSpanId + '_status';
338
-            $('#' + videoSpanId)[0].appendChild(statusSpan);
339
-
340
-            statusSpan = $('#' + videoSpanId + '>span.status');
341
-        }
342
-
343
-        // Display status
344
-        if (statusMsg && statusMsg.length)
345
-        {
346
-            $('#' + videoSpanId + '_status').text(statusMsg);
347
-            statusSpan.get(0).setAttribute("style", "display:inline-block;");
348
-        }
349
-        else
350
-        {
351
-            // Hide
352
-            statusSpan.get(0).setAttribute("style", "display:none;");
353
-        }
354
-
355
         // If we already have a display name for this video.
331
         // If we already have a display name for this video.
356
         if (nameSpan.length > 0) {
332
         if (nameSpan.length > 0) {
357
             var nameSpanElement = nameSpan.get(0);
333
             var nameSpanElement = nameSpan.get(0);
473
         }
449
         }
474
     };
450
     };
475
 
451
 
452
+    /**
453
+     * Shows the presence status message for the given video.
454
+     */
455
+    my.setPresenceStatus = function (videoSpanId, statusMsg) {
456
+
457
+        if (!$('#' + videoSpanId).length) {
458
+            // No container
459
+            return;
460
+        }
461
+
462
+        var nameSpan = $('#' + videoSpanId + '>span.displayname');
463
+
464
+        var statusSpan = $('#' + videoSpanId + '>span.status');
465
+        if (!statusSpan.length) {
466
+            //Add status span
467
+            statusSpan = document.createElement('span');
468
+            statusSpan.className = 'status';
469
+            statusSpan.id = videoSpanId + '_status';
470
+            $('#' + videoSpanId)[0].appendChild(statusSpan);
471
+
472
+            statusSpan = $('#' + videoSpanId + '>span.status');
473
+        }
474
+
475
+        // Display status
476
+        if (statusMsg && statusMsg.length) {
477
+            $('#' + videoSpanId + '_status').text(statusMsg);
478
+            statusSpan.get(0).setAttribute("style", "display:inline-block;");
479
+        }
480
+        else {
481
+            // Hide
482
+            statusSpan.get(0).setAttribute("style", "display:none;");
483
+        }
484
+    };
485
+
476
     /**
486
     /**
477
      * Shows a visual indicator for the focus of the conference.
487
      * Shows a visual indicator for the focus of the conference.
478
      * Currently if we're not the owner of the conference we obtain the focus
488
      * Currently if we're not the owner of the conference we obtain the focus

Loading…
取消
儲存