social_stream-presence 0.7.5 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/status/chat.png +0 -0
- data/app/assets/javascripts/chat_interface_manager.js.erb +42 -45
- data/app/assets/javascripts/chat_parser.js +5 -5
- data/app/assets/javascripts/chat_utilities.js +15 -11
- data/app/assets/javascripts/chat_window_manager.js +129 -26
- data/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +22 -3
- data/app/assets/javascripts/social_stream-presence.js +1 -0
- data/app/assets/javascripts/videochat.js.erb +459 -0
- data/app/assets/javascripts/xmpp_client_management.js.erb +303 -65
- data/app/assets/stylesheets/chat.css.scss +42 -1
- data/app/controllers/xmpp_controller.rb +17 -0
- data/app/views/chat/_index.html.erb +7 -2
- data/app/views/xmpp/getOpenTokSessionIDAndToken.xml.builder +6 -0
- data/config/locales/en.yml +22 -1
- data/config/locales/es.yml +23 -2
- data/config/routes.rb +2 -0
- data/lib/OpenTok/Exceptions.rb +11 -0
- data/lib/OpenTok/OpenTokSDK.rb +184 -0
- data/lib/OpenTok/Session.rb +27 -0
- data/lib/generators/social_stream/presence/templates/initializer.rb +7 -1
- data/lib/open_tok.rb +31 -0
- data/lib/opentok.rb +29 -0
- data/lib/social_stream-presence.rb +4 -0
- data/lib/social_stream/presence/version.rb +1 -1
- data/vendor/assets/javascripts/TB.min.js +4329 -0
- metadata +100 -64
Binary file
|
@@ -91,7 +91,7 @@ function settingChatBoxFunctions(){
|
|
91
91
|
|
92
92
|
if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
|
93
93
|
} else {
|
94
|
-
|
94
|
+
getChatBoxForSlug(guest_slug).chatbox("option", "boxManager").toggleBox(true);
|
95
95
|
};
|
96
96
|
});
|
97
97
|
|
@@ -268,33 +268,13 @@ function restartAwayTimer(){
|
|
268
268
|
//Update chatWindow Management
|
269
269
|
////////////////////
|
270
270
|
|
271
|
-
function
|
272
|
-
timerCounter++;
|
273
|
-
|
274
|
-
if((timerCounter > cyclesToRefresh)&&(requestContacts)) {
|
275
|
-
requestContacts = false;
|
276
|
-
updateChatWindow();
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
|
281
|
-
function refreshChatWindow(){
|
282
|
-
if(timerCounter > cyclesToRefresh){
|
283
|
-
updateChatWindow();
|
284
|
-
} else {
|
285
|
-
requestContacts = true;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
|
290
|
-
function updateChatWindow(){
|
291
|
-
var stropheConnectedAndOnlineStatus = ((isStropheConnected()) && (userStatus!="offline") && (!disconnectionFlag));
|
271
|
+
function updateChatWindow(){
|
292
272
|
timerCounter=0;
|
293
273
|
|
294
274
|
log("updateChatWindow()");
|
295
|
-
log("Connected " +
|
275
|
+
log("Connected " + isUserConnected());
|
296
276
|
|
297
|
-
if(!
|
277
|
+
if(! isUserConnected()){
|
298
278
|
loadDisconnectionDiv();
|
299
279
|
updateConnectedUsersOfMainChatBox();
|
300
280
|
return;
|
@@ -307,6 +287,7 @@ function updateChatWindow(){
|
|
307
287
|
hideConnectionBoxesFromDisconnectedSlugs();
|
308
288
|
setAllUserFunctions();
|
309
289
|
updateConnectedUsersOfMainChatBox();
|
290
|
+
checkForZeroUsersConnected();
|
310
291
|
if (isStropheConnected()) {
|
311
292
|
if (afterNewConnectionFlag){
|
312
293
|
afterNewConnectionFlag = false;
|
@@ -403,6 +384,7 @@ function updateInterfaceAfterPresenceStanza(slug,available){
|
|
403
384
|
} else {
|
404
385
|
hideConnectionBoxFromSlug(slug);
|
405
386
|
showOfflineChatNotificationForSlug(slug);
|
387
|
+
closeVideoSession(slug);
|
406
388
|
}
|
407
389
|
updateMainChatBoxAfterConnectionBoxChanges();
|
408
390
|
checkForZeroUsersConnected();
|
@@ -510,20 +492,17 @@ function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
|
|
510
492
|
return;
|
511
493
|
}
|
512
494
|
|
513
|
-
//Check
|
514
|
-
if (existsSlugChatBox(from_slug)) {
|
495
|
+
//Check slugs connectionBox
|
496
|
+
if (!existsSlugChatBox(from_slug)) {
|
515
497
|
//No connectionBox for this user!
|
516
498
|
var from_name = getNameFromSlug(from_slug);
|
517
499
|
if(! isAdminSlug(from_slug)){
|
518
|
-
|
519
|
-
|
500
|
+
updateChatWindow();
|
501
|
+
}
|
520
502
|
} else {
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
525
|
-
}
|
526
|
-
|
503
|
+
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
504
|
+
}
|
505
|
+
|
527
506
|
//Create or toggle from_slug's chatBox.
|
528
507
|
if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
|
529
508
|
} else {
|
@@ -564,16 +543,28 @@ function showChatNotification(notification,type,msg){
|
|
564
543
|
|
565
544
|
function showChatNotificationForSlug(slug,type,msg){
|
566
545
|
var notification = $("#" + slug).parent().find("div.ui-chatbox-notify");
|
567
|
-
|
546
|
+
if(notification.length==1){
|
547
|
+
showChatNotification(notification,type,msg);
|
548
|
+
}
|
568
549
|
}
|
569
550
|
|
570
551
|
function showOfflineChatNotificationForSlug(slug){
|
571
|
-
|
572
|
-
if(slug_chat_box!=null){
|
573
|
-
var name = slug_chat_box.attr("name")
|
574
|
-
var msg = name + ' ' + I18n.t('chat.notify.guestOffline');
|
552
|
+
var msg = I18n.t("chat.notify.guestOffline", {name: getNameFromSlug(slug)});
|
575
553
|
showChatNotificationForSlug(slug,"guestOffline",msg);
|
576
|
-
|
554
|
+
}
|
555
|
+
|
556
|
+
function showVideoChatNotificationForSlug(slug,msg){
|
557
|
+
showChatNotificationForSlug(slug,"videochat",msg);
|
558
|
+
}
|
559
|
+
|
560
|
+
function showVideoChatNotificationForSlugClientIssue(slug){
|
561
|
+
var msg = I18n.t("chat.notify.videochat.clientIssue", {name: getNameFromSlug(slug)});
|
562
|
+
showVideoChatNotificationForSlug(slug,msg);
|
563
|
+
}
|
564
|
+
|
565
|
+
function showVideoChatNotificationForSlugClientOffline(slug){
|
566
|
+
var msg = I18n.t("chat.notify.videochat.offline", {name: getNameFromSlug(slug)});
|
567
|
+
showVideoChatNotificationForSlug(slug,msg);
|
577
568
|
}
|
578
569
|
|
579
570
|
function hideChatNotification(notification){
|
@@ -587,8 +578,15 @@ function hideChatNotificationForSlug(slug){
|
|
587
578
|
hideChatNotification(notification);
|
588
579
|
}
|
589
580
|
|
590
|
-
function
|
591
|
-
|
581
|
+
function updateInterfaceAfterUsersDisconnect(){
|
582
|
+
updateNotificationsAfterUserDisconnect();
|
583
|
+
$.each(getAllSlugsWithVisibleVideoBoxes(), function(index, value) {
|
584
|
+
closeVideoSession(value);
|
585
|
+
});
|
586
|
+
}
|
587
|
+
|
588
|
+
function updateNotificationsAfterUserDisconnect(){
|
589
|
+
var notification = $("div.ui-chatbox-notify");
|
592
590
|
var msg = I18n.t('chat.notify.offline');
|
593
591
|
showChatNotification(notification,"userOffline",msg);
|
594
592
|
}
|
@@ -601,7 +599,7 @@ function hideAllNotifications(){
|
|
601
599
|
function updateAllNotifications(){
|
602
600
|
hideAllNotifications();
|
603
601
|
if(disconnectionFlag){
|
604
|
-
|
602
|
+
updateNotificationsAfterUserDisconnect();
|
605
603
|
} else {
|
606
604
|
//Notification for offline contacts
|
607
605
|
$.each(getAllDisconnectedSlugsWithChatBoxes(), function(index, value) {
|
@@ -617,8 +615,7 @@ function updateAllNotifications(){
|
|
617
615
|
|
618
616
|
function updateConnectedUsersOfMainChatBox(){
|
619
617
|
if(mainChatBox!=null){
|
620
|
-
|
621
|
-
if(stropheConnectedAndOnlineStatus){
|
618
|
+
if(isUserConnected()){
|
622
619
|
var connectedUsers = getConnectedSlugsLength();
|
623
620
|
changeMainChatBoxHeaderTitle( I18n.t('chat.title') + " (" + connectedUsers + ")");
|
624
621
|
changeMainChatBoxHeight(getChatBoxHeightRequiredForConnectionBoxes());
|
@@ -46,7 +46,7 @@ function parseContent(content){
|
|
46
46
|
return "<pre>" + content + "</pre>"
|
47
47
|
}
|
48
48
|
|
49
|
-
words = content.split(" ");
|
49
|
+
var words = content.split(" ");
|
50
50
|
for(i=0; i<words.length; i++){
|
51
51
|
words[i] = parseWord(words[i]);
|
52
52
|
}
|
@@ -131,18 +131,18 @@ function parseWord(word){
|
|
131
131
|
}
|
132
132
|
|
133
133
|
function splitFirst(word,key){
|
134
|
-
split=[]
|
135
|
-
cut = word.split(key);
|
134
|
+
var split=[]
|
135
|
+
var cut = word.split(key);
|
136
136
|
split[0]=cut[0]
|
137
137
|
cut.shift()
|
138
|
-
paste = cut.join(key)
|
138
|
+
var paste = cut.join(key)
|
139
139
|
split[1]=paste
|
140
140
|
return split
|
141
141
|
}
|
142
142
|
|
143
143
|
function buildIconImage(icon){
|
144
144
|
if (icon in chatIcons){
|
145
|
-
image_file = chatIcons[icon]
|
145
|
+
var image_file = chatIcons[icon]
|
146
146
|
return "<img class=\"chatEmoticon\" src=\"/assets/emoticons/" + image_file + "\"/>";
|
147
147
|
}
|
148
148
|
return icon
|
@@ -93,7 +93,7 @@ function userChatDataInputControl(){
|
|
93
93
|
////////////////////
|
94
94
|
|
95
95
|
var lastMessageTimes = new Array();
|
96
|
-
//lastMessageTimes['
|
96
|
+
//lastMessageTimes['slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
|
97
97
|
|
98
98
|
var timeBetweenMessages = 500; //mseconds
|
99
99
|
|
@@ -181,11 +181,6 @@ function floodControl() {
|
|
181
181
|
};
|
182
182
|
|
183
183
|
|
184
|
-
function initControlFlood(){
|
185
|
-
$(".ui-chatbox-input-box")
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
184
|
////////////////////
|
190
185
|
//Bounce chatbox control
|
191
186
|
////////////////////
|
@@ -193,21 +188,30 @@ var lastBounceTimes = new Array();
|
|
193
188
|
var timeBetweenBounces = 5000; //mseconds
|
194
189
|
|
195
190
|
function mustBounceBoxForChatWindow(jqueryUIChatbox){
|
196
|
-
var from_slug = $($(jqueryUIChatbox.elem.uiChatbox).find(".ui-chatbox-content").children()[0]).attr("id")
|
197
191
|
|
192
|
+
var slug = jqueryUIChatbox.elem.uiChatbox.find(".ui-chatbox-content").find(".ui-chatbox-log").attr("id")
|
193
|
+
|
194
|
+
if (typeof slug == 'undefined') {
|
195
|
+
return false;
|
196
|
+
}
|
197
|
+
|
198
|
+
if((slug in contactsInfo)&&(contactsInfo[slug].videoChatStatus!="disconnected")){
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
|
198
202
|
var t = (new Date()).getTime();
|
199
203
|
|
200
|
-
if(!(
|
201
|
-
lastBounceTimes[
|
204
|
+
if(!(slug in lastBounceTimes)){
|
205
|
+
lastBounceTimes[slug] = t;
|
202
206
|
return true;
|
203
207
|
}
|
204
208
|
|
205
|
-
var lastBounceTime = lastBounceTimes[
|
209
|
+
var lastBounceTime = lastBounceTimes[slug];
|
206
210
|
|
207
211
|
if (t - lastBounceTime < timeBetweenBounces) {
|
208
212
|
return false;
|
209
213
|
} else {
|
210
|
-
lastBounceTimes[
|
214
|
+
lastBounceTimes[slug] = t;
|
211
215
|
return true;
|
212
216
|
}
|
213
217
|
|
@@ -5,8 +5,8 @@
|
|
5
5
|
var nBox = 0;
|
6
6
|
var maxBox = 5;
|
7
7
|
var chatBoxWidth = 230;
|
8
|
-
var chatBoxHeight =
|
9
|
-
var videoBoxHeight =
|
8
|
+
var chatBoxHeight = 180;
|
9
|
+
var videoBoxHeight = 145;
|
10
10
|
var visibleChatBoxes = new Array();
|
11
11
|
var offsetForFlowBox = 0;
|
12
12
|
var chatBoxSeparation = chatBoxWidth+12;
|
@@ -150,13 +150,66 @@ function getChatBoxForSlug(slug){
|
|
150
150
|
}
|
151
151
|
}
|
152
152
|
|
153
|
+
function getChatBoxHeaderForSlug(slug){
|
154
|
+
var chatBox = getChatBoxForSlug(slug);
|
155
|
+
if(chatBox!=null){
|
156
|
+
return chatBox.parent().parent().find(".ui-chatbox-titlebar")
|
157
|
+
} else {
|
158
|
+
return null;
|
159
|
+
}
|
160
|
+
}
|
153
161
|
|
154
|
-
function
|
155
|
-
var
|
156
|
-
|
162
|
+
function getChatBoxButtonsForSlug(slug){
|
163
|
+
var chatBoxHeader = getChatBoxHeaderForSlug(slug);
|
164
|
+
if(chatBoxHeader!=null){
|
165
|
+
return chatBoxHeader.find(".ui-chatbox-icon");
|
166
|
+
} else {
|
167
|
+
return null;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
function getChatBoxButtonForSlug(slug,button){
|
172
|
+
var chatBoxButtons = getChatBoxButtonsForSlug(slug);
|
173
|
+
if(chatBoxButtons!=null){
|
174
|
+
switch (button){
|
175
|
+
case "close":
|
176
|
+
return chatBoxButtons[0];
|
177
|
+
break;
|
178
|
+
case "min":
|
179
|
+
return chatBoxButtons[1];
|
180
|
+
break;
|
181
|
+
case "video":
|
182
|
+
return chatBoxButtons[2];
|
183
|
+
break;
|
184
|
+
case "videoChange":
|
185
|
+
return chatBoxButtons[3];
|
186
|
+
break;
|
187
|
+
default : return null;
|
188
|
+
}
|
189
|
+
} else {
|
190
|
+
return null;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
|
195
|
+
function getAllSlugsWithChatOrVideoBoxes(){
|
196
|
+
var slugsWithChatBox = [];
|
197
|
+
var slugsWithVideoBox = [];
|
198
|
+
$.each(getAllChatBoxes(), function(index, value) {
|
199
|
+
if($(value).parent().find(".ui-videobox").is(":visible")){
|
200
|
+
slugsWithVideoBox.push($(value).attr("id"))
|
201
|
+
}
|
157
202
|
slugsWithChatBox.push($(value).attr("id"))
|
158
203
|
});
|
159
|
-
|
204
|
+
return [slugsWithChatBox,slugsWithVideoBox];
|
205
|
+
}
|
206
|
+
|
207
|
+
function getAllSlugsWithChatBoxes(){
|
208
|
+
return getAllSlugsWithChatOrVideoBoxes()[0];
|
209
|
+
}
|
210
|
+
|
211
|
+
function getAllSlugsWithVisibleVideoBoxes(){
|
212
|
+
return getAllSlugsWithChatOrVideoBoxes()[1];
|
160
213
|
}
|
161
214
|
|
162
215
|
function getAllDisconnectedSlugsWithChatBoxes(){
|
@@ -209,41 +262,88 @@ function rotatePriority(guest_slug){
|
|
209
262
|
//Video Window Manager functions
|
210
263
|
////////////////////
|
211
264
|
|
212
|
-
function
|
213
|
-
|
265
|
+
function getVideoBoxForSlug(slug){
|
266
|
+
var videoBox = $("#" + slug).parent().find("div.ui-videobox");
|
267
|
+
if(videoBox.length == 1){
|
268
|
+
return videoBox;
|
269
|
+
} else {
|
270
|
+
return null;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
function getPublisherVideoBoxForSlug(slug){
|
275
|
+
var pubDiv = $("#stream_publish_videochat_" + slug);
|
276
|
+
if (pubDiv.length > 0) {
|
277
|
+
return pubDiv
|
278
|
+
} else {
|
279
|
+
return null;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
function setVideoBoxContent(slug,embed){
|
284
|
+
var videoBox = getVideoBoxForSlug(slug);
|
285
|
+
if(videoBox!=null){
|
286
|
+
videoBox.html(embed);
|
287
|
+
}
|
214
288
|
}
|
215
289
|
|
216
|
-
function
|
217
|
-
|
218
|
-
|
219
|
-
|
290
|
+
function addVideoBoxContent(slug,embed){
|
291
|
+
var videoBox = getVideoBoxForSlug(slug);
|
292
|
+
if(videoBox!=null){
|
293
|
+
videoBox.append(embed);
|
294
|
+
}
|
220
295
|
}
|
221
296
|
|
297
|
+
function showVideoBox(chatBox){
|
298
|
+
chatBox.chatbox("option", "video",videoBoxHeight);
|
299
|
+
}
|
222
300
|
|
223
|
-
function hideVideoBox(
|
224
|
-
|
225
|
-
chatBox.chatbox("option", "video", 0);
|
301
|
+
function hideVideoBox(chatBox){
|
302
|
+
chatBox.chatbox("option", "video", 0);
|
226
303
|
}
|
227
304
|
|
228
305
|
|
229
306
|
//Function called from JQuery UI Plugin
|
230
|
-
function
|
231
|
-
|
232
|
-
|
307
|
+
function toggleVideoBox(uiElement){
|
308
|
+
var slug = $(uiElement.element).attr("id");
|
309
|
+
clickVideoChatButton(slug);
|
233
310
|
}
|
234
311
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
312
|
+
//Function called from JQuery UI Plugin
|
313
|
+
function toggleVideoBoxChange(uiElement){
|
314
|
+
var slug = $(uiElement.element).attr("id");
|
315
|
+
clickVideoChangeChatButton(slug);
|
316
|
+
}
|
317
|
+
|
318
|
+
function toggleVideoBoxForSlug(slug,force){
|
319
|
+
var aux;
|
320
|
+
var chatBox = getChatBoxForSlug(slug);
|
321
|
+
|
322
|
+
if(chatBox==null) {
|
323
|
+
return null;
|
324
|
+
}
|
325
|
+
|
326
|
+
if(typeof force != 'undefined'){
|
327
|
+
aux = force;
|
239
328
|
} else {
|
240
|
-
|
329
|
+
if (chatBox.chatbox("option", "video")==0){
|
330
|
+
aux=true;
|
331
|
+
} else {
|
332
|
+
aux=false;
|
333
|
+
}
|
241
334
|
}
|
335
|
+
|
336
|
+
if (aux){
|
337
|
+
//Show
|
338
|
+
showVideoBox(chatBox);
|
339
|
+
return true;
|
340
|
+
} else {
|
341
|
+
//Hide
|
342
|
+
hideVideoBox(chatBox);
|
343
|
+
return false;
|
344
|
+
}
|
242
345
|
}
|
243
346
|
|
244
|
-
function getVideoEmbedForSlug(slug){
|
245
|
-
return "<img src=\"http://www.batiburrillo.net/wp-content/uploads/2011/03/Freemake.jpg?cda6c1\" width=\"" + (chatBoxWidth-20) + "\"/>"
|
246
|
-
}
|
247
347
|
|
248
348
|
|
249
349
|
|
@@ -304,6 +404,9 @@ function createMainChatBox(){
|
|
304
404
|
$(mainChatBox).css('overflow-x','hidden')
|
305
405
|
$(mainChatBox).css('overflow-y','hidden')
|
306
406
|
|
407
|
+
//Minimize
|
408
|
+
mainChatBox.parent().toggle(false);
|
409
|
+
|
307
410
|
//Header title
|
308
411
|
updateConnectedUsersOfMainChatBox();
|
309
412
|
}
|
@@ -176,10 +176,10 @@
|
|
176
176
|
'ui-chatbox-icon' + ' ui-videobox-icon'
|
177
177
|
)
|
178
178
|
.attr('role', 'button')
|
179
|
-
|
180
|
-
|
179
|
+
.hover(function() {uiChatboxTitlebarVideo.addClass('ui-state-hover');},
|
180
|
+
function() {uiChatboxTitlebarVideo.removeClass('ui-state-hover');})
|
181
181
|
.click(function(event) {
|
182
|
-
|
182
|
+
toggleVideoBox(self)
|
183
183
|
return false;
|
184
184
|
})
|
185
185
|
.appendTo(uiChatboxTitlebar),
|
@@ -189,6 +189,25 @@
|
|
189
189
|
.appendTo(uiChatboxTitlebarVideo),
|
190
190
|
|
191
191
|
|
192
|
+
//Change video-window Menu button
|
193
|
+
uiChatboxTitlebarVideoChange = (self.uiChatboxTitlebarVideoChange = $('<a href="#"></a>'))
|
194
|
+
.addClass('ui-corner-all ' +
|
195
|
+
'ui-chatbox-icon' + ' ui-videobox-icon-change'
|
196
|
+
)
|
197
|
+
.attr('role', 'button')
|
198
|
+
.hover(function() {uiChatboxTitlebarVideoChange.addClass('ui-state-hover');},
|
199
|
+
function() {uiChatboxTitlebarVideoChange.removeClass('ui-state-hover');})
|
200
|
+
.click(function(event) {
|
201
|
+
toggleVideoBoxChange(self)
|
202
|
+
return false;
|
203
|
+
})
|
204
|
+
.appendTo(uiChatboxTitlebar),
|
205
|
+
uiChatboxTitlebarVideoText = $('<span></span>')
|
206
|
+
.addClass('ui-icon-newwin ' + 'chat-thick ' + ' chat-videoPublisherthick' )
|
207
|
+
.text('')
|
208
|
+
.appendTo(uiChatboxTitlebarVideoChange),
|
209
|
+
|
210
|
+
|
192
211
|
// content
|
193
212
|
uiChatboxContent = (self.uiChatboxContent = $('<div></div>'))
|
194
213
|
.addClass('ui-widget-content ' +
|