|
5 | 5 | var ui = { |
6 | 6 | $usersTitle: $('.j-users__title'), |
7 | 7 | $usersList: $('.j-users__list'), |
8 | | - $cl: $('.j-console'), |
9 | 8 |
|
10 | 9 | $panel: $('.j-pl'), |
11 | 10 | $callees: $('.j-callees'), |
|
68 | 67 | this.$btnHangup.removeClass('hidden'); |
69 | 68 | this.$btnCall.addClass('hidden'); |
70 | 69 | }, |
71 | | - /** |
72 | | - * [updateMsg update massage for user] |
73 | | - * @param {[string]} msg_name [key for MESSAGES object / name(id) of template] |
74 | | - * @param {[object]} obj [additional paramets for compiled template] |
75 | | - */ |
76 | | - updateMsg: function(params) { |
77 | | - var msg = ''; |
78 | | - |
79 | | - if(MESSAGES[params.msg]) { |
80 | | - msg = MESSAGES[params.msg]; |
81 | | - } else { |
82 | | - msg = _.template( $('#' + params.msg).html() )(params.obj); |
83 | | - } |
84 | | - |
85 | | - this.$cl |
86 | | - .empty() |
87 | | - .append(msg); |
88 | | - }, |
89 | 70 | toggleRemoteVideoView: function(userID, action) { |
90 | 71 | var $video = $('#remote_video_' + userID); |
91 | 72 |
|
|
134 | 115 | ui.$usersTitle.text(MESSAGES.title_login); |
135 | 116 |
|
136 | 117 | if(!params.withoutUpdMsg || params.msg) { |
137 | | - ui.updateMsg({msg: params.msg}); |
| 118 | + qbApp.MsgBoard.update(params.msg); |
138 | 119 | } |
139 | 120 | } |
140 | 121 |
|
|
159 | 140 |
|
160 | 141 | /** if app.caller is not exist create caller, if no - add callees */ |
161 | 142 | if(!window.navigator.onLine) { |
162 | | - ui.updateMsg({msg: 'no_internet'}); |
| 143 | + qbApp.MsgBoard.update('no_internet'); |
163 | 144 | } else { |
164 | 145 | if(_.isEmpty(app.caller)) { |
165 | 146 | authorizationing = true; |
|
178 | 159 |
|
179 | 160 | ui.$usersList.empty(); |
180 | 161 |
|
181 | | - ui.updateMsg( {msg: 'connect'} ); |
| 162 | + qbApp.MsgBoard.update('connect'); |
182 | 163 |
|
183 | 164 | QB.chat.connect({ |
184 | 165 | jid: QB.chat.helpers.getUserJid( app.caller.id, QBApp.appId ), |
|
194 | 175 | ui.createUsers(usersWithoutCaller, ui.$usersList); |
195 | 176 |
|
196 | 177 | ui.$usersTitle.text(MESSAGES.title_callee); |
197 | | - ui.updateMsg( {msg: 'login_tpl', obj: {name: app.caller.full_name}} ); |
| 178 | + qbApp.MsgBoard.update('login_tpl', {name: app.caller.full_name}); |
198 | 179 |
|
199 | 180 | ui.$panel.removeClass('hidden'); |
200 | 181 | ui.setPositionFooter(); |
|
240 | 221 | }; |
241 | 222 |
|
242 | 223 | if(!window.navigator.onLine) { |
243 | | - ui.updateMsg({msg: 'no_internet'}); |
| 224 | + qbApp.MsgBoard.update('no_internet'); |
244 | 225 | } else { |
245 | 226 | if ( _.isEmpty(app.callees) ) { |
246 | 227 | $('#error_no_calles').modal(); |
247 | 228 | } else { |
248 | | - ui.updateMsg( {msg: 'create_session'} ); |
| 229 | + qbApp.MsgBoard.update('create_session'); |
249 | 230 | app.currentSession = QB.webrtc.createNewSession(Object.keys(app.callees), QB.webrtc.CallType.VIDEO); |
250 | 231 | app.currentSession.getUserMedia(mediaParams, function(err, stream) { |
251 | 232 | if (err || !stream.getAudioTracks().length || !stream.getVideoTracks().length) { |
252 | | - ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}}); |
| 233 | + qbApp.MsgBoard.update('device_not_found', {name: app.caller.full_name}); |
253 | 234 | app.currentSession.stop({}); |
254 | 235 | } else { |
255 | 236 | app.currentSession.call({}, function(error) { |
|
258 | 239 | } else { |
259 | 240 | var compiled = _.template( $('#callee_video').html() ); |
260 | 241 |
|
261 | | - ui.updateMsg({msg: 'calling'}); |
| 242 | + qbApp.MsgBoard.update('calling'); |
262 | 243 | document.getElementById(ui.sounds.call).play(); |
263 | 244 |
|
264 | 245 | /** create video elements for callees */ |
|
284 | 265 | app.currentSession.stop({}); |
285 | 266 | app.currentSession = {}; |
286 | 267 |
|
287 | | - ui.updateMsg( {msg: 'login_tpl', obj: {name: app.caller.full_name}} ); |
| 268 | + qbApp.MsgBoard.update('login_tpl', {name: app.caller.full_name}); |
288 | 269 | } |
289 | 270 | }); |
290 | 271 |
|
|
307 | 288 |
|
308 | 289 | app.currentSession.getUserMedia(mediaParams, function(err, stream) { |
309 | 290 | if (err) { |
310 | | - ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}}); |
| 291 | + qbApp.MsgBoard.update('device_not_found', {name: app.caller.full_name}); |
311 | 292 | isDeviceAccess = false; |
312 | 293 | app.currentSession.stop({}); |
313 | 294 | } else { |
|
338 | 319 | }); |
339 | 320 |
|
340 | 321 | ui.$callees.append(videoElems); |
341 | | - ui.updateMsg( {msg: 'during_call', obj: {name: app.caller.full_name}} ); |
| 322 | + qbApp.MsgBoard.update('during_call', {name: app.caller.full_name}); |
342 | 323 | ui.setPositionFooter(); |
343 | 324 |
|
344 | 325 | app.currentSession.accept({}); |
|
423 | 404 |
|
424 | 405 | /** Before use WebRTC checking WebRTC is avaible */ |
425 | 406 | if (!QB.webrtc) { |
426 | | - ui.updateMsg( {msg: 'webrtc_not_avaible'} ); |
| 407 | + qbApp.MsgBoard.update('webrtc_not_avaible'); |
427 | 408 | } else { |
428 | 409 | /** |
429 | 410 | * QB Event listener: |
|
473 | 454 | isDeviceAccess = true; |
474 | 455 | } else { |
475 | 456 | if(session.opponentsIDs.length > 1) { |
476 | | - ui.updateMsg({msg: 'call_stop', obj: {name: app.caller.full_name}}); |
| 457 | + qbApp.MsgBoard.update('call_stop', {name: app.caller.full_name}); |
477 | 458 | } |
478 | 459 | } |
479 | 460 |
|
|
502 | 483 |
|
503 | 484 | /** It's for p2p call */ |
504 | 485 | if(session.opponentsIDs.length === 1) { |
505 | | - ui.updateMsg({ |
506 | | - msg: 'p2p_call_stop', |
507 | | - obj: { |
508 | | - name: userInfo.full_name, |
509 | | - reason: 'not answered' |
510 | | - } |
511 | | - }); |
| 486 | + qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'not answered'}); |
512 | 487 | } |
513 | 488 |
|
514 | 489 | /** It's for groups call */ |
|
567 | 542 | takedCallCallee.push(userInfo); |
568 | 543 |
|
569 | 544 | if(app.currentSession.currentUserID === app.currentSession.initiatorID) { |
570 | | - ui.updateMsg( {msg: 'accept_call', obj: {users: takedCallCallee }} ); |
| 545 | + qbApp.MsgBoard.update('accept_call', {users: takedCallCallee}); |
571 | 546 | } |
572 | 547 | }; |
573 | 548 |
|
|
582 | 557 |
|
583 | 558 | /** It's for p2p call */ |
584 | 559 | if(session.opponentsIDs.length === 1) { |
585 | | - ui.updateMsg({ |
586 | | - msg: 'p2p_call_stop', |
587 | | - obj: { |
588 | | - name: userInfo.full_name, |
589 | | - reason: 'rejected the call' |
590 | | - } |
591 | | - }); |
| 560 | + qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'rejected the call'}); |
592 | 561 | } |
593 | 562 |
|
594 | 563 | /** It's for groups call */ |
|
606 | 575 |
|
607 | 576 | /** It's for p2p call */ |
608 | 577 | if(session.opponentsIDs.length === 1) { |
609 | | - ui.updateMsg({ |
610 | | - msg: 'p2p_call_stop', |
611 | | - obj: { |
612 | | - name: userInfo.full_name, |
613 | | - reason: 'hung up the call' |
614 | | - } |
615 | | - }); |
| 578 | + qbApp.MsgBoard.update('p2p_call_stop', {name: userInfo.full_name, reason: 'hung up the call'}); |
616 | 579 | } |
617 | 580 |
|
618 | 581 | /** It's for groups call */ |
|
704 | 667 | if (app.currentSession.currentUserID === app.currentSession.initiatorID && !isCallEnded) { |
705 | 668 | /** get array if users without user who ends call */ |
706 | 669 | takedCallCallee = _.reject(takedCallCallee, function(num){ return num.id !== +userID; }); |
707 | | - ui.updateMsg( {msg: 'accept_call', obj: {users: takedCallCallee }} ); |
| 670 | + qbApp.MsgBoard.update('accept_call', {users: takedCallCallee}); |
708 | 671 | } |
709 | 672 |
|
710 | 673 | if( _.isEmpty(app.currentSession) || isCallEnded ) { |
|
0 commit comments