|
3 | 3 | /** when DOM is ready */ |
4 | 4 | $(function() { |
5 | 5 | var ui = { |
6 | | - $usersTitle: $('.j-users__title'), |
7 | | - $usersList: $('.j-users__list'), |
8 | | - |
9 | | - $panel: $('.j-pl'), |
10 | | - $callees: $('.j-callees'), |
11 | | - |
12 | | - $btnCall: $('.j-call'), |
13 | | - $btnHangup: $('.j-hangup'), |
14 | | - |
15 | | - $ctrlBtn: $('.j-caller__ctrl'), |
16 | | - filterClassName: '.j-filter', |
17 | | - |
18 | | - modal: { |
19 | | - 'income_call': '#income_call' |
20 | | - }, |
21 | | - |
22 | | - sounds: { |
23 | | - 'call': 'callingSignal', |
24 | | - 'end': 'endCallSignal', |
25 | | - 'rington': 'ringtoneSignal' |
26 | | - }, |
27 | | - setPositionFooter: function() { |
28 | | - var $footer = $('.j-footer'), |
29 | | - invisibleClassName = 'invisible', |
30 | | - footerFixedClassName = 'footer-fixed'; |
31 | | - |
32 | | - if( $(window).outerHeight() > $('.j-wrapper').outerHeight() ) { |
33 | | - $footer.addClass(footerFixedClassName); |
34 | | - } else { |
35 | | - $footer.removeClass(footerFixedClassName); |
36 | | - } |
| 6 | + $usersTitle: $('.j-users__title'), |
| 7 | + $usersList: $('.j-users__list'), |
| 8 | + |
| 9 | + $panel: $('.j-pl'), |
| 10 | + $callees: $('.j-callees'), |
| 11 | + |
| 12 | + $btnCall: $('.j-call'), |
| 13 | + $btnHangup: $('.j-hangup'), |
| 14 | + |
| 15 | + $ctrlBtn: $('.j-caller__ctrl'), |
| 16 | + filterClassName: '.j-filter', |
| 17 | + |
| 18 | + modal: { |
| 19 | + 'income_call': '#income_call' |
| 20 | + }, |
| 21 | + |
| 22 | + sounds: { |
| 23 | + 'call': 'callingSignal', |
| 24 | + 'end': 'endCallSignal', |
| 25 | + 'rington': 'ringtoneSignal' |
| 26 | + }, |
| 27 | + setPositionFooter: function() { |
| 28 | + var $footer = $('.j-footer'), |
| 29 | + invisibleClassName = 'invisible', |
| 30 | + footerFixedClassName = 'footer-fixed'; |
| 31 | + |
| 32 | + if( $(window).outerHeight() > $('.j-wrapper').outerHeight() ) { |
| 33 | + $footer.addClass(footerFixedClassName); |
| 34 | + } else { |
| 35 | + $footer.removeClass(footerFixedClassName); |
| 36 | + } |
37 | 37 |
|
38 | | - $footer.removeClass(invisibleClassName); |
39 | | - }, |
40 | | - togglePreloadMain: function(action) { |
41 | | - var $main = $('.j-main'), |
42 | | - preloadClassName = 'main-preload'; |
| 38 | + $footer.removeClass(invisibleClassName); |
| 39 | + }, |
| 40 | + togglePreloadMain: function(action) { |
| 41 | + var $main = $('.j-main'), |
| 42 | + preloadClassName = 'main-preload'; |
43 | 43 |
|
44 | | - if(action === 'show') { |
45 | | - $main.addClass( preloadClassName ); |
46 | | - } else { |
47 | | - $main.removeClass( preloadClassName ); |
48 | | - } |
49 | | - }, |
50 | | - createUsers: function(users, $node) { |
51 | | - var tpl = _.template( $('#user_tpl').html() ), |
52 | | - usersHTML = ''; |
53 | | - |
54 | | - $node.empty(); |
| 44 | + if(action === 'show') { |
| 45 | + $main.addClass( preloadClassName ); |
| 46 | + } else { |
| 47 | + $main.removeClass( preloadClassName ); |
| 48 | + } |
| 49 | + }, |
| 50 | + createUsers: function(users, $node) { |
| 51 | + var tpl = _.template( $('#user_tpl').html() ), |
| 52 | + usersHTML = ''; |
55 | 53 |
|
56 | | - _.each(users, function(user, i, list) { |
57 | | - usersHTML += tpl(user); |
58 | | - }); |
| 54 | + $node.empty(); |
59 | 55 |
|
60 | | - $node.append(usersHTML); |
61 | | - }, |
62 | | - showCallBtn: function() { |
63 | | - this.$btnHangup.addClass('hidden'); |
64 | | - this.$btnCall.removeClass('hidden'); |
65 | | - }, |
66 | | - hideCallBtn: function() { |
67 | | - this.$btnHangup.removeClass('hidden'); |
68 | | - this.$btnCall.addClass('hidden'); |
69 | | - }, |
70 | | - toggleRemoteVideoView: function(userID, action) { |
71 | | - var $video = $('#remote_video_' + userID); |
72 | | - |
73 | | - if(!_.isEmpty(app.currentSession) && $video.length){ |
74 | | - if(action === 'show') { |
75 | | - $video.parents('.j-callee').removeClass('callees__callee-wait'); |
76 | | - } else if(action === 'hide') { |
77 | | - $video.parents('.j-callee').addClass('callees__callee-wait'); |
78 | | - } else if(action === 'clear') { |
79 | | - /** detachMediaStream take videoElementId */ |
80 | | - app.currentSession.detachMediaStream('remote_video_' + userID); |
81 | | - $video.removeClass('fw-video-wait'); |
82 | | - } |
83 | | - } |
84 | | - }, |
85 | | - classesNameFilter: 'no aden reyes perpetua inkwell toaster walden hudson gingham mayfair lofi xpro2 _1977 brooklyn', |
86 | | - changeFilter: function(selector, filterName) { |
87 | | - $(selector) |
88 | | - .removeClass(this.classesNameFilter) |
89 | | - .addClass( filterName ); |
90 | | - }, |
91 | | - callTime: 0, |
92 | | - updTimer: function() { |
93 | | - this.callTime += 1000; |
| 56 | + _.each(users, function(user, i, list) { |
| 57 | + usersHTML += tpl(user); |
| 58 | + }); |
94 | 59 |
|
95 | | - $('#timer').removeClass('hidden') |
96 | | - .text( new Date(this.callTime).toUTCString().split(/ /)[4] ); |
97 | | - } |
| 60 | + $node.append(usersHTML); |
| 61 | + }, |
| 62 | + showCallBtn: function() { |
| 63 | + this.$btnHangup.addClass('hidden'); |
| 64 | + this.$btnCall.removeClass('hidden'); |
| 65 | + }, |
| 66 | + hideCallBtn: function() { |
| 67 | + this.$btnHangup.removeClass('hidden'); |
| 68 | + this.$btnCall.addClass('hidden'); |
| 69 | + }, |
| 70 | + toggleRemoteVideoView: function(userID, action) { |
| 71 | + var $video = $('#remote_video_' + userID); |
| 72 | + |
| 73 | + if(!_.isEmpty(app.currentSession) && $video.length){ |
| 74 | + if(action === 'show') { |
| 75 | + $video.parents('.j-callee').removeClass('callees__callee-wait'); |
| 76 | + } else if(action === 'hide') { |
| 77 | + $video.parents('.j-callee').addClass('callees__callee-wait'); |
| 78 | + } else if(action === 'clear') { |
| 79 | + /** detachMediaStream take videoElementId */ |
| 80 | + app.currentSession.detachMediaStream('remote_video_' + userID); |
| 81 | + $video.removeClass('fw-video-wait'); |
| 82 | + } |
| 83 | + } |
| 84 | + }, |
| 85 | + classesNameFilter: 'no aden reyes perpetua inkwell toaster walden hudson gingham mayfair lofi xpro2 _1977 brooklyn', |
| 86 | + changeFilter: function(selector, filterName) { |
| 87 | + $(selector) |
| 88 | + .removeClass(this.classesNameFilter) |
| 89 | + .addClass( filterName ); |
| 90 | + }, |
| 91 | + callTime: 0, |
| 92 | + updTimer: function() { |
| 93 | + this.callTime += 1000; |
| 94 | + |
| 95 | + $('#timer').removeClass('hidden') |
| 96 | + .text( new Date(this.callTime).toUTCString().split(/ /)[4] ); |
| 97 | + } |
98 | 98 | }, |
99 | 99 | app = { |
100 | 100 | caller: {}, |
|
108 | 108 | authorizationing = false, |
109 | 109 | callTimer; |
110 | 110 |
|
| 111 | + window.app = app; |
| 112 | + |
111 | 113 | function initializeUI(arg) { |
112 | 114 | var params = arg || {}; |
113 | 115 |
|
|
480 | 482 | authorizationing = false; |
481 | 483 | }; |
482 | 484 |
|
| 485 | + QB.webrtc.onCallStatsReport = function onCallStatsReport(session, userId, bytesReceived) { |
| 486 | + console.group('onCallStatsReport'); |
| 487 | + console.log('userId: ' + userId); |
| 488 | + console.log('bytesReceived: ' + bytesReceived); |
| 489 | + console.groupEnd(); |
| 490 | + }; |
| 491 | + |
483 | 492 | QB.webrtc.onSessionCloseListener = function onSessionCloseListener(session){ |
484 | 493 | console.log('onSessionCloseListener: ' + session); |
485 | 494 |
|
|
662 | 671 | } |
663 | 672 |
|
664 | 673 | if(!callTimer) { |
665 | | - callTimer = setInterval( function(){ ui.updTimer.call(ui) }, 1000); |
| 674 | + callTimer = setInterval( function(){ ui.updTimer.call(ui); }, 1000); |
666 | 675 | } |
667 | 676 | }; |
668 | 677 |
|
|
0 commit comments