3 appDS2.controller('collaborationControllerDS2', function ($scope,$http, $modal) {
4 console.log("modal", $modal);
10 $(document).ready(function () {
13 panelLayout = $('body').layout({
14 center__paneSelector: ".outer-center"
15 , west__paneSelector: ".outer-west"
16 , east__paneSelector: ".outer-east"
19 , spacing_open: 8 // ALL panes
20 , spacing_closed: 12 // ALL panes
22 , center__childOptions: {
23 center__paneSelector: ".inner-center"
24 , west__paneSelector: ".inner-west"
25 , east__paneSelector: ".inner-east"
28 , spacing_open: 8 // ALL panes
29 , spacing_closed: 8 // ALL panes
30 , west__spacing_closed: 12
31 , east__spacing_closed: 12
40 function initializeConnections() {
43 channelId = location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
44 var videoChannelId = channelId.concat("video");
45 var screenChannelId = channelId.concat("screen");
47 videoConnection = new RTCMultiConnection(videoChannelId);
48 screenConnection = new RTCMultiConnection(screenChannelId);
50 configConnection(videoConnection,true,true,false,true,false);
51 configConnection(screenConnection,false,false,true,false,true);
55 function configConnection(_connection, _audio, _video, _screen, _data, _oneway) {
56 _connection.session = {
57 audio: _audio, // by default, it is true
58 video: _video, // by default, it is true
65 _connection.direction = "one-to-one";
68 _connection.onmessage = function(e) {
71 console.debug(e.userid, 'posted', e.data);
72 console.log('latency:', e.latency, 'ms');
79 function assignStreamToDom() {
82 screenConnection.screenbody = document.querySelector('.screenContainer1');
83 screenConnection.videobody = document.querySelector('.videoContainer2');
85 videoConnection.screenbody = document.querySelector('.screenContainer2');
86 videoConnection.videobody = document.querySelector('.videoContainer1');
89 function maximizeLayout() {
91 // open the panes and maximize the window.
92 top.window.resizeTo(screen.availWidth,screen.availHeight);
93 panelLayout.open('west');
94 // panelLayout.open('south'); is not working due to state initialization problem; debug to find out. so replacing the call with work around below - hack.
95 $(".ui-layout-toggler-south-closed").first().click();
99 function minimizeLayout() {
101 // close the panes and minimize the window.
102 top.window.resizeTo(screen.availWidth - 2*screen.availWidth/3, screen.availHeight - screen.availHeight/2);
103 panelLayout.close('west');
104 // panelLayout.close('south'); is not working due to state initialization problem; debug to find out. so replacing the call with work around below - hack.
105 $(".ui-layout-toggler-south-opened").first().click();
108 function emptyContainers() {
109 $('.screenContainer1').empty();
110 $('.videoContainer2').empty();
112 $('.screenContainer2').empty();
113 $('.videoContainer1').empty();
116 function appendDIV(div, parent) {
117 if (typeof div === 'string') {
119 div = document.createElement('div');
120 div.innerHTML = content;
123 var chatOutput = document.getElementById('chat-output'),
124 fileProgress = document.getElementById('file-progress');
126 if (!parent) chatOutput.insertBefore(div, chatOutput.firstChild);
127 else fileProgress.insertBefore(div, fileProgress.firstChild);
130 $('#chat-input').focus();
133 function confirmClose() {
134 var message = "Are you sure you want to close the session?";
136 /* if(popupModalService != undefined) {
137 popupModalService.popupConfirmWin("Confirm", message, function(){ location.reload();});
141 if (confirm(message) == true) {
143 //window.opener.location.reload(); // go to the parent window
151 function notifyOthers() {
153 // var websocket = localStorage.getItem('notifySocket');
154 //if( websocket != null) {
155 // handling websocket peer broadcast session
156 var currentUser = "${sessionScope.user.sbcid}";
157 var initialPageVisit = "${sessionScope.initialPageVisit}";
160 var userList = location.search.split('chat_id=')[1].split('-');
161 for(var i=0;i<userList.length;i++) {
162 if(userList[i] !== currentUser) {
163 remoteUser = userList[i];
168 socketSetup(initialPageVisit, currentUser, remoteUser,"socketSend");
177 function makeChatVisible() {
179 $('#chat-input').css("visibility", 'visible');
184 /* on click button enabled*/
185 window.onload = function () {
186 document.getElementById('share-screen').onclick = function() {
189 videoConnection.close();
190 screenConnection.close();
196 videoConnection.open();
197 screenConnection.open();
207 document.getElementById('stop-share-screen').onclick = function() {
211 videoConnection.close();
212 screenConnection.close();
218 document.getElementById('view-screen').onclick = function() {
224 // timeout is required for the sharing to properly work
225 setTimeout(function() {
226 screenConnection.connect();
228 setTimeout(function() {
229 videoConnection.connect();
235 document.getElementById('chat-input').onkeypress = function(e) {
236 if (e.keyCode !== 13 || !this.value) return;
237 var message = "<b>${model.name}</b>: " + this.value;
240 // sending text message
241 videoConnection.send(message);
247 document.getElementById('file').onchange = function() {
248 videoConnection.send(this.files[0]);
253 //document.querySelector('.screenContainerPane').appenChild(document.querySelector('.screenContainer'));
254 //document.querySelector('.videoContainerPane').appendChild(document.querySelector('.videoContainer'));
256 //panelLayout.bindButton($('#share-screen'), 'open', 'outer-west');
257 //panelLayout.bindButton($('#stop-share-screen'), 'close', 'outer-west');
258 var videoConnection = null, screenConnection = null;
259 initializeConnections();
263 //document.getElementById('share-screen').click();