social_stream-presence 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/emoticons/beer.png +0 -0
- data/app/assets/images/emoticons/clock.png +0 -0
- data/app/assets/images/emoticons/face-raspberry.png +0 -0
- data/app/assets/images/emoticons/face-sad.png +0 -0
- data/app/assets/images/emoticons/face-smile.png +0 -0
- data/app/assets/images/emoticons/face-tired.png +0 -0
- data/app/assets/images/emoticons/face-wink.png +0 -0
- data/app/assets/images/emoticons/present.png +0 -0
- data/app/assets/images/emoticons/rain.png +0 -0
- data/app/assets/images/emoticons/sun.png +0 -0
- data/app/assets/javascripts/xmpp_client.js.erb +417 -38
- data/app/assets/stylesheets/chat.css +20 -0
- data/app/helpers/xmpp_helper.rb +1 -1
- data/app/views/xmpp/_chat.html.erb +2 -0
- data/app/views/xmpp/_chat_off.html.erb +13 -5
- data/lib/social_stream/presence/engine.rb +1 -1
- data/lib/social_stream/presence/version.rb +1 -1
- metadata +13 -3
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -3,7 +3,7 @@
|
|
3
3
|
////////////////////
|
4
4
|
|
5
5
|
function log(msg) {
|
6
|
-
console.log(msg)
|
6
|
+
//console.log(msg)
|
7
7
|
}
|
8
8
|
|
9
9
|
|
@@ -17,6 +17,12 @@ statusMessage['away'] = "Away";
|
|
17
17
|
statusMessage['xa'] = "Away";
|
18
18
|
statusMessage['dnd'] = "Busy";
|
19
19
|
|
20
|
+
var statusIcons = new Array();
|
21
|
+
statusIcons[''] = "available";
|
22
|
+
statusIcons['chat'] = "available";
|
23
|
+
statusIcons['away'] = "away";
|
24
|
+
statusIcons['xa'] = "away";
|
25
|
+
statusIcons['dnd'] = "dnd";
|
20
26
|
|
21
27
|
////////////////////
|
22
28
|
//Connect functions
|
@@ -56,6 +62,33 @@ function connectToServerWithPassword(chatPassword){
|
|
56
62
|
return true;
|
57
63
|
}
|
58
64
|
|
65
|
+
|
66
|
+
////////////////////
|
67
|
+
//Reconnect button functions
|
68
|
+
////////////////////
|
69
|
+
|
70
|
+
var connectButtonTimer;
|
71
|
+
var periodBetweenAttempts=15; //(seg)
|
72
|
+
var connectButtonTimerCounter=periodBetweenAttempts;
|
73
|
+
|
74
|
+
function connectButtonTimerFunction(){
|
75
|
+
if(connectButtonTimerCounter < periodBetweenAttempts){
|
76
|
+
connectButtonTimerCounter++;
|
77
|
+
} else if (connectButtonTimerCounter == periodBetweenAttempts) {
|
78
|
+
$("#chat_header_title").html('<%=I18n.t('chat.disconnected')%>')
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
function requestConnectToChat(){
|
83
|
+
if (connectButtonTimerCounter > (periodBetweenAttempts-1)) {
|
84
|
+
connectButtonTimerCounter=0;
|
85
|
+
$("#chat_header_title").html('<%=I18n.t('chat.connecting')%>')
|
86
|
+
return true
|
87
|
+
} else {
|
88
|
+
return false
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
59
92
|
////////////////////
|
60
93
|
//Strophe functions
|
61
94
|
////////////////////
|
@@ -114,9 +147,9 @@ function onConnect(status) {
|
|
114
147
|
setTimeout ("onReconnect()", 3000);
|
115
148
|
} else if (status == Strophe.Status.AUTHFAIL) {
|
116
149
|
log('Strophe authentication fail.');
|
117
|
-
|
118
|
-
|
119
|
-
|
150
|
+
if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)){
|
151
|
+
sessionStorage.setItem("ss_user_pass",null);
|
152
|
+
}
|
120
153
|
userConnected = false;
|
121
154
|
} else if (status == Strophe.Status.ERROR) {
|
122
155
|
log('Strophe error.');
|
@@ -165,26 +198,31 @@ function onMessage(msg) {
|
|
165
198
|
var from_slug = from.split("@")[0];
|
166
199
|
var from_name = $("#" + from_slug).attr("name");
|
167
200
|
var from_jid = from_slug + "@" + domain;
|
168
|
-
|
169
|
-
log(from + ' says: ' + Strophe.getText(body));
|
201
|
+
|
170
202
|
|
171
203
|
if (typeof ($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
|
204
|
+
//No connectionBox for this user!
|
172
205
|
var from_name = from_slug;
|
206
|
+
refreshChatWindow();
|
173
207
|
} else {
|
208
|
+
showConnectionBoxFromSlug(from_slug);
|
174
209
|
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
175
210
|
}
|
176
211
|
|
177
|
-
if (mustPlaySoundForChatWindow(window[from_slug])){
|
178
|
-
playSound("onMessageAudio");
|
179
|
-
}
|
180
|
-
|
181
212
|
if (createChatBox(from_slug,from_name,from_jid,user_name,user_jid)) {
|
182
213
|
} else {
|
183
|
-
window[from_slug].chatbox("option", "boxManager").toggleBox(true);
|
214
|
+
window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
|
184
215
|
}
|
185
|
-
|
186
|
-
|
216
|
+
|
217
|
+
content = parseContent(Strophe.getText(body));
|
218
|
+
//Send message to chatBox and post-message functions.
|
219
|
+
$("#" + from_slug).chatbox("option", "boxManager").addMsg(from_name, content);
|
187
220
|
rotatePriority(from_slug);
|
221
|
+
blinkTitleOnMessage(from_name);
|
222
|
+
if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])){
|
223
|
+
playSound("onMessageAudio");
|
224
|
+
}
|
225
|
+
|
188
226
|
}
|
189
227
|
|
190
228
|
// we must return true to keep the handler alive.
|
@@ -192,25 +230,259 @@ function onMessage(msg) {
|
|
192
230
|
return true;
|
193
231
|
}
|
194
232
|
|
233
|
+
///////////////////////////////////////////////////////
|
234
|
+
//Allow new features in chat msg like links, images, icons, ...
|
235
|
+
///////////////////////////////////////////////////////
|
236
|
+
|
237
|
+
var chatIcons = new Array();
|
238
|
+
chatIcons[':)'] = "face-smile.png";
|
239
|
+
chatIcons[':('] = "face-sad.png";
|
240
|
+
chatIcons['(B)'] = "beer.png";
|
241
|
+
chatIcons['(C)'] = "clock.png";
|
242
|
+
chatIcons['(P)'] = "present.png";
|
243
|
+
chatIcons[':P']= "face-raspberry.png";
|
244
|
+
chatIcons[':Z']= "face-tired.png";
|
245
|
+
chatIcons['(R)']= "rain.png";
|
246
|
+
chatIcons['(S)']= "sun.png";
|
247
|
+
chatIcons[';)']= "face-wink.png";
|
248
|
+
|
249
|
+
|
250
|
+
function parseContent(content){
|
251
|
+
|
252
|
+
var html_tag_pattern=/.*\<[^>]+>.*/g
|
253
|
+
if (html_tag_pattern.test(content)){
|
254
|
+
content = content.replace(/>/g, ">");
|
255
|
+
content = content.replace(/</g, "<");
|
256
|
+
return "<pre>" + content + "</pre>"
|
257
|
+
}
|
258
|
+
|
259
|
+
words = content.split(" ");
|
260
|
+
for(i=0; i<words.length; i++){
|
261
|
+
words[i] = parseWord(words[i]);
|
262
|
+
}
|
263
|
+
|
264
|
+
return words.join(" ");
|
265
|
+
}
|
266
|
+
|
267
|
+
function parseWord(word){
|
268
|
+
|
269
|
+
//Look for empty words
|
270
|
+
if (word.trim()==""){
|
271
|
+
return word
|
272
|
+
}
|
273
|
+
|
274
|
+
//Look for simple words
|
275
|
+
var simple_word_pattern=/^[aA-zZ0-9]+$/g
|
276
|
+
if (simple_word_pattern.test(word)){
|
277
|
+
return word
|
278
|
+
}
|
279
|
+
|
280
|
+
//Look for http urls
|
281
|
+
var http_urls_pattern=/(http(s)?:\/\/)([aA-zZ0-9%=_&+?])+([./-][aA-zZ0-9%=_&+?]+)*[/]?/g
|
282
|
+
http_urls = word.match(http_urls_pattern)
|
283
|
+
if (http_urls!=null){
|
284
|
+
url = http_urls[0]
|
285
|
+
type = getUrlType(url);
|
286
|
+
|
287
|
+
switch(type){
|
288
|
+
case "link":
|
289
|
+
link = buildUrlLink(url,url)
|
290
|
+
subwords = word.split(url)
|
291
|
+
word = parseWord(subwords[0]) + link + parseWord(subwords[1])
|
292
|
+
break;
|
293
|
+
case "image":
|
294
|
+
imageLink = buildImageLink(url);
|
295
|
+
subwords = word.split(url)
|
296
|
+
word = parseWord(subwords[0]) + imageLink + parseWord(subwords[1])
|
297
|
+
break;
|
298
|
+
default:
|
299
|
+
}
|
300
|
+
return word
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
//Look for www urls
|
305
|
+
var www_urls_pattern = /(www[.])([aA-zZ0-9%=_&+?])+([.][aA-zZ0-9%=_&+?]+)*[/]?/g
|
306
|
+
www_urls = word.match(www_urls_pattern)
|
307
|
+
if (www_urls!=null){
|
308
|
+
url = www_urls[0]
|
309
|
+
type = getUrlType(url);
|
310
|
+
|
311
|
+
switch(type){
|
312
|
+
case "link":
|
313
|
+
link = buildUrlLink("http://" + url,url)
|
314
|
+
subwords = word.split(url)
|
315
|
+
word = parseWord(subwords[0]) + link + parseWord(subwords[1])
|
316
|
+
break;
|
317
|
+
case "image":
|
318
|
+
imageLink = buildImageLink("http://" + url);
|
319
|
+
subwords = word.split(url)
|
320
|
+
word = parseWord(subwords[0]) + imageLink + parseWord(subwords[1])
|
321
|
+
break;
|
322
|
+
default:
|
323
|
+
}
|
324
|
+
return word
|
325
|
+
}
|
326
|
+
|
327
|
+
//Look for icons: Directly replace
|
328
|
+
var icons_a_pattern=/\(([A-Z])+\)/g
|
329
|
+
var icons_b_pattern=/(:|;)([()A-Z])(.)*/g
|
330
|
+
if (((icons_a_pattern.test(word))) || (icons_b_pattern.test(word))) {
|
331
|
+
for (var i in chatIcons) {
|
332
|
+
word = word.replace(buildRegex(i), buildIconImage(i))
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
//Look for icons with Regex
|
337
|
+
// var icons_a_pattern=/\(([A-Z])+\)/g
|
338
|
+
// if (icons_a_pattern.test(word)){
|
339
|
+
// icon = word.replace(/[^(]*(\([A-Z]+\))(\([A-Z]+\))?(.)*/g, "$1")
|
340
|
+
// subwords = splitFirst(word,icon)
|
341
|
+
// image = buildIconImage(icon);
|
342
|
+
// return subwords[0] + image + subwords[1];
|
343
|
+
// }
|
344
|
+
|
345
|
+
// var icons_b_pattern=/:([()A-Z])(.)*/g
|
346
|
+
// if (icons_b_pattern.test(word)){
|
347
|
+
// icon = word.replace(/[aA-zZ]*(:[()A-Z])(.)*/g, "$1")
|
348
|
+
// subwords = splitFirst(word,icon)
|
349
|
+
// image = buildIconImage(icon);
|
350
|
+
// return subwords[0] + image + subwords[1];
|
351
|
+
//return parseWord(subwords[0]) + image + parseWord(subwords[1]);
|
352
|
+
// }
|
353
|
+
|
354
|
+
|
355
|
+
//No special content detected
|
356
|
+
return word
|
357
|
+
}
|
358
|
+
|
359
|
+
function splitFirst(word,key){
|
360
|
+
split=[]
|
361
|
+
cut = word.split(key);
|
362
|
+
split[0]=cut[0]
|
363
|
+
cut.shift()
|
364
|
+
paste = cut.join(key)
|
365
|
+
split[1]=paste
|
366
|
+
return split
|
367
|
+
}
|
368
|
+
|
369
|
+
function buildIconImage(icon){
|
370
|
+
if (icon in chatIcons){
|
371
|
+
image_file = chatIcons[icon]
|
372
|
+
image = "<img class=\"chatIcon\" src=\"assets/emoticons/" + image_file + "\"/>";
|
373
|
+
return image
|
374
|
+
}
|
375
|
+
return icon
|
376
|
+
}
|
377
|
+
|
378
|
+
function buildUrlLink(url,name){
|
379
|
+
link = "<a target=\"_blank\" class=\"chatLink\" href=\"" + url + "\">" + name + "</a>";
|
380
|
+
return link
|
381
|
+
}
|
382
|
+
|
383
|
+
function buildImageLink(url){
|
384
|
+
link = "<a target=\"_blank\" class=\"chatImageLink\" href=\"" + url + "\">" + "<img class=\"chatImage\" src=\"" + url + "\"/>" + "</a>";
|
385
|
+
return link
|
386
|
+
}
|
387
|
+
|
388
|
+
|
389
|
+
function buildRegex(word){
|
390
|
+
word = word.replace(")","\\)")
|
391
|
+
word = word.replace("(","\\(")
|
392
|
+
pattern = "(" + word + ")";
|
393
|
+
pattern = buildPattern(pattern)
|
394
|
+
return (new RegExp(pattern,'g'));
|
395
|
+
}
|
396
|
+
|
397
|
+
function buildPattern(pattern){
|
398
|
+
//Escape pattern special characters
|
399
|
+
pattern = pattern.replace("+","\\+")
|
400
|
+
pattern = pattern.replace("?","\\?")
|
401
|
+
return pattern
|
402
|
+
}
|
403
|
+
|
404
|
+
function getUrlType(url){
|
405
|
+
urlArray = url.split(".");
|
406
|
+
if (urlArray!=null && urlArray.length>0){
|
407
|
+
extension= urlArray[urlArray.length-1]
|
408
|
+
} else {
|
409
|
+
extension = null;
|
410
|
+
}
|
411
|
+
|
412
|
+
switch(extension){
|
413
|
+
case "jpg":
|
414
|
+
return "image"
|
415
|
+
break;
|
416
|
+
case "png":
|
417
|
+
return "image"
|
418
|
+
break;
|
419
|
+
case "gif":
|
420
|
+
return "image"
|
421
|
+
break;
|
422
|
+
default:
|
423
|
+
return "link"
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
|
195
428
|
|
196
429
|
function onPresence(presence) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
430
|
+
|
431
|
+
//Check presence stanza type
|
432
|
+
ptype = $(presence).attr('type');
|
433
|
+
|
434
|
+
switch (ptype){
|
435
|
+
case undefined:
|
436
|
+
processAvailablePresenceStanza(presence)
|
437
|
+
break;
|
438
|
+
case "available":
|
439
|
+
processAvailablePresenceStanza(presence)
|
440
|
+
break;
|
441
|
+
case "unavailable":
|
442
|
+
processUnavailablePresenceStanza(presence)
|
443
|
+
break;
|
444
|
+
default :
|
445
|
+
//Stanza type not recognize
|
446
|
+
processAvailablePresenceStanza(presence)
|
447
|
+
}
|
448
|
+
|
203
449
|
return true;
|
204
450
|
}
|
205
451
|
|
452
|
+
function processAvailablePresenceStanza(presence){
|
453
|
+
from = $(presence).attr('from');
|
454
|
+
slug = from.split("@")[0];
|
455
|
+
|
456
|
+
if (slug != user_slug) {
|
457
|
+
if (getConnectionBoxFromSlug(slug)!=null){
|
458
|
+
status = $(presence).find('show').text();
|
459
|
+
setUserIconStatus(slug, status);
|
460
|
+
if (cacheConnectedUsers.indexOf(slug) != -1) {
|
461
|
+
showConnectionBoxFromSlug(slug);
|
462
|
+
}
|
463
|
+
} else {
|
464
|
+
setTimeout("refreshChatWindow()", 3000);
|
465
|
+
}
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
function processUnavailablePresenceStanza(presence){
|
470
|
+
from = $(presence).attr('from');
|
471
|
+
slug = from.split("@")[0];
|
472
|
+
|
473
|
+
if (slug != user_slug) {
|
474
|
+
if (getConnectionBoxFromSlug(slug)!=null){
|
475
|
+
hideConnectionBoxFromSlug(slug)
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
206
479
|
|
207
480
|
function sendChatMessage(from,to,text){
|
208
481
|
var type = "chat";
|
209
482
|
var body= $build("body");
|
210
483
|
body.t(text);
|
211
484
|
var message = $msg({to: to, from: from, type: 'chat'}).cnode(body.tree());
|
212
|
-
connection.send(message.tree());
|
213
|
-
log(from + ' says: ' + text + ' to ' + to);
|
485
|
+
connection.send(message.tree());
|
214
486
|
resumeAwayTimerIfAway();
|
215
487
|
return true;
|
216
488
|
}
|
@@ -302,7 +574,7 @@ function setUserFunctions(){
|
|
302
574
|
|
303
575
|
if (createChatBox(guest_slug, guest_name, guest_jid, user_name, user_jid)) {
|
304
576
|
} else {
|
305
|
-
window[guest_slug].chatbox("option", "boxManager").toggleBox(true);
|
577
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "boxManager").toggleBox(true);
|
306
578
|
};
|
307
579
|
});
|
308
580
|
|
@@ -401,18 +673,121 @@ function sendStatus(status){
|
|
401
673
|
|
402
674
|
|
403
675
|
function mustPlaySoundForChatWindow(chatBox){
|
676
|
+
//Deny conditions
|
404
677
|
if(userStatus == "dnd"){
|
405
678
|
return false;
|
406
679
|
}
|
407
680
|
|
408
|
-
|
681
|
+
//Accept conditions
|
682
|
+
if (!chatFocus){
|
409
683
|
return true;
|
410
|
-
|
684
|
+
}
|
411
685
|
|
412
|
-
//
|
413
|
-
return
|
686
|
+
//Default action
|
687
|
+
return false
|
688
|
+
}
|
689
|
+
|
690
|
+
|
691
|
+
var chatFocus;
|
692
|
+
|
693
|
+
function onChatBlur() {
|
694
|
+
chatFocus = false;
|
695
|
+
};
|
696
|
+
|
697
|
+
function onChatFocus(){
|
698
|
+
stopBlink();
|
699
|
+
titles = []; //Remove titles after StopBlink!
|
700
|
+
chatFocus = true;
|
701
|
+
};
|
702
|
+
|
703
|
+
function initFocusListeners(){
|
704
|
+
if (/*@cc_on!@*/false) { // check for Internet Explorer
|
705
|
+
document.onfocusin = onFocus;
|
706
|
+
document.onfocusout = onBlur;
|
707
|
+
} else {
|
708
|
+
window.onfocus = onChatFocus;
|
709
|
+
window.onblur = onChatBlur;
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
|
714
|
+
var blinkTimer;
|
715
|
+
var titles=[];
|
716
|
+
|
717
|
+
function blinkTitle(titles,index){
|
718
|
+
$(document).attr("title", titles[index]);
|
719
|
+
index = (index+1)%titles.length
|
720
|
+
blinkTimer=setTimeout(function(){blinkTitle(titles,index)}, 2000);
|
414
721
|
}
|
415
722
|
|
723
|
+
function stopBlink(){
|
724
|
+
clearTimeout(blinkTimer);
|
725
|
+
if (titles.length > 0) {
|
726
|
+
$(document).attr("title", titles[0]);
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
function blinkTitleOnMessage(username){
|
731
|
+
if (!chatFocus){
|
732
|
+
if (titles.length==0){
|
733
|
+
titles.push($(document).attr("title"))
|
734
|
+
}
|
735
|
+
if (titles.indexOf(username) == -1){
|
736
|
+
titles.push(username + " says...")
|
737
|
+
}
|
738
|
+
stopBlink();
|
739
|
+
blinkTitle(titles,titles.length-1);
|
740
|
+
}
|
741
|
+
}
|
742
|
+
|
743
|
+
function getConnectionBoxFromSlug(slug){
|
744
|
+
if ($('div.user_presence[slug=' + slug + ']').length > 0){
|
745
|
+
return ($('div.user_presence[slug=' + slug + ']'))[0];
|
746
|
+
} else {
|
747
|
+
return null;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
|
751
|
+
|
752
|
+
var cacheConnectedUsers = [];
|
753
|
+
function hideConnectionBoxFromSlug(slug){
|
754
|
+
if ($('div.user_presence[slug=' + slug + ']').length > 0){
|
755
|
+
$('div.user_presence[slug=' + slug + ']').hide();
|
756
|
+
if(cacheConnectedUsers.indexOf(slug)==-1){
|
757
|
+
cacheConnectedUsers.push(slug);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
function showConnectionBoxFromSlug(slug){
|
763
|
+
if ($('div.user_presence[slug=' + slug + ']').length > 0){
|
764
|
+
if (!($('div.user_presence[slug=' + slug + ']').is(":visible"))){
|
765
|
+
$('div.user_presence[slug=' + slug + ']').show();
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
function setUserIconStatus(slug, status){
|
771
|
+
if (status in statusIcons) {
|
772
|
+
iconName = statusIcons[status];
|
773
|
+
var $img_status = $('img.presence_status');
|
774
|
+
connectionBox = getConnectionBoxFromSlug(slug);
|
775
|
+
$(connectionBox).find($img_status).attr("src", "/assets/status/" + iconName + ".png")
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
function getAllConnectedSlugs(){
|
780
|
+
connectedSlugs=[];
|
781
|
+
connectionBoxes = $('div.user_presence[slug]');
|
782
|
+
$.each(connectionBoxes, function(index, value) {
|
783
|
+
if($(value).is(":visible")){
|
784
|
+
connectedSlugs.push($(value).attr("slug"))
|
785
|
+
}
|
786
|
+
});
|
787
|
+
return connectedSlugs
|
788
|
+
}
|
789
|
+
|
790
|
+
|
416
791
|
////////////////////
|
417
792
|
//Chat functions
|
418
793
|
////////////////////
|
@@ -429,8 +804,8 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
|
429
804
|
//Create chatbox for new conversations
|
430
805
|
//Open chatbox for old conversations
|
431
806
|
|
432
|
-
//Box Variable name = guest_slug
|
433
|
-
if (typeof window[guest_slug] == 'undefined') {
|
807
|
+
//Box Variable name = getChatVariableFromSlug(guest_slug)
|
808
|
+
if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') {
|
434
809
|
|
435
810
|
//Add div with id = guest_slug
|
436
811
|
$("#chat_divs").append("<div id=" + guest_slug + " name=" + guest_name + "></div>")
|
@@ -444,7 +819,7 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
|
444
819
|
var position = boxParams[1];
|
445
820
|
|
446
821
|
|
447
|
-
window[guest_slug] = $("#" + guest_slug).chatbox({id: user_name,
|
822
|
+
window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name,
|
448
823
|
user:{key : "value"},
|
449
824
|
hidden: false,
|
450
825
|
offset: offset, // relative to right edge of the browser window
|
@@ -468,31 +843,29 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
|
468
843
|
|
469
844
|
messageSent : function(id, user, msg) {
|
470
845
|
rotatePriority(guest_slug);
|
471
|
-
$("#" + guest_slug).chatbox("option", "boxManager").addMsg(id, msg);
|
846
|
+
$("#" + guest_slug).chatbox("option", "boxManager").addMsg(id, parseContent(msg));
|
472
847
|
sendChatMessage(user_jid,guest_jid,msg);
|
473
848
|
}});
|
474
849
|
|
475
|
-
visibleChatBoxes[position-1] = window[guest_slug];
|
476
|
-
|
477
|
-
|
850
|
+
visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
|
478
851
|
|
479
852
|
return true;
|
480
853
|
|
481
854
|
} else {
|
482
855
|
|
483
|
-
if (visibleChatBoxes.indexOf(window[guest_slug]) == -1) {
|
856
|
+
if (visibleChatBoxes.indexOf(window[getChatVariableFromSlug(guest_slug)]) == -1) {
|
484
857
|
|
485
858
|
//Offset Management for old box
|
486
859
|
boxParams = getBoxParams();
|
487
860
|
var offset = boxParams[0];
|
488
861
|
var position = boxParams[1];
|
489
862
|
|
490
|
-
window[guest_slug].chatbox("option", "offset", offset);
|
491
|
-
window[guest_slug].chatbox("option", "position", position);
|
492
|
-
visibleChatBoxes[position-1] = window[guest_slug];
|
863
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "offset", offset);
|
864
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "position", position);
|
865
|
+
visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
|
493
866
|
}
|
494
867
|
|
495
|
-
window[guest_slug].chatbox("option", "hidden", false);
|
868
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
|
496
869
|
return false;
|
497
870
|
}
|
498
871
|
|
@@ -543,4 +916,10 @@ function rotatePriority(guest_slug){
|
|
543
916
|
}
|
544
917
|
}
|
545
918
|
|
919
|
+
function getChatVariableFromSlug(slug){
|
920
|
+
return "slug_" + slug;
|
921
|
+
}
|
546
922
|
|
923
|
+
function getSlugFromChatVariable(variable){
|
924
|
+
return variable.split("_")[1];
|
925
|
+
}
|
@@ -237,3 +237,23 @@ input.connectChatButton{
|
|
237
237
|
margin-top:5px;
|
238
238
|
margin-bottom:5px;
|
239
239
|
}
|
240
|
+
|
241
|
+
|
242
|
+
/* Chat text */
|
243
|
+
|
244
|
+
.chatImage {
|
245
|
+
max-width: 100px;
|
246
|
+
max-height: 100px;
|
247
|
+
}
|
248
|
+
|
249
|
+
.chatIcon {
|
250
|
+
max-width:20px;
|
251
|
+
max-height: 20px;
|
252
|
+
}
|
253
|
+
|
254
|
+
a.chatLink:link, a.chatLink:visited {
|
255
|
+
color: #1E726A;
|
256
|
+
}
|
257
|
+
|
258
|
+
.chatImageLink {
|
259
|
+
}
|
data/app/helpers/xmpp_helper.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
<script type="text/javascript">
|
2
|
-
|
3
|
-
|
2
|
+
$(document).ready(function () {
|
3
|
+
|
4
|
+
connectButtonTimer = setInterval("connectButtonTimerFunction()", 1000)
|
5
|
+
connectButtonTimerCounter=periodBetweenAttempts+1
|
6
|
+
|
4
7
|
if (authByCookie()){
|
5
8
|
//Authentication by cookie
|
6
9
|
|
7
10
|
$("#passwordFormChat").hide();
|
8
11
|
$('.connectChatButton').bind('click', function () {
|
9
|
-
|
12
|
+
if (requestConnectToChat()){
|
13
|
+
connectToServerWithCookie();
|
14
|
+
}
|
10
15
|
});
|
11
16
|
|
12
17
|
} else {
|
@@ -19,7 +24,9 @@
|
|
19
24
|
}
|
20
25
|
|
21
26
|
$('.connectChatButton').bind('click', function () {
|
22
|
-
|
27
|
+
if (requestConnectToChat()) {
|
28
|
+
connectToServerWithPassword($('#user_password').val());
|
29
|
+
}
|
23
30
|
});
|
24
31
|
|
25
32
|
$('.storePass').bind('click', function () {
|
@@ -29,13 +36,14 @@
|
|
29
36
|
}
|
30
37
|
|
31
38
|
});
|
39
|
+
|
32
40
|
</script>
|
33
41
|
|
34
42
|
<div class="block">
|
35
43
|
<div class="header">
|
36
44
|
<%=image_tag("btn/btn_friend.png", :class => "header_icon")%>
|
37
45
|
<div class="header_text">
|
38
|
-
|
46
|
+
<p id="chat_header_title"><%=t('chat.disconnected')%></p>
|
39
47
|
</div>
|
40
48
|
</div>
|
41
49
|
</div>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 21
|
9
|
+
version: 0.0.21
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aldo Gordillo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-11 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -87,6 +87,16 @@ files:
|
|
87
87
|
- app/assets/audio/chat/onMessageAudio.mp3
|
88
88
|
- app/assets/audio/chat/onMessageAudio.wav
|
89
89
|
- app/assets/images/black_arrow3.png
|
90
|
+
- app/assets/images/emoticons/beer.png
|
91
|
+
- app/assets/images/emoticons/clock.png
|
92
|
+
- app/assets/images/emoticons/face-raspberry.png
|
93
|
+
- app/assets/images/emoticons/face-sad.png
|
94
|
+
- app/assets/images/emoticons/face-smile.png
|
95
|
+
- app/assets/images/emoticons/face-tired.png
|
96
|
+
- app/assets/images/emoticons/face-wink.png
|
97
|
+
- app/assets/images/emoticons/present.png
|
98
|
+
- app/assets/images/emoticons/rain.png
|
99
|
+
- app/assets/images/emoticons/sun.png
|
90
100
|
- app/assets/images/status/available.png
|
91
101
|
- app/assets/images/status/away.png
|
92
102
|
- app/assets/images/status/dnd.png
|