Przeglądaj źródła

fix errors reported by jshint

j8
Philipp Hancke 11 lat temu
rodzic
commit
78c8f43c3d
6 zmienionych plików z 497 dodań i 490 usunięć
  1. 247
    245
      app.js
  2. 29
    28
      chat.js
  3. 198
    195
      desktopsharing.js
  4. 1
    0
      estos_log.js
  5. 13
    12
      etherpad.js
  6. 9
    10
      util.js

+ 247
- 245
app.js Wyświetl plik

24
 var currentVideoHeight = null;
24
 var currentVideoHeight = null;
25
 /**
25
 /**
26
  * Method used to calculate large video size.
26
  * Method used to calculate large video size.
27
- * @type {function()}
27
+ * @type {function ()}
28
  */
28
  */
29
 var getVideoSize;
29
 var getVideoSize;
30
 /**
30
 /**
31
  * Method used to get large video position.
31
  * Method used to get large video position.
32
- * @type {function()}
32
+ * @type {function ()}
33
  */
33
  */
34
 var getVideoPosition;
34
 var getVideoPosition;
35
 
35
 
40
     if (RTC === null) {
40
     if (RTC === null) {
41
         window.location.href = 'webrtcrequired.html';
41
         window.location.href = 'webrtcrequired.html';
42
         return;
42
         return;
43
+        /*
43
     } else if (RTC.browser !== 'chrome') {
44
     } else if (RTC.browser !== 'chrome') {
44
         window.location.href = 'chromeonly.html';
45
         window.location.href = 'chromeonly.html';
45
         return;
46
         return;
47
+        */
46
     }
48
     }
47
 
49
 
48
     connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
50
     connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
69
             if (config.useStunTurn) {
71
             if (config.useStunTurn) {
70
                 connection.jingle.getStunAndTurnCredentials();
72
                 connection.jingle.getStunAndTurnCredentials();
71
             }
73
             }
72
-            obtainAudioAndVideoPermissions(function(){
73
-                getUserMediaWithConstraints( ['audio'], audioStreamReady,
74
-                    function(error){
74
+            obtainAudioAndVideoPermissions(function () {
75
+                getUserMediaWithConstraints(['audio'], audioStreamReady,
76
+                    function (error) {
75
                         console.error('failed to obtain audio stream - stop', error);
77
                         console.error('failed to obtain audio stream - stop', error);
76
                     });
78
                     });
77
             });
79
             });
88
  * We first ask for audio and video combined stream in order to get permissions and not to ask twice.
90
  * We first ask for audio and video combined stream in order to get permissions and not to ask twice.
89
  * Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
91
  * Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
90
  */
92
  */
91
-function obtainAudioAndVideoPermissions(callback){
93
+function obtainAudioAndVideoPermissions(callback) {
92
     // This makes sense only on https sites otherwise we'll be asked for permissions every time
94
     // This makes sense only on https sites otherwise we'll be asked for permissions every time
93
-    if(location.protocol !== 'https:') {
95
+    if (location.protocol !== 'https:') {
94
         callback();
96
         callback();
95
         return;
97
         return;
96
     }
98
     }
97
     // Get AV
99
     // Get AV
98
     getUserMediaWithConstraints(
100
     getUserMediaWithConstraints(
99
         ['audio', 'video'],
101
         ['audio', 'video'],
100
-        function(avStream) {
102
+        function (avStream) {
101
             avStream.stop();
103
             avStream.stop();
102
             callback();
104
             callback();
103
         },
105
         },
104
-        function(error){
106
+        function (error) {
105
             console.error('failed to obtain audio/video stream - stop', error);
107
             console.error('failed to obtain audio/video stream - stop', error);
106
         });
108
         });
107
 }
109
 }
110
 
112
 
111
     change_local_audio(stream);
113
     change_local_audio(stream);
112
 
114
 
113
-    if(RTC.browser !== 'firefox') {
114
-        getUserMediaWithConstraints( ['video'], videoStreamReady, videoStreamFailed, config.resolution || '360' );
115
+    if (RTC.browser !== 'firefox') {
116
+        getUserMediaWithConstraints(['video'], videoStreamReady, videoStreamFailed, config.resolution || '360');
115
     } else {
117
     } else {
116
         doJoin();
118
         doJoin();
117
     }
119
     }
169
             roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
171
             roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
170
         }
172
         }
171
     } else {
173
     } else {
172
-        roomjid += '/' + Strophe.getNodeFromJid(connection.jid).substr(0,8);
174
+        roomjid += '/' + Strophe.getNodeFromJid(connection.jid).substr(0, 8);
173
     }
175
     }
174
     connection.emuc.doJoin(roomjid);
176
     connection.emuc.doJoin(roomjid);
175
 }
177
 }
186
     connection.jingle.localVideo = stream;
188
     connection.jingle.localVideo = stream;
187
 
189
 
188
     var localVideo = document.createElement('video');
190
     var localVideo = document.createElement('video');
189
-    localVideo.id = 'localVideo_'+stream.id;
191
+    localVideo.id = 'localVideo_' + stream.id;
190
     localVideo.autoplay = true;
192
     localVideo.autoplay = true;
191
     localVideo.volume = 0; // is it required if audio is separated ?
193
     localVideo.volume = 0; // is it required if audio is separated ?
192
     localVideo.oncontextmenu = function () { return false; };
194
     localVideo.oncontextmenu = function () { return false; };
196
 
198
 
197
     var localVideoSelector = $('#' + localVideo.id);
199
     var localVideoSelector = $('#' + localVideo.id);
198
     // Add click handler
200
     // Add click handler
199
-    localVideoSelector.click(function () { handleVideoThumbClicked(localVideo.src); } );
201
+    localVideoSelector.click(function () {
202
+        handleVideoThumbClicked(localVideo.src);
203
+    });
200
     // Add stream ended handler
204
     // Add stream ended handler
201
     stream.onended = function () {
205
     stream.onended = function () {
202
         localVideoContainer.removeChild(localVideo);
206
         localVideoContainer.removeChild(localVideo);
204
     };
208
     };
205
     // Flip video x axis if needed
209
     // Flip video x axis if needed
206
     flipXLocalVideo = flipX;
210
     flipXLocalVideo = flipX;
207
-    if(flipX) {
211
+    if (flipX) {
208
         localVideoSelector.addClass("flipVideoX");
212
         localVideoSelector.addClass("flipVideoX");
209
     }
213
     }
210
     // Attach WebRTC stream
214
     // Attach WebRTC stream
216
 
220
 
217
 $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
221
 $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
218
     function waitForRemoteVideo(selector, sid, ssrc) {
222
     function waitForRemoteVideo(selector, sid, ssrc) {
219
-        if(selector.removed) {
223
+        if (selector.removed) {
220
             console.warn("media removed before had started", selector);
224
             console.warn("media removed before had started", selector);
221
             return;
225
             return;
222
         }
226
         }
230
 
234
 
231
             // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
235
             // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
232
             //        in order to get rid of too many maps
236
             //        in order to get rid of too many maps
233
-            if(ssrc) {
237
+            if (ssrc) {
234
                 videoSrcToSsrc[sel.attr('src')] = ssrc;
238
                 videoSrcToSsrc[sel.attr('src')] = ssrc;
235
             } else {
239
             } else {
236
                 console.warn("No ssrc given for video", sel);
240
                 console.warn("No ssrc given for video", sel);
250
         var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
254
         var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
251
         ssrclines = ssrclines.filter(function (line) {
255
         ssrclines = ssrclines.filter(function (line) {
252
             return line.indexOf('mslabel:' + data.stream.label) !== -1;
256
             return line.indexOf('mslabel:' + data.stream.label) !== -1;
253
-                                     });
257
+        });
254
         if (ssrclines.length) {
258
         if (ssrclines.length) {
255
             thessrc = ssrclines[0].substring(7).split(' ')[0];
259
             thessrc = ssrclines[0].substring(7).split(' ')[0];
256
             // ok to overwrite the one from focus? might save work in colibri.js
260
             // ok to overwrite the one from focus? might save work in colibri.js
305
     sel.hide();
309
     sel.hide();
306
     RTC.attachMediaStream(sel, data.stream);
310
     RTC.attachMediaStream(sel, data.stream);
307
 
311
 
308
-    if(isVideo) {
312
+    if (isVideo) {
309
         waitForRemoteVideo(sel, sid, thessrc);
313
         waitForRemoteVideo(sel, sid, thessrc);
310
     }
314
     }
311
 
315
 
316
         sel.removed = true;
320
         sel.removed = true;
317
         sel.remove();
321
         sel.remove();
318
 
322
 
319
-        var audioCount = $('#'+container.id+'>audio').length;
320
-        var videoCount = $('#'+container.id+'>video').length;
321
-        if(!audioCount && !videoCount) {
323
+        var audioCount = $('#' + container.id + '>audio').length;
324
+        var videoCount = $('#' + container.id + '>video').length;
325
+        if (!audioCount && !videoCount) {
322
             console.log("Remove whole user");
326
             console.log("Remove whole user");
323
             // Remove whole container
327
             // Remove whole container
324
             container.remove();
328
             container.remove();
330
     };
334
     };
331
 
335
 
332
     // Add click handler
336
     // Add click handler
333
-    sel.click(function () { handleVideoThumbClicked(vid.src); });
337
+    sel.click(function () {
338
+        handleVideoThumbClicked(vid.src);
339
+    });
334
 
340
 
335
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
341
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
336
-    if (isVideo
337
-        && data.peerjid && sess.peerjid === data.peerjid &&
338
-           data.stream.getVideoTracks().length === 0 &&
339
-           connection.jingle.localVideo.getVideoTracks().length > 0) {
340
-        window.setTimeout(function() {
342
+    if (isVideo &&
343
+        data.peerjid && sess.peerjid === data.peerjid &&
344
+        data.stream.getVideoTracks().length === 0 &&
345
+        connection.jingle.localVideo.getVideoTracks().length > 0) {
346
+        //
347
+        window.setTimeout(function () {
341
             sendKeyframe(sess.peerconnection);
348
             sendKeyframe(sess.peerconnection);
342
         }, 3000);
349
         }, 3000);
343
     }
350
     }
361
  * Checks if removed video is currently displayed and tries to display another one instead.
368
  * Checks if removed video is currently displayed and tries to display another one instead.
362
  * @param removedVideoSrc src stream identifier of the video.
369
  * @param removedVideoSrc src stream identifier of the video.
363
  */
370
  */
364
-function checkChangeLargeVideo(removedVideoSrc){
371
+function checkChangeLargeVideo(removedVideoSrc) {
365
     if (removedVideoSrc === $('#largeVideo').attr('src')) {
372
     if (removedVideoSrc === $('#largeVideo').attr('src')) {
366
         // this is currently displayed as large
373
         // this is currently displayed as large
367
         // pick the last visible video in the row
374
         // pick the last visible video in the row
368
         // if nobody else is left, this picks the local video
375
         // if nobody else is left, this picks the local video
369
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
376
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
370
 
377
 
371
-        if(!pick) {
378
+        if (!pick) {
372
             console.info("Last visible video no longer exists");
379
             console.info("Last visible video no longer exists");
373
             pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
380
             pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
374
-            if(!pick) {
381
+            if (!pick) {
375
                 // Try local video
382
                 // Try local video
376
                 console.info("Fallback to local video...");
383
                 console.info("Fallback to local video...");
377
                 pick = $('#remoteVideos>span>span>video').get(0);
384
                 pick = $('#remoteVideos>span>span>video').get(0);
396
         function () {
403
         function () {
397
             pc.createAnswer(
404
             pc.createAnswer(
398
                 function (modifiedAnswer) {
405
                 function (modifiedAnswer) {
399
-                    pc.setLocalDescription(modifiedAnswer,
406
+                    pc.setLocalDescription(
407
+                        modifiedAnswer,
400
                         function () {
408
                         function () {
409
+                            // noop
401
                         },
410
                         },
402
                         function (error) {
411
                         function (error) {
403
                             console.log('triggerKeyframe setLocalDescription failed', error);
412
                             console.log('triggerKeyframe setLocalDescription failed', error);
436
                         function () {
445
                         function () {
437
                             console.log('mute SLD ok');
446
                             console.log('mute SLD ok');
438
                         },
447
                         },
439
-                        function(error) {
448
+                        function (error) {
440
                             console.log('mute SLD error');
449
                             console.log('mute SLD error');
441
                         }
450
                         }
442
                     );
451
                     );
497
             newssrcs[type] = ssrc;
506
             newssrcs[type] = ssrc;
498
 
507
 
499
             directions[type] = (
508
             directions[type] = (
500
-                SDPUtil.find_line(media, 'a=sendrecv')
501
-                || SDPUtil.find_line(media, 'a=recvonly')
502
-                || SDPUtil.find_line('a=sendonly')
503
-                || SDPUtil.find_line('a=inactive')
504
-                || 'a=sendrecv' ).substr(2);
509
+                SDPUtil.find_line(media, 'a=sendrecv') ||
510
+                SDPUtil.find_line(media, 'a=recvonly') ||
511
+                SDPUtil.find_line('a=sendonly') ||
512
+                SDPUtil.find_line('a=inactive') ||
513
+                'a=sendrecv').substr(2);
505
         }
514
         }
506
     });
515
     });
507
     console.log('new ssrcs', newssrcs);
516
     console.log('new ssrcs', newssrcs);
513
         i++;
522
         i++;
514
         var type = mtype;
523
         var type = mtype;
515
         // Change video type to screen
524
         // Change video type to screen
516
-        if(mtype === 'video' && isUsingScreenStream) {
525
+        if (mtype === 'video' && isUsingScreenStream) {
517
             type = 'screen';
526
             type = 'screen';
518
         }
527
         }
519
         connection.emuc.addMediaToPresence(i, type, newssrcs[mtype], directions[mtype]);
528
         connection.emuc.addMediaToPresence(i, type, newssrcs[mtype], directions[mtype]);
603
 $(document).bind('presence.muc', function (event, jid, info, pres) {
612
 $(document).bind('presence.muc', function (event, jid, info, pres) {
604
 
613
 
605
     // Remove old ssrcs coming from the jid
614
     // Remove old ssrcs coming from the jid
606
-    Object.keys(ssrc2jid).forEach(function(ssrc){
607
-       if(ssrc2jid[ssrc] == jid){
608
-           delete ssrc2jid[ssrc];
609
-       }
610
-       if(ssrc2videoType == jid){
611
-           delete  ssrc2videoType[ssrc];
612
-       }
615
+    Object.keys(ssrc2jid).forEach(function (ssrc) {
616
+        if (ssrc2jid[ssrc] == jid) {
617
+            delete ssrc2jid[ssrc];
618
+        }
619
+        if (ssrc2videoType == jid) {
620
+            delete ssrc2videoType[ssrc];
621
+        }
613
     });
622
     });
614
 
623
 
615
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
624
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
623
         // might need to update the direction if participant just went from sendrecv to recvonly
632
         // might need to update the direction if participant just went from sendrecv to recvonly
624
         if (type === 'video' || type === 'screen') {
633
         if (type === 'video' || type === 'screen') {
625
             var el = $('#participant_'  + Strophe.getResourceFromJid(jid) + '>video');
634
             var el = $('#participant_'  + Strophe.getResourceFromJid(jid) + '>video');
626
-            switch(ssrc.getAttribute('direction')) {
635
+            switch (ssrc.getAttribute('direction')) {
627
             case 'sendrecv':
636
             case 'sendrecv':
628
                 el.show();
637
                 el.show();
629
                 break;
638
                 break;
650
     console.log('on password required', jid);
659
     console.log('on password required', jid);
651
 
660
 
652
     $.prompt('<h2>Password required</h2>' +
661
     $.prompt('<h2>Password required</h2>' +
653
-            '<input id="lockKey" type="text" placeholder="shared key" autofocus>',
654
-             {
655
-                persistent: true,
656
-                buttons: { "Ok": true , "Cancel": false},
657
-                defaultButton: 1,
658
-                loaded: function(event) {
659
-                    document.getElementById('lockKey').focus();
660
-                },
661
-                submit: function(e,v,m,f){
662
-                    if(v)
663
-                    {
664
-                        var lockKey = document.getElementById('lockKey');
662
+        '<input id="lockKey" type="text" placeholder="shared key" autofocus>', {
663
+        persistent: true,
664
+        buttons: { "Ok": true, "Cancel": false},
665
+        defaultButton: 1,
666
+        loaded: function (event) {
667
+            document.getElementById('lockKey').focus();
668
+        },
669
+        submit: function (e, v, m, f) {
670
+            if (v) {
671
+                var lockKey = document.getElementById('lockKey');
665
 
672
 
666
-                        if (lockKey.value !== null)
667
-                        {
668
-                            setSharedKey(lockKey.value);
669
-                            connection.emuc.doJoin(jid, lockKey.value);
670
-                        }
671
-                    }
673
+                if (lockKey.value !== null) {
674
+                    setSharedKey(lockKey.value);
675
+                    connection.emuc.doJoin(jid, lockKey.value);
672
                 }
676
                 }
673
-            });
677
+            }
678
+        }
679
+    });
674
 });
680
 });
675
 
681
 
676
 $(document).bind('audiomuted.muc', function (event, jid, isMuted) {
682
 $(document).bind('audiomuted.muc', function (event, jid, isMuted) {
739
  * @param videoSrc eg. blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
745
  * @param videoSrc eg. blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
740
  * @returns {boolean}
746
  * @returns {boolean}
741
  */
747
  */
742
-function isVideoSrcDesktop(videoSrc){
748
+function isVideoSrcDesktop(videoSrc) {
743
     // FIXME: fix this mapping mess...
749
     // FIXME: fix this mapping mess...
744
     // figure out if large video is desktop stream or just a camera
750
     // figure out if large video is desktop stream or just a camera
745
     var isDesktop = false;
751
     var isDesktop = false;
746
-    if(localVideoSrc === videoSrc) {
752
+    if (localVideoSrc === videoSrc) {
747
         // local video
753
         // local video
748
         isDesktop = isUsingScreenStream;
754
         isDesktop = isUsingScreenStream;
749
     } else {
755
     } else {
750
         // Do we have associations...
756
         // Do we have associations...
751
         var videoSsrc = videoSrcToSsrc[videoSrc];
757
         var videoSsrc = videoSrcToSsrc[videoSrc];
752
-        if(videoSsrc) {
758
+        if (videoSsrc) {
753
             var videoType = ssrc2videoType[videoSsrc];
759
             var videoType = ssrc2videoType[videoSsrc];
754
-            if(videoType) {
760
+            if (videoType) {
755
                 // Finally there...
761
                 // Finally there...
756
                 isDesktop = videoType === 'screen';
762
                 isDesktop = videoType === 'screen';
757
             } else {
763
             } else {
769
  */
775
  */
770
 function setLargeVideoVisible(isVisible) {
776
 function setLargeVideoVisible(isVisible) {
771
     if (isVisible) {
777
     if (isVisible) {
772
-        $('#largeVideo').css({visibility:'visible'});
773
-        $('.watermark').css({visibility:'visible'});
778
+        $('#largeVideo').css({visibility: 'visible'});
779
+        $('.watermark').css({visibility: 'visible'});
774
     }
780
     }
775
     else {
781
     else {
776
-        $('#largeVideo').css({visibility:'hidden'});
777
-        $('.watermark').css({visibility:'hidden'});
782
+        $('#largeVideo').css({visibility: 'hidden'});
783
+        $('.watermark').css({visibility: 'hidden'});
778
     }
784
     }
779
 }
785
 }
780
 
786
 
789
     var sess = getConferenceHandler();
795
     var sess = getConferenceHandler();
790
     if (sess) {
796
     if (sess) {
791
         sess.toggleVideoMute(
797
         sess.toggleVideoMute(
792
-            function(isMuted){
793
-                if(isMuted) {
798
+            function (isMuted) {
799
+                if (isMuted) {
794
                     $('#video').removeClass("icon-camera");
800
                     $('#video').removeClass("icon-camera");
795
                     $('#video').addClass("icon-camera icon-camera-disabled");
801
                     $('#video').addClass("icon-camera icon-camera-disabled");
796
                 } else {
802
                 } else {
801
         );
807
         );
802
     }
808
     }
803
 
809
 
804
-    var sess = focus || activecall;
810
+    sess = focus || activecall;
805
     if (!sess) {
811
     if (!sess) {
806
         return;
812
         return;
807
     }
813
     }
835
  * @param videoWidth the stream video width
841
  * @param videoWidth the stream video width
836
  * @param videoHeight the stream video height
842
  * @param videoHeight the stream video height
837
  */
843
  */
838
-var positionLarge = function(videoWidth, videoHeight) {
844
+var positionLarge = function (videoWidth, videoHeight) {
839
     var videoSpaceWidth = $('#videospace').width();
845
     var videoSpaceWidth = $('#videospace').width();
840
     var videoSpaceHeight = window.innerHeight;
846
     var videoSpaceHeight = window.innerHeight;
841
 
847
 
842
-    var videoSize = getVideoSize(   videoWidth,
843
-                                    videoHeight,
844
-                                    videoSpaceWidth,
845
-                                    videoSpaceHeight);
848
+    var videoSize = getVideoSize(videoWidth,
849
+                                 videoHeight,
850
+                                 videoSpaceWidth,
851
+                                 videoSpaceHeight);
846
 
852
 
847
     var largeVideoWidth = videoSize[0];
853
     var largeVideoWidth = videoSize[0];
848
     var largeVideoHeight = videoSize[1];
854
     var largeVideoHeight = videoSize[1];
849
 
855
 
850
-    var videoPosition = getVideoPosition(   largeVideoWidth,
851
-                                            largeVideoHeight,
852
-                                            videoSpaceWidth,
853
-                                            videoSpaceHeight);
856
+    var videoPosition = getVideoPosition(largeVideoWidth,
857
+                                         largeVideoHeight,
858
+                                         videoSpaceWidth,
859
+                                         videoSpaceHeight);
854
 
860
 
855
     var horizontalIndent = videoPosition[0];
861
     var horizontalIndent = videoPosition[0];
856
     var verticalIndent = videoPosition[1];
862
     var verticalIndent = videoPosition[1];
857
 
863
 
858
-    positionVideo(  $('#largeVideo'),
859
-                    largeVideoWidth,
860
-                    largeVideoHeight,
861
-                    horizontalIndent, verticalIndent);
864
+    positionVideo($('#largeVideo'),
865
+                  largeVideoWidth,
866
+                  largeVideoHeight,
867
+                  horizontalIndent, verticalIndent);
862
 };
868
 };
863
 
869
 
864
 /**
870
 /**
868
  * @return an array with 2 elements, the horizontal indent and the vertical
874
  * @return an array with 2 elements, the horizontal indent and the vertical
869
  * indent
875
  * indent
870
  */
876
  */
871
-function getCameraVideoPosition(   videoWidth,
872
-                                   videoHeight,
873
-                                   videoSpaceWidth,
874
-                                   videoSpaceHeight) {
877
+function getCameraVideoPosition(videoWidth,
878
+                                videoHeight,
879
+                                videoSpaceWidth,
880
+                                videoSpaceHeight) {
875
     // Parent height isn't completely calculated when we position the video in
881
     // Parent height isn't completely calculated when we position the video in
876
     // full screen mode and this is why we use the screen height in this case.
882
     // full screen mode and this is why we use the screen height in this case.
877
     // Need to think it further at some point and implement it properly.
883
     // Need to think it further at some point and implement it properly.
878
-    var isFullScreen = document.fullScreen
879
-                        || document.mozFullScreen
880
-                        || document.webkitIsFullScreen; 
884
+    var isFullScreen = document.fullScreen ||
885
+            document.mozFullScreen ||
886
+            document.webkitIsFullScreen;
881
     if (isFullScreen)
887
     if (isFullScreen)
882
         videoSpaceHeight = window.innerHeight;
888
         videoSpaceHeight = window.innerHeight;
883
 
889
 
884
-    var horizontalIndent = (videoSpaceWidth - videoWidth)/2;
885
-    var verticalIndent = (videoSpaceHeight - videoHeight)/2;
890
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
891
+    var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
886
 
892
 
887
     return [horizontalIndent, verticalIndent];
893
     return [horizontalIndent, verticalIndent];
888
 }
894
 }
894
  * @return an array with 2 elements, the horizontal indent and the vertical
900
  * @return an array with 2 elements, the horizontal indent and the vertical
895
  * indent
901
  * indent
896
  */
902
  */
897
-function getDesktopVideoPosition(  videoWidth,
898
-                                   videoHeight,
899
-                                   videoSpaceWidth,
900
-                                   videoSpaceHeight) {
903
+function getDesktopVideoPosition(videoWidth,
904
+                                 videoHeight,
905
+                                 videoSpaceWidth,
906
+                                 videoSpaceHeight) {
901
 
907
 
902
-    var horizontalIndent = (videoSpaceWidth - videoWidth)/2;
908
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
903
 
909
 
904
     var verticalIndent = 0;// Top aligned
910
     var verticalIndent = 0;// Top aligned
905
 
911
 
928
 
934
 
929
     if (availableWidth / aspectRatio < videoSpaceHeight) {
935
     if (availableWidth / aspectRatio < videoSpaceHeight) {
930
         availableHeight = videoSpaceHeight;
936
         availableHeight = videoSpaceHeight;
931
-        availableWidth = availableHeight*aspectRatio;
937
+        availableWidth = availableHeight * aspectRatio;
932
     }
938
     }
933
 
939
 
934
-    if (availableHeight*aspectRatio < videoSpaceWidth) {
940
+    if (availableHeight * aspectRatio < videoSpaceWidth) {
935
         availableWidth = videoSpaceWidth;
941
         availableWidth = videoSpaceWidth;
936
         availableHeight = availableWidth / aspectRatio;
942
         availableHeight = availableWidth / aspectRatio;
937
     }
943
     }
945
  *
951
  *
946
  * @return an array with 2 elements, the video width and the video height
952
  * @return an array with 2 elements, the video width and the video height
947
  */
953
  */
948
-function getDesktopVideoSize( videoWidth,
949
-                              videoHeight,
950
-                              videoSpaceWidth,
951
-                              videoSpaceHeight )
952
-{
954
+function getDesktopVideoSize(videoWidth,
955
+                             videoHeight,
956
+                             videoSpaceWidth,
957
+                             videoSpaceHeight) {
953
     if (!videoWidth)
958
     if (!videoWidth)
954
         videoWidth = currentVideoWidth;
959
         videoWidth = currentVideoWidth;
955
     if (!videoHeight)
960
     if (!videoHeight)
965
     if (availableWidth / aspectRatio >= videoSpaceHeight)
970
     if (availableWidth / aspectRatio >= videoSpaceHeight)
966
     {
971
     {
967
         availableHeight = videoSpaceHeight;
972
         availableHeight = videoSpaceHeight;
968
-        availableWidth = availableHeight*aspectRatio;
973
+        availableWidth = availableHeight * aspectRatio;
969
     }
974
     }
970
 
975
 
971
-    if (availableHeight*aspectRatio >= videoSpaceWidth)
976
+    if (availableHeight * aspectRatio >= videoSpaceWidth)
972
     {
977
     {
973
         availableWidth = videoSpaceWidth;
978
         availableWidth = videoSpaceWidth;
974
         availableHeight = availableWidth / aspectRatio;
979
         availableHeight = availableWidth / aspectRatio;
986
  * @param horizontalIndent the left and right indent
991
  * @param horizontalIndent the left and right indent
987
  * @param verticalIndent the top and bottom indent
992
  * @param verticalIndent the top and bottom indent
988
  */
993
  */
989
-function positionVideo( video,
990
-                        width,
991
-                        height,
992
-                        horizontalIndent,
993
-                        verticalIndent) {
994
+function positionVideo(video,
995
+                       width,
996
+                       height,
997
+                       horizontalIndent,
998
+                       verticalIndent) {
994
     video.width(width);
999
     video.width(width);
995
     video.height(height);
1000
     video.height(height);
996
     video.css({  top: verticalIndent + 'px',
1001
     video.css({  top: verticalIndent + 'px',
1014
     resizeThumbnails();
1019
     resizeThumbnails();
1015
 };
1020
 };
1016
 
1021
 
1017
-var calculateThumbnailSize = function() {
1022
+var calculateThumbnailSize = function () {
1018
  // Calculate the available height, which is the inner window height minus
1023
  // Calculate the available height, which is the inner window height minus
1019
     // 39px for the header minus 2px for the delimiter lines on the top and
1024
     // 39px for the header minus 2px for the delimiter lines on the top and
1020
     // bottom of the large video, minus the 36px space inside the remoteVideos
1025
     // bottom of the large video, minus the 36px space inside the remoteVideos
1056
     // Set default desktop sharing method
1061
     // Set default desktop sharing method
1057
     setDesktopSharing(config.desktopSharing);
1062
     setDesktopSharing(config.desktopSharing);
1058
     // Initialize Chrome extension inline installs
1063
     // Initialize Chrome extension inline installs
1059
-    if(config.chromeExtensionId)
1060
-    {
1064
+    if (config.chromeExtensionId) {
1061
         initInlineInstalls();
1065
         initInlineInstalls();
1062
     }
1066
     }
1063
 
1067
 
1072
     });
1076
     });
1073
     // Listen for large video size updates
1077
     // Listen for large video size updates
1074
     document.getElementById('largeVideo')
1078
     document.getElementById('largeVideo')
1075
-        .addEventListener('loadedmetadata', function(e){
1079
+        .addEventListener('loadedmetadata', function (e) {
1076
             currentVideoWidth = this.videoWidth;
1080
             currentVideoWidth = this.videoWidth;
1077
             currentVideoHeight = this.videoHeight;
1081
             currentVideoHeight = this.videoHeight;
1078
             positionLarge(currentVideoWidth, currentVideoHeight);
1082
             positionLarge(currentVideoWidth, currentVideoHeight);
1114
 
1118
 
1115
 function disposeConference() {
1119
 function disposeConference() {
1116
     var handler = getConferenceHandler();
1120
     var handler = getConferenceHandler();
1117
-    if(handler && handler.peerconnection) {
1121
+    if (handler && handler.peerconnection) {
1118
         // FIXME: probably removing streams is not required and close() should be enough
1122
         // FIXME: probably removing streams is not required and close() should be enough
1119
-        if(connection.jingle.localAudio) {
1123
+        if (connection.jingle.localAudio) {
1120
             handler.peerconnection.removeStream(connection.jingle.localAudio);
1124
             handler.peerconnection.removeStream(connection.jingle.localAudio);
1121
         }
1125
         }
1122
-        if(connection.jingle.localVideo) {
1126
+        if (connection.jingle.localVideo) {
1123
             handler.peerconnection.removeStream(connection.jingle.localVideo);
1127
             handler.peerconnection.removeStream(connection.jingle.localVideo);
1124
         }
1128
         }
1125
         handler.peerconnection.close();
1129
         handler.peerconnection.close();
1128
     activecall = null;
1132
     activecall = null;
1129
 }
1133
 }
1130
 
1134
 
1131
-function dump(elem, filename){
1135
+function dump(elem, filename) {
1132
     elem = elem.parentNode;
1136
     elem = elem.parentNode;
1133
     elem.download = filename || 'meetlog.json';
1137
     elem.download = filename || 'meetlog.json';
1134
     elem.href = 'data:application/json;charset=utf-8,\n';
1138
     elem.href = 'data:application/json;charset=utf-8,\n';
1141
                 data["jingle_" + session.sid] = {
1145
                 data["jingle_" + session.sid] = {
1142
                     updateLog: session.peerconnection.updateLog,
1146
                     updateLog: session.peerconnection.updateLog,
1143
                     stats: session.peerconnection.stats,
1147
                     stats: session.peerconnection.stats,
1144
-                    url: window.location.href}
1145
-                ;
1148
+                    url: window.location.href
1149
+                };
1146
             }
1150
             }
1147
         });
1151
         });
1148
     }
1152
     }
1173
     if (focus === null) {
1177
     if (focus === null) {
1174
         if (sharedKey)
1178
         if (sharedKey)
1175
             $.prompt("This conversation is currently protected by a shared secret key.",
1179
             $.prompt("This conversation is currently protected by a shared secret key.",
1176
-                 {
1177
-                 title: "Secrect key",
1178
-                 persistent: false
1179
-                 });
1180
+                {
1181
+                    title: "Secrect key",
1182
+                    persistent: false
1183
+                }
1184
+            );
1180
         else
1185
         else
1181
             $.prompt("This conversation isn't currently protected by a secret key. Only the owner of the conference could set a shared key.",
1186
             $.prompt("This conversation isn't currently protected by a secret key. Only the owner of the conference could set a shared key.",
1182
-                     {
1183
-                     title: "Secrect key",
1184
-                     persistent: false
1185
-                     });
1186
-    }
1187
-    else {
1188
-        if (sharedKey)
1187
+                {
1188
+                    title: "Secrect key",
1189
+                    persistent: false
1190
+                }
1191
+            );
1192
+    } else {
1193
+        if (sharedKey) {
1189
             $.prompt("Are you sure you would like to remove your secret key?",
1194
             $.prompt("Are you sure you would like to remove your secret key?",
1190
-                     {
1191
-                     title: "Remove secrect key",
1192
-                     persistent: false,
1193
-                     buttons: { "Remove": true, "Cancel": false},
1194
-                     defaultButton: 1,
1195
-                     submit: function(e,v,m,f){
1196
-                     if(v)
1197
-                     {
1198
-                        setSharedKey('');
1199
-                        lockRoom(false);
1200
-                     }
1201
-                     }
1202
-                     });
1203
-        else
1195
+                {
1196
+                    title: "Remove secrect key",
1197
+                    persistent: false,
1198
+                    buttons: { "Remove": true, "Cancel": false},
1199
+                    defaultButton: 1,
1200
+                    submit: function (e, v, m, f) {
1201
+                        if (v) {
1202
+                            setSharedKey('');
1203
+                            lockRoom(false);
1204
+                        }
1205
+                    }
1206
+                }
1207
+            );
1208
+        } else {
1204
             $.prompt('<h2>Set a secrect key to lock your room</h2>' +
1209
             $.prompt('<h2>Set a secrect key to lock your room</h2>' +
1205
                      '<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
1210
                      '<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
1206
-                     {
1207
-                     persistent: false,
1208
-                     buttons: { "Save": true , "Cancel": false},
1209
-                     defaultButton: 1,
1210
-                     loaded: function(event) {
1211
-                     document.getElementById('lockKey').focus();
1212
-                     },
1213
-                     submit: function(e,v,m,f){
1214
-                     if(v)
1215
-                     {
1216
-                        var lockKey = document.getElementById('lockKey');
1217
-
1218
-                        if (lockKey.value)
1219
-                        {
1220
-                            setSharedKey(Util.escapeHtml(lockKey.value));
1221
-                            lockRoom(true);
1211
+                {
1212
+                    persistent: false,
1213
+                    buttons: { "Save": true, "Cancel": false},
1214
+                    defaultButton: 1,
1215
+                    loaded: function (event) {
1216
+                        document.getElementById('lockKey').focus();
1217
+                    },
1218
+                    submit: function (e, v, m, f) {
1219
+                        if (v) {
1220
+                            var lockKey = document.getElementById('lockKey');
1221
+
1222
+                            if (lockKey.value) {
1223
+                                setSharedKey(Util.escapeHtml(lockKey.value));
1224
+                                lockRoom(true);
1225
+                            }
1222
                         }
1226
                         }
1223
-                     }
1227
+                    }
1224
                 }
1228
                 }
1225
-            });
1229
+            );
1230
+        }
1226
     }
1231
     }
1227
 }
1232
 }
1228
 
1233
 
1230
  * Opens the invite link dialog.
1235
  * Opens the invite link dialog.
1231
  */
1236
  */
1232
 function openLinkDialog() {
1237
 function openLinkDialog() {
1233
-    $.prompt('<input id="inviteLinkRef" type="text" value="'
1234
-            + encodeURI(roomUrl) + '" onclick="this.select();" readonly>',
1235
-             {
1236
-             title: "Share this link with everyone you want to invite",
1237
-             persistent: false,
1238
-             buttons: { "Cancel": false},
1239
-             loaded: function(event) {
1240
-             document.getElementById('inviteLinkRef').select();
1241
-             }
1242
-             });
1238
+    $.prompt('<input id="inviteLinkRef" type="text" value="' +
1239
+        encodeURI(roomUrl) + '" onclick="this.select();" readonly>',
1240
+        {
1241
+            title: "Share this link with everyone you want to invite",
1242
+            persistent: false,
1243
+            buttons: { "Cancel": false},
1244
+            loaded: function (event) {
1245
+                document.getElementById('inviteLinkRef').select();
1246
+            }
1247
+        }
1248
+    );
1243
 }
1249
 }
1244
 
1250
 
1245
 /**
1251
 /**
1247
  */
1253
  */
1248
 function openSettingsDialog() {
1254
 function openSettingsDialog() {
1249
     $.prompt('<h2>Configure your conference</h2>' +
1255
     $.prompt('<h2>Configure your conference</h2>' +
1250
-             '<input type="checkbox" id="initMuted"> Participants join muted<br/>' +
1251
-             '<input type="checkbox" id="requireNicknames"> Require nicknames<br/><br/>' +
1252
-             'Set a secrect key to lock your room: <input id="lockKey" type="text" placeholder="your shared key" autofocus>',
1253
-             {
1254
-                persistent: false,
1255
-                buttons: { "Save": true , "Cancel": false},
1256
-                defaultButton: 1,
1257
-                loaded: function(event) {
1258
-                    document.getElementById('lockKey').focus();
1259
-                },
1260
-                submit: function(e,v,m,f){
1261
-                    if(v)
1262
-                    {
1263
-                        if ($('#initMuted').is(":checked"))
1264
-                        {
1265
-                            // it is checked
1266
-                        }
1256
+        '<input type="checkbox" id="initMuted"> Participants join muted<br/>' +
1257
+        '<input type="checkbox" id="requireNicknames"> Require nicknames<br/><br/>' +
1258
+        'Set a secrect key to lock your room: <input id="lockKey" type="text" placeholder="your shared key" autofocus>',
1259
+        {
1260
+            persistent: false,
1261
+            buttons: { "Save": true, "Cancel": false},
1262
+            defaultButton: 1,
1263
+            loaded: function (event) {
1264
+                document.getElementById('lockKey').focus();
1265
+            },
1266
+            submit: function (e, v, m, f) {
1267
+                if (v) {
1268
+                    if ($('#initMuted').is(":checked")) {
1269
+                        // it is checked
1270
+                    }
1267
 
1271
 
1268
-                        if ($('#requireNicknames').is(":checked"))
1269
-                        {
1270
-                            // it is checked
1271
-                        }
1272
-             /*
1273
-                        var lockKey = document.getElementById('lockKey');
1272
+                    if ($('#requireNicknames').is(":checked")) {
1273
+                        // it is checked
1274
+                    }
1275
+                    /*
1276
+                    var lockKey = document.getElementById('lockKey');
1274
 
1277
 
1275
-                        if (lockKey.value)
1276
-                        {
1277
-                            setSharedKey(lockKey.value);
1278
-                            lockRoom(true);
1279
-                        }
1280
-              */
1278
+                    if (lockKey.value)
1279
+                    {
1280
+                        setSharedKey(lockKey.value);
1281
+                        lockRoom(true);
1281
                     }
1282
                     }
1283
+                    */
1282
                 }
1284
                 }
1283
-             });
1285
+            }
1286
+        }
1287
+    );
1284
 }
1288
 }
1285
 
1289
 
1286
 /**
1290
 /**
1312
 /**
1316
 /**
1313
  * Hides the toolbar.
1317
  * Hides the toolbar.
1314
  */
1318
  */
1315
-var hideToolbar = function() {
1319
+var hideToolbar = function () {
1316
 
1320
 
1317
     var isToolbarHover = false;
1321
     var isToolbarHover = false;
1318
-    $('#header').find('*').each(function(){
1322
+    $('#header').find('*').each(function () {
1319
         var id = $(this).attr('id');
1323
         var id = $(this).attr('id');
1320
         if ($("#" + id + ":hover").length > 0) {
1324
         if ($("#" + id + ":hover").length > 0) {
1321
             isToolbarHover = true;
1325
             isToolbarHover = true;
1418
         var session = connection.jingle.sessions[Object.keys(connection.jingle.sessions)[0]];
1422
         var session = connection.jingle.sessions[Object.keys(connection.jingle.sessions)[0]];
1419
         var focusId = 'participant_' + Strophe.getResourceFromJid(session.peerjid);
1423
         var focusId = 'participant_' + Strophe.getResourceFromJid(session.peerjid);
1420
         var focusContainer = document.getElementById(focusId);
1424
         var focusContainer = document.getElementById(focusId);
1421
-        if(!focusContainer) {
1425
+        if (!focusContainer) {
1422
             console.error("No focus container!");
1426
             console.error("No focus container!");
1423
             return;
1427
             return;
1424
         }
1428
         }
1438
  * Checks if container for participant identified by given peerJid exists in the document and creates it eventually.
1442
  * Checks if container for participant identified by given peerJid exists in the document and creates it eventually.
1439
  * @param peerJid peer Jid to check.
1443
  * @param peerJid peer Jid to check.
1440
  */
1444
  */
1441
-function ensurePeerContainerExists(peerJid){
1442
-
1445
+function ensurePeerContainerExists(peerJid) {
1443
     var peerResource = Strophe.getResourceFromJid(peerJid);
1446
     var peerResource = Strophe.getResourceFromJid(peerJid);
1444
     var videoSpanId = 'participant_' + peerResource;
1447
     var videoSpanId = 'participant_' + peerResource;
1445
 
1448
 
1446
-    if($('#'+videoSpanId).length > 0) {
1449
+    if ($('#' + videoSpanId).length > 0) {
1447
         return;
1450
         return;
1448
     }
1451
     }
1449
 
1452
 
1482
 function toggleFullScreen() {
1485
 function toggleFullScreen() {
1483
     var fsElement = document.documentElement;
1486
     var fsElement = document.documentElement;
1484
 
1487
 
1485
-    if (!document.mozFullScreen && !document.webkitIsFullScreen){
1486
-
1488
+    if (!document.mozFullScreen && !document.webkitIsFullScreen) {
1487
         //Enter Full Screen
1489
         //Enter Full Screen
1488
         if (fsElement.mozRequestFullScreen) {
1490
         if (fsElement.mozRequestFullScreen) {
1489
             fsElement.mozRequestFullScreen();
1491
             fsElement.mozRequestFullScreen();
1511
     if (nameSpan.length > 0) {
1513
     if (nameSpan.length > 0) {
1512
         var nameSpanElement = nameSpan.get(0);
1514
         var nameSpanElement = nameSpan.get(0);
1513
 
1515
 
1514
-        if (nameSpanElement.id === 'localDisplayName'
1515
-            && $('#localDisplayName').text() !== displayName)
1516
+        if (nameSpanElement.id === 'localDisplayName' &&
1517
+            $('#localDisplayName').text() !== displayName) {
1516
             $('#localDisplayName').text(displayName);
1518
             $('#localDisplayName').text(displayName);
1517
-        else
1519
+        } else {
1518
             $('#' + videoSpanId + '_name').text(displayName);
1520
             $('#' + videoSpanId + '_name').text(displayName);
1519
-    }
1520
-    else {
1521
+        }
1522
+    } else {
1521
         var editButton = null;
1523
         var editButton = null;
1522
 
1524
 
1523
         if (videoSpanId === 'localVideoContainer') {
1525
         if (videoSpanId === 'localVideoContainer') {
1532
 
1534
 
1533
         if (!editButton) {
1535
         if (!editButton) {
1534
             nameSpan.id = videoSpanId + '_name';
1536
             nameSpan.id = videoSpanId + '_name';
1535
-        }
1536
-        else {
1537
+        } else {
1537
             nameSpan.id = 'localDisplayName';
1538
             nameSpan.id = 'localDisplayName';
1538
             $('#' + videoSpanId)[0].appendChild(editButton);
1539
             $('#' + videoSpanId)[0].appendChild(editButton);
1539
 
1540
 
1541
             editableText.className = 'displayname';
1542
             editableText.className = 'displayname';
1542
             editableText.id = 'editDisplayName';
1543
             editableText.id = 'editDisplayName';
1543
 
1544
 
1544
-            if (displayName.length)
1545
-                editableText.value
1546
-                    = displayName.substring(0, displayName.indexOf(' (me)'));
1545
+            if (displayName.length) {
1546
+                editableText.value = displayName.substring(0, displayName.indexOf(' (me)'));
1547
+            }
1547
 
1548
 
1548
             editableText.setAttribute('style', 'display:none;');
1549
             editableText.setAttribute('style', 'display:none;');
1549
             editableText.setAttribute('placeholder', 'ex. Jane Pink');
1550
             editableText.setAttribute('placeholder', 'ex. Jane Pink');
1550
             $('#' + videoSpanId)[0].appendChild(editableText);
1551
             $('#' + videoSpanId)[0].appendChild(editableText);
1551
 
1552
 
1552
-            $('#localVideoContainer .displayname').bind("click", function(e) {
1553
+            $('#localVideoContainer .displayname').bind("click", function (e) {
1553
                 e.preventDefault();
1554
                 e.preventDefault();
1554
                 $('#localDisplayName').hide();
1555
                 $('#localDisplayName').hide();
1555
                 $('#editDisplayName').show();
1556
                 $('#editDisplayName').show();
1556
                 $('#editDisplayName').focus();
1557
                 $('#editDisplayName').focus();
1557
                 $('#editDisplayName').select();
1558
                 $('#editDisplayName').select();
1558
 
1559
 
1559
-                var inputDisplayNameHandler = function(name) {
1560
+                var inputDisplayNameHandler = function (name) {
1560
                     if (nickname !== name) {
1561
                     if (nickname !== name) {
1561
                         nickname = name;
1562
                         nickname = name;
1562
                         window.localStorage.displayname = nickname;
1563
                         window.localStorage.displayname = nickname;
1661
  * Resizes and repositions videos in full screen mode.
1662
  * Resizes and repositions videos in full screen mode.
1662
  */
1663
  */
1663
 $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
1664
 $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
1664
-        function() {
1665
-            resizeLargeVideoContainer();
1666
-            positionLarge();
1667
-            isFullScreen = document.fullScreen
1668
-                                || document.mozFullScreen
1669
-                                || document.webkitIsFullScreen;
1670
-
1671
-            if (isFullScreen) {
1672
-                setView("fullscreen");
1673
-            }
1674
-            else {
1675
-                setView("default");
1676
-            }
1677
-});
1665
+    function () {
1666
+        resizeLargeVideoContainer();
1667
+        positionLarge();
1668
+        isFullScreen = document.fullScreen ||
1669
+            document.mozFullScreen ||
1670
+            document.webkitIsFullScreen;
1671
+
1672
+        if (isFullScreen) {
1673
+            setView("fullscreen");
1674
+        }
1675
+        else {
1676
+            setView("default");
1677
+        }
1678
+    }
1679
+);
1678
 
1680
 
1679
 /**
1681
 /**
1680
  * Sets the current view.
1682
  * Sets the current view.

+ 29
- 28
chat.js Wyświetl plik

1
+/* global $, Util, connection, nickname:true, getVideoSize, getVideoPosition, showToolbar, processReplacements */
1
 /**
2
 /**
2
  * Chat related user interface.
3
  * Chat related user interface.
3
  */
4
  */
16
             Chat.setChatConversationMode(true);
17
             Chat.setChatConversationMode(true);
17
         }
18
         }
18
 
19
 
19
-        $('#nickinput').keydown(function(event) {
20
+        $('#nickinput').keydown(function (event) {
20
             if (event.keyCode === 13) {
21
             if (event.keyCode === 13) {
21
                 event.preventDefault();
22
                 event.preventDefault();
22
                 var val = Util.escapeHtml(this.value);
23
                 var val = Util.escapeHtml(this.value);
35
             }
36
             }
36
         });
37
         });
37
 
38
 
38
-        $('#usermsg').keydown(function(event) {
39
+        $('#usermsg').keydown(function (event) {
39
             if (event.keyCode === 13) {
40
             if (event.keyCode === 13) {
40
                 event.preventDefault();
41
                 event.preventDefault();
41
                 var message = Util.escapeHtml(this.value);
42
                 var message = Util.escapeHtml(this.value);
45
             }
46
             }
46
         });
47
         });
47
 
48
 
48
-        var onTextAreaResize = function() {
49
+        var onTextAreaResize = function () {
49
             resizeChatConversation();
50
             resizeChatConversation();
50
             scrollChatToBottom();
51
             scrollChatToBottom();
51
         };
52
         };
52
         $('#usermsg').autosize({callback: onTextAreaResize});
53
         $('#usermsg').autosize({callback: onTextAreaResize});
53
 
54
 
54
         $("#chatspace").bind("shown",
55
         $("#chatspace").bind("shown",
55
-            function() {
56
+            function () {
56
                 unreadMessages = 0;
57
                 unreadMessages = 0;
57
                 setVisualNotification(false);
58
                 setVisualNotification(false);
58
             });
59
             });
82
         var escDisplayName = Util.escapeHtml(displayName);
83
         var escDisplayName = Util.escapeHtml(displayName);
83
         message = processReplacements(escMessage);
84
         message = processReplacements(escMessage);
84
 
85
 
85
-        $('#chatconversation').append('<div class="' + divClassName + '"><b>'
86
-                                        + escDisplayName + ': </b>'
87
-                                        + message + '</div>');
86
+        $('#chatconversation').append('<div class="' + divClassName + '"><b>' +
87
+                                      escDisplayName + ': </b>' +
88
+                                      message + '</div>');
88
         $('#chatconversation').animate(
89
         $('#chatconversation').animate(
89
                 { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
90
                 { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
90
     };
91
     };
103
             = getVideoSize(null, null, videospaceWidth, videospaceHeight);
104
             = getVideoSize(null, null, videospaceWidth, videospaceHeight);
104
         var videoWidth = videoSize[0];
105
         var videoWidth = videoSize[0];
105
         var videoHeight = videoSize[1];
106
         var videoHeight = videoSize[1];
106
-        var videoPosition = getVideoPosition(   videoWidth,
107
-                                                videoHeight,
108
-                                                videospaceWidth,
109
-                                                videospaceHeight);
107
+        var videoPosition = getVideoPosition(videoWidth,
108
+                                             videoHeight,
109
+                                             videospaceWidth,
110
+                                             videospaceHeight);
110
         var horizontalIndent = videoPosition[0];
111
         var horizontalIndent = videoPosition[0];
111
         var verticalIndent = videoPosition[1];
112
         var verticalIndent = videoPosition[1];
112
 
113
 
113
         if (chatspace.is(":visible")) {
114
         if (chatspace.is(":visible")) {
114
-            videospace.animate( {right: chatSize[0],
115
+            videospace.animate({right: chatSize[0],
115
                                 width: videospaceWidth,
116
                                 width: videospaceWidth,
116
                                 height: videospaceHeight},
117
                                 height: videospaceHeight},
117
                                 {queue: false,
118
                                 {queue: false,
143
                                 height: videospaceHeight},
144
                                 height: videospaceHeight},
144
                                {queue: false,
145
                                {queue: false,
145
                                 duration: 500,
146
                                 duration: 500,
146
-                                complete: function() {
147
+                                complete: function () {
147
                                     scrollChatToBottom();
148
                                     scrollChatToBottom();
148
                                     chatspace.trigger('shown');
149
                                     chatspace.trigger('shown');
149
                                 }
150
                                 }
183
      */
184
      */
184
     my.setChatConversationMode = function (isConversationMode) {
185
     my.setChatConversationMode = function (isConversationMode) {
185
         if (isConversationMode) {
186
         if (isConversationMode) {
186
-            $('#nickname').css({visibility:"hidden"});
187
-            $('#chatconversation').css({visibility:'visible'});
188
-            $('#usermsg').css({visibility:'visible'});
187
+            $('#nickname').css({visibility: 'hidden'});
188
+            $('#chatconversation').css({visibility: 'visible'});
189
+            $('#usermsg').css({visibility: 'visible'});
189
             $('#usermsg').focus();
190
             $('#usermsg').focus();
190
         }
191
         }
191
     };
192
     };
205
     /**
206
     /**
206
      * Returns the size of the chat.
207
      * Returns the size of the chat.
207
      */
208
      */
208
-    my.getChatSize = function() {
209
+    my.getChatSize = function () {
209
         var availableHeight = window.innerHeight;
210
         var availableHeight = window.innerHeight;
210
         var availableWidth = window.innerWidth;
211
         var availableWidth = window.innerWidth;
211
 
212
 
212
         var chatWidth = 200;
213
         var chatWidth = 200;
213
-        if (availableWidth*0.2 < 200)
214
-            chatWidth = availableWidth*0.2;
214
+        if (availableWidth * 0.2 < 200)
215
+            chatWidth = availableWidth * 0.2;
215
 
216
 
216
         return [chatWidth, availableHeight];
217
         return [chatWidth, availableHeight];
217
     };
218
     };
228
         $('#chatconversation').width($('#chatspace').width() - 10);
229
         $('#chatconversation').width($('#chatspace').width() - 10);
229
         $('#chatconversation')
230
         $('#chatconversation')
230
             .height(window.innerHeight - 10 - parseInt(usermsgHeight));
231
             .height(window.innerHeight - 10 - parseInt(usermsgHeight));
231
-    };
232
+    }
232
 
233
 
233
     /**
234
     /**
234
      * Shows/hides a visual notification, indicating that a message has arrived.
235
      * Shows/hides a visual notification, indicating that a message has arrived.
245
 
246
 
246
             var chatButtonElement
247
             var chatButtonElement
247
                 = document.getElementById('chatButton').parentNode;
248
                 = document.getElementById('chatButton').parentNode;
248
-            var leftIndent = (Util.getTextWidth(chatButtonElement)
249
-                                - Util.getTextWidth(unreadMsgElement))/2;
250
-            var topIndent = (Util.getTextHeight(chatButtonElement)
251
-                                - Util.getTextHeight(unreadMsgElement))/2 - 3;
249
+            var leftIndent = (Util.getTextWidth(chatButtonElement) -
250
+                              Util.getTextWidth(unreadMsgElement)) / 2;
251
+            var topIndent = (Util.getTextHeight(chatButtonElement) -
252
+                             Util.getTextHeight(unreadMsgElement)) / 2 - 3;
252
 
253
 
253
             unreadMsgElement.setAttribute(
254
             unreadMsgElement.setAttribute(
254
                     'style',
255
                     'style',
255
-                    'top:' + topIndent
256
-                     + '; left:' + leftIndent +';');
256
+                    'top:' + topIndent +
257
+                    '; left:' + leftIndent + ';');
257
 
258
 
258
             if (!glower.hasClass('icon-chat-simple')) {
259
             if (!glower.hasClass('icon-chat-simple')) {
259
                 glower.removeClass('icon-chat');
260
                 glower.removeClass('icon-chat');
267
         }
268
         }
268
 
269
 
269
         if (show && !notificationInterval) {
270
         if (show && !notificationInterval) {
270
-            notificationInterval = window.setInterval(function() {
271
+            notificationInterval = window.setInterval(function () {
271
                 glower.toggleClass('active');
272
                 glower.toggleClass('active');
272
             }, 800);
273
             }, 800);
273
         }
274
         }
282
      * Scrolls chat to the bottom.
283
      * Scrolls chat to the bottom.
283
      */
284
      */
284
     function scrollChatToBottom() {
285
     function scrollChatToBottom() {
285
-        setTimeout(function() {
286
+        setTimeout(function () {
286
             $('#chatconversation').scrollTop(
287
             $('#chatconversation').scrollTop(
287
                     $('#chatconversation')[0].scrollHeight);
288
                     $('#chatconversation')[0].scrollHeight);
288
         }, 5);
289
         }, 5);

+ 198
- 195
desktopsharing.js Wyświetl plik

1
+/* global $, config, connection, chrome, alert, getUserMediaWithConstraints, change_local_video, getConferenceHandler */
1
 /**
2
 /**
2
  * Indicates that desktop stream is currently in use(for toggle purpose).
3
  * Indicates that desktop stream is currently in use(for toggle purpose).
3
  * @type {boolean}
4
  * @type {boolean}
12
 /**
13
 /**
13
  * Method used to get screen sharing stream.
14
  * Method used to get screen sharing stream.
14
  *
15
  *
15
- * @type {function(stream_callback, failure_callback}
16
+ * @type {function (stream_callback, failure_callback}
16
  */
17
  */
17
 var obtainDesktopStream = null;
18
 var obtainDesktopStream = null;
18
 
19
 
22
  */
23
  */
23
 var _desktopSharingEnabled = null;
24
 var _desktopSharingEnabled = null;
24
 
25
 
26
+/**
27
+ * Method obtains desktop stream from WebRTC 'screen' source.
28
+ * Flag 'chrome://flags/#enable-usermedia-screen-capture' must be enabled.
29
+ */
30
+function obtainWebRTCScreen(streamCallback, failCallback) {
31
+    getUserMediaWithConstraints(
32
+        ['screen'],
33
+        streamCallback,
34
+        failCallback
35
+    );
36
+}
37
+
38
+/**
39
+ * Constructs inline install URL for Chrome desktop streaming extension.
40
+ * The 'chromeExtensionId' must be defined in config.js.
41
+ * @returns {string}
42
+ */
43
+function getWebStoreInstallUrl()
44
+{
45
+    return "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId;
46
+}
47
+
48
+/**
49
+ * Checks whether extension update is required.
50
+ * @param minVersion minimal required version
51
+ * @param extVersion current extension version
52
+ * @returns {boolean}
53
+ */
54
+function isUpdateRequired(minVersion, extVersion)
55
+{
56
+    try
57
+    {
58
+        var s1 = minVersion.split('.');
59
+        var s2 = extVersion.split('.');
60
+
61
+        var len = Math.max(s1.length, s2.length);
62
+        for (var i = 0; i < len; i++)
63
+        {
64
+            var n1 = 0,
65
+                n2 = 0;
66
+
67
+            if (i < s1.length)
68
+                n1 = parseInt(s1[i]);
69
+            if (i < s2.length)
70
+                n2 = parseInt(s2[i]);
71
+
72
+            if (isNaN(n1) || isNaN(n2))
73
+            {
74
+                return true;
75
+            }
76
+            else if (n1 !== n2)
77
+            {
78
+                return n1 > n2;
79
+            }
80
+        }
81
+
82
+        // will happen if boths version has identical numbers in
83
+        // their components (even if one of them is longer, has more components)
84
+        return false;
85
+    }
86
+    catch (e)
87
+    {
88
+        console.error("Failed to parse extension version", e);
89
+        return true;
90
+    }
91
+}
92
+
93
+
94
+function checkExtInstalled(isInstalledCallback) {
95
+    if (!chrome.runtime) {
96
+        // No API, so no extension for sure
97
+        isInstalledCallback(false);
98
+    }
99
+    chrome.runtime.sendMessage(
100
+        config.chromeExtensionId,
101
+        { getVersion: true },
102
+        function (response) {
103
+            if (!response || !response.version) {
104
+                // Communication failure - assume that no endpoint exists
105
+                console.warn("Extension not installed?: " + chrome.runtime.lastError);
106
+                isInstalledCallback(false);
107
+            } else {
108
+                // Check installed extension version
109
+                var extVersion = response.version;
110
+                console.log('Extension version is: ' + extVersion);
111
+                var updateRequired = isUpdateRequired(config.minChromeExtVersion, extVersion);
112
+                if (updateRequired) {
113
+                    alert(
114
+                        'Jitsi Desktop Streamer requires update. ' +
115
+                        'Changes will take effect after next Chrome restart.');
116
+                }
117
+                isInstalledCallback(!updateRequired);
118
+            }
119
+        }
120
+    );
121
+}
122
+
123
+function doGetStreamFromExtension(streamCallback, failCallback) {
124
+    // Sends 'getStream' msg to the extension. Extension id must be defined in the config.
125
+    chrome.runtime.sendMessage(
126
+        config.chromeExtensionId,
127
+        { getStream: true},
128
+        function (response) {
129
+            if (!response) {
130
+                failCallback(chrome.runtime.lastError);
131
+                return;
132
+            }
133
+            console.log("Response from extension: " + response);
134
+            if (response.streamId) {
135
+                getUserMediaWithConstraints(
136
+                    ['desktop'],
137
+                    function (stream) {
138
+                        streamCallback(stream);
139
+                    },
140
+                    failCallback,
141
+                    null, null, null,
142
+                    response.streamId);
143
+            } else {
144
+                failCallback("Extension failed to get the stream");
145
+            }
146
+        }
147
+    );
148
+}
149
+/**
150
+ * Asks Chrome extension to call chooseDesktopMedia and gets chrome 'desktop' stream for returned stream token.
151
+ */
152
+function obtainScreenFromExtension(streamCallback, failCallback) {
153
+    checkExtInstalled(
154
+        function (isInstalled) {
155
+            if (isInstalled) {
156
+                doGetStreamFromExtension(streamCallback, failCallback);
157
+            } else {
158
+                chrome.webstore.install(
159
+                    getWebStoreInstallUrl(),
160
+                    function (arg) {
161
+                        console.log("Extension installed successfully", arg);
162
+                        // We need to reload the page in order to get the access to chrome.runtime
163
+                        window.location.reload(false);
164
+                    },
165
+                    function (arg) {
166
+                        console.log("Failed to install the extension", arg);
167
+                        failCallback(arg);
168
+                    }
169
+                );
170
+            }
171
+        }
172
+    );
173
+}
174
+
25
 /**
175
 /**
26
  * @returns {boolean} <tt>true</tt> if desktop sharing feature is available and enabled.
176
  * @returns {boolean} <tt>true</tt> if desktop sharing feature is available and enabled.
27
  */
177
  */
28
 function isDesktopSharingEnabled() {
178
 function isDesktopSharingEnabled() {
29
-    if(_desktopSharingEnabled === null){
30
-        if(obtainDesktopStream === obtainScreenFromExtension) {
179
+    if (_desktopSharingEnabled === null) {
180
+        if (obtainDesktopStream === obtainScreenFromExtension) {
31
             // Parse chrome version
181
             // Parse chrome version
32
             var userAgent = navigator.userAgent.toLowerCase();
182
             var userAgent = navigator.userAgent.toLowerCase();
33
             // We can assume that user agent is chrome, because it's enforced when 'ext' streaming method is set
183
             // We can assume that user agent is chrome, because it's enforced when 'ext' streaming method is set
41
     return _desktopSharingEnabled;
191
     return _desktopSharingEnabled;
42
 }
192
 }
43
 
193
 
194
+function showDesktopSharingButton() {
195
+    if (isDesktopSharingEnabled()) {
196
+        $('#desktopsharing').css({display: "inline"});
197
+    } else {
198
+        $('#desktopsharing').css({display: "none"});
199
+    }
200
+}
201
+
44
 /**
202
 /**
45
  * Call this method to toggle desktop sharing feature.
203
  * Call this method to toggle desktop sharing feature.
46
  * @param method pass "ext" to use chrome extension for desktop capture(chrome extension required),
204
  * @param method pass "ext" to use chrome extension for desktop capture(chrome extension required),
49
  */
207
  */
50
 function setDesktopSharing(method) {
208
 function setDesktopSharing(method) {
51
     // Check if we are running chrome
209
     // Check if we are running chrome
52
-    if(!navigator.webkitGetUserMedia){
210
+    if (!navigator.webkitGetUserMedia) {
53
         obtainDesktopStream = null;
211
         obtainDesktopStream = null;
54
         console.info("Desktop sharing disabled");
212
         console.info("Desktop sharing disabled");
55
-    } else if(method == "ext") {
213
+    } else if (method == "ext") {
56
         obtainDesktopStream = obtainScreenFromExtension;
214
         obtainDesktopStream = obtainScreenFromExtension;
57
         console.info("Using Chrome extension for desktop sharing");
215
         console.info("Using Chrome extension for desktop sharing");
58
-    } else if(method == "webrtc") {
216
+    } else if (method == "webrtc") {
59
         obtainDesktopStream = obtainWebRTCScreen;
217
         obtainDesktopStream = obtainWebRTCScreen;
60
         console.info("Using Chrome WebRTC for desktop sharing");
218
         console.info("Using Chrome WebRTC for desktop sharing");
61
     }
219
     }
66
     showDesktopSharingButton();
224
     showDesktopSharingButton();
67
 }
225
 }
68
 
226
 
69
-function showDesktopSharingButton() {
70
-    if(isDesktopSharingEnabled()) {
71
-        $('#desktopsharing').css( {display:"inline"} );
72
-    } else {
73
-        $('#desktopsharing').css( {display:"none"} );
74
-    }
75
-}
76
-
77
 /**
227
 /**
78
  * Initializes <link rel=chrome-webstore-item /> with extension id set in config.js to support inline installs.
228
  * Initializes <link rel=chrome-webstore-item /> with extension id set in config.js to support inline installs.
79
  * Host site must be selected as main website of published extension.
229
  * Host site must be selected as main website of published extension.
83
     $("link[rel=chrome-webstore-item]").attr("href", getWebStoreInstallUrl());
233
     $("link[rel=chrome-webstore-item]").attr("href", getWebStoreInstallUrl());
84
 }
234
 }
85
 
235
 
86
-/**
87
- * Constructs inline install URL for Chrome desktop streaming extension.
88
- * The 'chromeExtensionId' must be defined in config.js.
89
- * @returns {string}
90
- */
91
-function getWebStoreInstallUrl()
92
-{
93
-    return "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId;
236
+function getSwitchStreamFailed(error) {
237
+    console.error("Failed to obtain the stream to switch to", error);
238
+    switchInProgress = false;
239
+}
240
+
241
+function streamSwitchDone() {
242
+    //window.setTimeout(
243
+    //    function () {
244
+    switchInProgress = false;
245
+    //    }, 100
246
+    //);
247
+}
248
+
249
+function newStreamCreated(stream) {
250
+
251
+    var oldStream = connection.jingle.localVideo;
252
+
253
+    change_local_video(stream, !isUsingScreenStream);
254
+
255
+    var conferenceHandler = getConferenceHandler();
256
+    if (conferenceHandler) {
257
+        // FIXME: will block switchInProgress on true value in case of exception
258
+        conferenceHandler.switchStreams(stream, oldStream, streamSwitchDone);
259
+    } else {
260
+        // We are done immediately
261
+        console.error("No conference handler");
262
+        streamSwitchDone();
263
+    }
94
 }
264
 }
95
 
265
 
96
 /*
266
 /*
104
     switchInProgress = true;
274
     switchInProgress = true;
105
 
275
 
106
     // Only the focus is able to set a shared key.
276
     // Only the focus is able to set a shared key.
107
-    if(!isUsingScreenStream)
277
+    if (!isUsingScreenStream)
108
     {
278
     {
109
         obtainDesktopStream(
279
         obtainDesktopStream(
110
-            function(stream) {
280
+            function (stream) {
111
                 // We now use screen stream
281
                 // We now use screen stream
112
                 isUsingScreenStream = true;
282
                 isUsingScreenStream = true;
113
                 // Hook 'ended' event to restore camera when screen stream stops
283
                 // Hook 'ended' event to restore camera when screen stream stops
114
                 stream.addEventListener('ended',
284
                 stream.addEventListener('ended',
115
-                    function(e) {
116
-                        if(!switchInProgress && isUsingScreenStream) {
285
+                    function (e) {
286
+                        if (!switchInProgress && isUsingScreenStream) {
117
                             toggleScreenSharing();
287
                             toggleScreenSharing();
118
                         }
288
                         }
119
                     }
289
                     }
120
                 );
290
                 );
121
                 newStreamCreated(stream);
291
                 newStreamCreated(stream);
122
             },
292
             },
123
-            getSwitchStreamFailed );
293
+            getSwitchStreamFailed);
124
     } else {
294
     } else {
125
         // Disable screen stream
295
         // Disable screen stream
126
         getUserMediaWithConstraints(
296
         getUserMediaWithConstraints(
127
             ['video'],
297
             ['video'],
128
-            function(stream) {
298
+            function (stream) {
129
                 // We are now using camera stream
299
                 // We are now using camera stream
130
                 isUsingScreenStream = false;
300
                 isUsingScreenStream = false;
131
                 newStreamCreated(stream);
301
                 newStreamCreated(stream);
135
     }
305
     }
136
 }
306
 }
137
 
307
 
138
-function getSwitchStreamFailed(error) {
139
-    console.error("Failed to obtain the stream to switch to", error);
140
-    switchInProgress = false;
141
-}
142
-
143
-function newStreamCreated(stream) {
144
-
145
-    var oldStream = connection.jingle.localVideo;
146
-
147
-    change_local_video(stream, !isUsingScreenStream);
148
-
149
-    var conferenceHandler = getConferenceHandler();
150
-    if(conferenceHandler) {
151
-        // FIXME: will block switchInProgress on true value in case of exception
152
-        conferenceHandler.switchStreams(stream, oldStream, streamSwitchDone);
153
-    } else {
154
-        // We are done immediately
155
-        console.error("No conference handler");
156
-        streamSwitchDone();
157
-    }
158
-}
159
-
160
-function streamSwitchDone() {
161
-    //window.setTimeout(
162
-    //    function() {
163
-            switchInProgress = false;
164
-    //    }, 100
165
-    //);
166
-}
167
-
168
-/**
169
- * Method obtains desktop stream from WebRTC 'screen' source.
170
- * Flag 'chrome://flags/#enable-usermedia-screen-capture' must be enabled.
171
- */
172
-function obtainWebRTCScreen(streamCallback, failCallback) {
173
-    getUserMediaWithConstraints(
174
-        ['screen'],
175
-        streamCallback,
176
-        failCallback
177
-    );
178
-}
179
-
180
-/**
181
- * Asks Chrome extension to call chooseDesktopMedia and gets chrome 'desktop' stream for returned stream token.
182
- */
183
-function obtainScreenFromExtension(streamCallback, failCallback) {
184
-    checkExtInstalled(
185
-        function(isInstalled) {
186
-            if(isInstalled) {
187
-                doGetStreamFromExtension(streamCallback, failCallback);
188
-            } else {
189
-                chrome.webstore.install(
190
-                    getWebStoreInstallUrl(),
191
-                    function(arg) {
192
-                        console.log("Extension installed successfully", arg);
193
-                        // We need to reload the page in order to get the access to chrome.runtime
194
-                        window.location.reload(false);
195
-                    },
196
-                    function(arg) {
197
-                        console.log("Failed to install the extension", arg);
198
-                        failCallback(arg);
199
-                    }
200
-                );
201
-            }
202
-        }
203
-    );
204
-}
205
-
206
-function checkExtInstalled(isInstalledCallback) {
207
-    if(!chrome.runtime) {
208
-        // No API, so no extension for sure
209
-        isInstalledCallback(false);
210
-    }
211
-    chrome.runtime.sendMessage(
212
-        config.chromeExtensionId,
213
-        { getVersion: true },
214
-        function(response){
215
-            if(!response || !response.version) {
216
-                // Communication failure - assume that no endpoint exists
217
-                console.warn("Extension not installed?: "+chrome.runtime.lastError);
218
-                isInstalledCallback(false);
219
-            } else {
220
-                // Check installed extension version
221
-                var extVersion = response.version;
222
-                console.log('Extension version is: '+extVersion);
223
-                var updateRequired = isUpdateRequired(config.minChromeExtVersion, extVersion);
224
-                if(updateRequired) {
225
-                    alert(
226
-                        'Jitsi Desktop Streamer requires update. ' +
227
-                        'Changes will take effect after next Chrome restart.' );
228
-                }
229
-                isInstalledCallback(!updateRequired);
230
-            }
231
-        }
232
-    );
233
-}
234
-
235
-/**
236
- * Checks whether extension update is required.
237
- * @param minVersion minimal required version
238
- * @param extVersion current extension version
239
- * @returns {boolean}
240
- */
241
-function isUpdateRequired(minVersion, extVersion)
242
-{
243
-    try
244
-    {
245
-        var s1 = minVersion.split('.');
246
-        var s2 = extVersion.split('.');
247
-
248
-        var len = Math.max(s1.length, s2.length);
249
-        for(var i = 0; i < len; i++)
250
-        {
251
-            var n1=0,n2=0;
252
-
253
-            if(i < s1.length)
254
-                n1 = parseInt(s1[i]);
255
-            if(i < s2.length)
256
-                n2 = parseInt(s2[i]);
257
-
258
-            if(isNaN(n1) || isNaN(n2))
259
-            {
260
-                return true;
261
-            }
262
-            else if(n1 !== n2)
263
-            {
264
-                return n1 > n2;
265
-            }
266
-        }
267
-
268
-        // will happen if boths version has identical numbers in
269
-        // their components (even if one of them is longer, has more components)
270
-        return false;
271
-    }
272
-    catch(e)
273
-    {
274
-        console.error("Failed to parse extension version", e);
275
-        return true;
276
-    }
277
-}
278
-
279
-function doGetStreamFromExtension(streamCallback, failCallback) {
280
-    // Sends 'getStream' msg to the extension. Extension id must be defined in the config.
281
-    chrome.runtime.sendMessage(
282
-        config.chromeExtensionId,
283
-        { getStream: true},
284
-        function(response) {
285
-            if(!response) {
286
-                failCallback(chrome.runtime.lastError);
287
-                return;
288
-            }
289
-            console.log("Response from extension: "+response);
290
-            if(response.streamId) {
291
-                getUserMediaWithConstraints(
292
-                    ['desktop'],
293
-                    function(stream) {
294
-                        streamCallback(stream);
295
-                    },
296
-                    failCallback,
297
-                    null, null, null,
298
-                    response.streamId);
299
-            } else {
300
-                failCallback("Extension failed to get the stream");
301
-            }
302
-        }
303
-    );
304
-}

+ 1
- 0
estos_log.js Wyświetl plik

1
+/* global Strophe */
1
 Strophe.addConnectionPlugin('logger', {
2
 Strophe.addConnectionPlugin('logger', {
2
     // logs raw stanzas and makes them available for download as JSON
3
     // logs raw stanzas and makes them available for download as JSON
3
     connection: null,
4
     connection: null,

+ 13
- 12
etherpad.js Wyświetl plik

1
+/* global $, config, Prezi, Util, connection, setLargeVideoVisible, dockToolbar */
1
 var Etherpad = (function (my) {
2
 var Etherpad = (function (my) {
2
     var etherpadName = null;
3
     var etherpadName = null;
3
     var etherpadIFrame = null;
4
     var etherpadIFrame = null;
15
 
16
 
16
             if (!name) {
17
             if (!name) {
17
                 // In case we're the focus we generate the name.
18
                 // In case we're the focus we generate the name.
18
-                etherpadName = Math.random().toString(36).substring(7)
19
-                                + '_' + (new Date().getTime()).toString();
19
+                etherpadName = Math.random().toString(36).substring(7) +
20
+                                '_' + (new Date().getTime()).toString();
20
                 shareEtherpad();
21
                 shareEtherpad();
21
             }
22
             }
22
             else
23
             else
41
 
42
 
42
         if ($('#etherpad>iframe').css('visibility') === 'hidden') {
43
         if ($('#etherpad>iframe').css('visibility') === 'hidden') {
43
             largeVideo.fadeOut(300, function () {
44
             largeVideo.fadeOut(300, function () {
44
-                if (Prezi.isPresentationVisible())
45
-                    largeVideo.css({opacity:'0'});
46
-                else {
45
+                if (Prezi.isPresentationVisible()) {
46
+                    largeVideo.css({opacity: '0'});
47
+                } else {
47
                     setLargeVideoVisible(false);
48
                     setLargeVideoVisible(false);
48
                     dockToolbar(true);
49
                     dockToolbar(true);
49
                 }
50
                 }
50
 
51
 
51
-                $('#etherpad>iframe').fadeIn(300, function() {
52
+                $('#etherpad>iframe').fadeIn(300, function () {
52
                     document.body.style.background = '#eeeeee';
53
                     document.body.style.background = '#eeeeee';
53
-                    $('#etherpad>iframe').css({visibility:'visible'});
54
-                    $('#etherpad').css({zIndex:2});
54
+                    $('#etherpad>iframe').css({visibility: 'visible'});
55
+                    $('#etherpad').css({zIndex: 2});
55
                 });
56
                 });
56
             });
57
             });
57
         }
58
         }
58
         else if ($('#etherpad>iframe')) {
59
         else if ($('#etherpad>iframe')) {
59
             $('#etherpad>iframe').fadeOut(300, function () {
60
             $('#etherpad>iframe').fadeOut(300, function () {
60
-                $('#etherpad>iframe').css({visibility:'hidden'});
61
-                $('#etherpad').css({zIndex:0});
61
+                $('#etherpad>iframe').css({visibility: 'hidden'});
62
+                $('#etherpad').css({zIndex: 0});
62
                 document.body.style.background = 'black';
63
                 document.body.style.background = 'black';
63
                 if (!isPresentation) {
64
                 if (!isPresentation) {
64
-                    $('#largeVideo').fadeIn(300, function() {
65
+                    $('#largeVideo').fadeIn(300, function () {
65
                         setLargeVideoVisible(true);
66
                         setLargeVideoVisible(true);
66
                         dockToolbar(false);
67
                         dockToolbar(false);
67
                     });
68
                     });
99
      */
100
      */
100
     function enableEtherpadButton() {
101
     function enableEtherpadButton() {
101
         if (!$('#etherpadButton').is(":visible"))
102
         if (!$('#etherpadButton').is(":visible"))
102
-            $('#etherpadButton').css({display:'inline-block'});
103
+            $('#etherpadButton').css({display: 'inline-block'});
103
     }
104
     }
104
 
105
 
105
     /**
106
     /**

+ 9
- 10
util.js Wyświetl plik

1
+/* global $ */
1
 /**
2
 /**
2
  * Utility functions.
3
  * Utility functions.
3
  */
4
  */
8
      *
9
      *
9
      * @param el the element
10
      * @param el the element
10
      */
11
      */
11
-    my.getTextWidth = function(el) {
12
+    my.getTextWidth = function (el) {
12
         return (el.clientWidth + 1);
13
         return (el.clientWidth + 1);
13
     };
14
     };
14
 
15
 
17
      *
18
      *
18
      * @param el the element
19
      * @param el the element
19
      */
20
      */
20
-    my.getTextHeight = function(el) {
21
+    my.getTextHeight = function (el) {
21
         return (el.clientHeight + 1);
22
         return (el.clientHeight + 1);
22
     };
23
     };
23
 
24
 
26
      *
27
      *
27
      * @param number the number to cast
28
      * @param number the number to cast
28
      */
29
      */
29
-    my.toInteger = function(number) {
30
+    my.toInteger = function (number) {
30
         return Math.round(Number(number));
31
         return Math.round(Number(number));
31
     };
32
     };
32
 
33
 
35
      *
36
      *
36
      * @param id the identifier of the audio element.
37
      * @param id the identifier of the audio element.
37
      */
38
      */
38
-    my.playSoundNotification = function(id) {
39
+    my.playSoundNotification = function (id) {
39
         document.getElementById(id).play();
40
         document.getElementById(id).play();
40
     };
41
     };
41
 
42
 
42
     /**
43
     /**
43
      * Escapes the given text.
44
      * Escapes the given text.
44
      */
45
      */
45
-    my.escapeHtml = function(unsafeText) {
46
+    my.escapeHtml = function (unsafeText) {
46
         return $('<div/>').text(unsafeText).html();
47
         return $('<div/>').text(unsafeText).html();
47
     };
48
     };
48
 
49
 
49
     /**
50
     /**
50
      * Returns the available video width.
51
      * Returns the available video width.
51
      */
52
      */
52
-    my.getAvailableVideoWidth = function() {
53
-        var chatspaceWidth = $('#chatspace').is(":visible")
54
-        ? $('#chatspace').width()
55
-        : 0;
53
+    my.getAvailableVideoWidth = function () {
54
+        var chatspaceWidth = $('#chatspace').is(":visible") ? $('#chatspace').width() : 0;
56
 
55
 
57
         return window.innerWidth - chatspaceWidth;
56
         return window.innerWidth - chatspaceWidth;
58
     };
57
     };
59
 
58
 
60
     return my;
59
     return my;
61
-}(Util || {}));
60
+}(Util || {}));

Ładowanie…
Anuluj
Zapisz