social_stream 0.26.1 → 0.26.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -0
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/social_stream-base.gemspec +1 -1
- data/lib/social_stream/release/component.rb +5 -0
- data/lib/social_stream/release/global.rb +8 -7
- data/lib/social_stream/release/kernel.rb +24 -0
- data/lib/social_stream/version.rb +1 -1
- data/presence/app/assets/javascripts/jquery.flexselect.sstreampresence.js +2 -2
- data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +5 -5
- data/presence/app/assets/javascripts/presence.js.erb +6 -4
- data/presence/app/assets/javascripts/presence_XmppClient.js.erb +1146 -996
- data/presence/app/assets/javascripts/presence_audio.js.erb +74 -60
- data/presence/app/assets/javascripts/presence_game.js.erb +35 -22
- data/presence/app/assets/javascripts/presence_game_comunication.js.erb +22 -5
- data/presence/app/assets/javascripts/presence_game_factory.js.erb +1 -1
- data/presence/app/assets/javascripts/presence_game_interface.js.erb +33 -13
- data/presence/app/assets/javascripts/presence_notifications.js +206 -183
- data/presence/app/assets/javascripts/presence_parser.js +265 -247
- data/presence/app/assets/javascripts/presence_persistence.js +199 -188
- data/presence/app/assets/javascripts/presence_store.js +22 -11
- data/presence/app/assets/javascripts/presence_uiManager.js.erb +553 -530
- data/presence/app/assets/javascripts/presence_utilities.js +244 -219
- data/presence/app/assets/javascripts/presence_videochat.js.erb +436 -409
- data/presence/app/assets/javascripts/presence_windowManager.js +586 -532
- data/presence/app/views/chat/_index.html.erb +7 -13
- data/presence/config/locales/en.yml +2 -1
- data/presence/config/locales/es.yml +2 -1
- data/presence/ejabberd/ejabberd_files.zip +0 -0
- data/presence/ejabberd/ejabberd_scripts/authentication_script +9 -2
- data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/presence/lib/generators/social_stream/presence/templates/initializer.rb +4 -0
- data/presence/lib/social_stream-presence.rb +3 -0
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/presence/xmpp_server_order.rb +1 -0
- data/release.thor +33 -13
- data/social_stream.gemspec +2 -2
- metadata +90 -29
@@ -1,237 +1,262 @@
|
|
1
1
|
////////////////////
|
2
|
-
//
|
2
|
+
//SOCIAL STREAM PRESENCE: UTILITIES
|
3
3
|
////////////////////
|
4
|
-
var sspresence_debugging=false;
|
5
4
|
|
6
|
-
|
7
|
-
if(sspresence_debugging){
|
8
|
-
console.log(msg)
|
9
|
-
}
|
10
|
-
}
|
5
|
+
PRESENCE.UTILITIES = (function(P,$,undefined){
|
11
6
|
|
7
|
+
var init = function(){
|
8
|
+
initFocusListeners();
|
9
|
+
}
|
12
10
|
|
13
|
-
////////////////////
|
14
|
-
//
|
15
|
-
////////////////////
|
16
|
-
|
17
|
-
var chatFocus;
|
18
|
-
|
19
|
-
function onChatBlur() {
|
20
|
-
chatFocus = false;
|
21
|
-
};
|
22
|
-
|
23
|
-
function onChatFocus(){
|
24
|
-
stopBlink();
|
25
|
-
titles = []; //Remove titles after StopBlink!
|
26
|
-
chatFocus = true;
|
27
|
-
};
|
28
|
-
|
29
|
-
function initFocusListeners(){
|
30
|
-
if (/*@cc_on!@*/false) { // check for Internet Explorer
|
31
|
-
document.onfocusin = onFocus;
|
32
|
-
document.onfocusout = onBlur;
|
33
|
-
} else {
|
34
|
-
window.onfocus = onChatFocus;
|
35
|
-
window.onblur = onChatBlur;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
var blinkTimer;
|
41
|
-
var titles=[];
|
42
|
-
|
43
|
-
function blinkTitle(titles,index){
|
44
|
-
$(document).attr("title", titles[index]);
|
45
|
-
index = (index+1)%titles.length
|
46
|
-
blinkTimer=setTimeout(function(){blinkTitle(titles,index)}, 2000);
|
47
|
-
}
|
48
|
-
|
49
|
-
function stopBlink(){
|
50
|
-
clearTimeout(blinkTimer);
|
51
|
-
if (titles.length > 0) {
|
52
|
-
$(document).attr("title", titles[0]);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
function blinkTitleOnMessage(username){
|
57
|
-
if (!chatFocus){
|
58
|
-
if (titles.length==0){
|
59
|
-
titles.push($(document).attr("title"))
|
60
|
-
}
|
61
|
-
if (titles.indexOf(username) == -1){
|
62
|
-
titles.push(username + " says...")
|
63
|
-
}
|
64
|
-
stopBlink();
|
65
|
-
blinkTitle(titles,titles.length-1);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
////////////////////
|
72
|
-
//Control user data input on the chatbox
|
73
|
-
////////////////////
|
74
|
-
|
75
|
-
//Return true to allow user to send data to the chatbox.
|
76
|
-
function userChatDataInputControl(){
|
77
|
-
var floodControlBoolean = floodControl();
|
78
|
-
var offlineDataSendControlBoolean = offlineDataSendControl();
|
79
|
-
return (floodControlBoolean && offlineDataSendControlBoolean);
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
////////////////////
|
85
|
-
//Antiflood
|
86
|
-
////////////////////
|
87
|
-
|
88
|
-
var lastMessageTimes = new Array();
|
89
|
-
//lastMessageTimes['slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
|
90
|
-
|
91
|
-
var timeBetweenMessages = 500; //mseconds
|
92
|
-
|
93
|
-
//Return true when detects a text storm and control the text flood:
|
94
|
-
//timeBetweenMessages is the minimum time that must elapse between the messages of the same contact.
|
95
|
-
function antifloodControl(from_slug,msg,msgID) {
|
11
|
+
////////////////////
|
12
|
+
//Debug functions
|
13
|
+
////////////////////
|
14
|
+
var debugging=false;
|
96
15
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
16
|
+
var log = function(msg) {
|
17
|
+
if(debugging){
|
18
|
+
console.log(msg)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
////////////////////
|
23
|
+
//Blink page title when focus lost on new messages
|
24
|
+
////////////////////
|
25
|
+
var chatFocus;
|
26
|
+
|
27
|
+
var onChatBlur = function() {
|
28
|
+
chatFocus = false;
|
29
|
+
};
|
30
|
+
|
31
|
+
var onChatFocus = function(){
|
32
|
+
stopBlink();
|
33
|
+
titles = []; //Remove titles after StopBlink!
|
34
|
+
chatFocus = true;
|
35
|
+
};
|
102
36
|
|
103
|
-
|
104
|
-
|
37
|
+
var initFocusListeners = function(){
|
38
|
+
if (/*@cc_on!@*/false) { // check for Internet Explorer
|
39
|
+
document.onfocusin = PRESENCE.UTILITIES.onChatFocus;
|
40
|
+
document.onfocusout = PRESENCE.UTILITIES.onChatBlur;
|
41
|
+
} else {
|
42
|
+
window.onfocus = PRESENCE.UTILITIES.onChatFocus;
|
43
|
+
window.onblur = PRESENCE.UTILITIES.onChatBlur;
|
44
|
+
}
|
105
45
|
}
|
106
46
|
|
107
|
-
var
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if((lastMessageTimes[from_slug][1])[0]==msgID){
|
120
|
-
//Message is the first on the queue: Show it and remove from the queue
|
121
|
-
lastMessageTimes[from_slug][1].splice(0,1);
|
122
|
-
} else {
|
123
|
-
//Message is not the first on the queue
|
124
|
-
return retryToShowMessage(from_slug,msg,msgID);
|
125
|
-
}
|
47
|
+
var getChatFocus = function(){
|
48
|
+
return chatFocus;
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
var blinkTimer;
|
53
|
+
var titles=[];
|
54
|
+
|
55
|
+
var blinkTitle = function(titles,index){
|
56
|
+
$(document).attr("title", titles[index]);
|
57
|
+
index = (index+1)%titles.length
|
58
|
+
blinkTimer=setTimeout(function(){PRESENCE.UTILITIES.blinkTitle(titles,index)}, 2000);
|
126
59
|
}
|
127
60
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
function
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
var
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
////////////////////
|
178
|
-
//Bounce chatbox control
|
179
|
-
////////////////////
|
180
|
-
var lastBounceTimes = new Array();
|
181
|
-
var timeBetweenBounces = 5000; //mseconds
|
61
|
+
var stopBlink = function (){
|
62
|
+
clearTimeout(blinkTimer);
|
63
|
+
if (titles.length > 0) {
|
64
|
+
$(document).attr("title", titles[0]);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
var blinkTitleOnMessage = function (username){
|
69
|
+
if (!chatFocus){
|
70
|
+
if (titles.length==0){
|
71
|
+
titles.push($(document).attr("title"))
|
72
|
+
}
|
73
|
+
if (titles.indexOf(username) == -1){
|
74
|
+
titles.push(username + " says...")
|
75
|
+
}
|
76
|
+
stopBlink();
|
77
|
+
blinkTitle(titles,titles.length-1);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
////////////////////
|
84
|
+
//Control user data input on the chatbox
|
85
|
+
////////////////////
|
86
|
+
|
87
|
+
//Return true to allow user to send data to the chatbox.
|
88
|
+
var userChatDataInputControl = function(){
|
89
|
+
var floodControlBoolean = floodControl();
|
90
|
+
var offlineDataSendControlBoolean = offlineDataSendControl();
|
91
|
+
return (floodControlBoolean && offlineDataSendControlBoolean);
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
////////////////////
|
97
|
+
//Antiflood
|
98
|
+
////////////////////
|
99
|
+
|
100
|
+
var lastMessageTimes = new Array();
|
101
|
+
//lastMessageTimes['slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
|
102
|
+
|
103
|
+
var timeBetweenMessages = 500; //mseconds
|
104
|
+
|
105
|
+
//Return true when detects a text storm and control the text flood:
|
106
|
+
//timeBetweenMessages is the minimum time that must elapse between the messages of the same contact.
|
107
|
+
var antifloodControl = function(from_slug,msg,msgID) {
|
182
108
|
|
183
|
-
|
109
|
+
if( from_slug in lastMessageTimes){
|
110
|
+
|
111
|
+
} else {
|
112
|
+
lastMessageTimes[from_slug] = [,[]];
|
113
|
+
}
|
114
|
+
|
115
|
+
if (msgID==null){
|
116
|
+
msgID = generateMessageID();
|
117
|
+
}
|
118
|
+
|
119
|
+
var lastMessageTime = lastMessageTimes[from_slug][0];
|
120
|
+
|
121
|
+
var t = (new Date()).getTime();
|
122
|
+
if(t - lastMessageTime < timeBetweenMessages) {
|
123
|
+
//Flood detected
|
124
|
+
return retryToShowMessage(from_slug,msg,msgID);
|
125
|
+
}
|
126
|
+
|
127
|
+
//Check if is the first message of this user to be send.
|
128
|
+
//var messageQueue = lastMessageTimes[from_slug][1];
|
129
|
+
|
130
|
+
if (lastMessageTimes[from_slug][1].length>0){
|
131
|
+
if((lastMessageTimes[from_slug][1])[0]==msgID){
|
132
|
+
//Message is the first on the queue: Show it and remove from the queue
|
133
|
+
lastMessageTimes[from_slug][1].splice(0,1);
|
134
|
+
} else {
|
135
|
+
//Message is not the first on the queue
|
136
|
+
return retryToShowMessage(from_slug,msg,msgID);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
//Message can be send
|
141
|
+
lastMessageTimes[from_slug][0] = t;
|
142
|
+
return false;
|
143
|
+
};
|
184
144
|
|
185
|
-
var slug = jqueryUIChatbox.elem.uiChatbox.find(".ui-chatbox-content").find(".ui-chatbox-log").attr("id")
|
186
145
|
|
187
|
-
|
188
|
-
|
146
|
+
var rootMessageID=1;
|
147
|
+
var generateMessageID = function(){
|
148
|
+
return (++rootMessageID);
|
189
149
|
}
|
190
150
|
|
191
|
-
|
192
|
-
|
151
|
+
|
152
|
+
var retryToShowMessage = function(from_slug,msg,msgID){
|
153
|
+
//Enque the message if isn't in the queue
|
154
|
+
if (lastMessageTimes[from_slug][1].indexOf(msgID)==-1){
|
155
|
+
lastMessageTimes[from_slug][1].push(msgID);
|
156
|
+
}
|
157
|
+
|
158
|
+
setTimeout(function(){PRESENCE.UIMANAGER.afterReceivedChatMessage(from_slug,msg,msgID)}, timeBetweenMessages);
|
159
|
+
return true;
|
193
160
|
}
|
194
161
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
162
|
+
|
163
|
+
////////////////////
|
164
|
+
//Controlflood
|
165
|
+
////////////////////
|
166
|
+
var timeBetweenOwnMessages = 500; //mseconds
|
167
|
+
var lastMessageSentTime=null;
|
168
|
+
|
169
|
+
var floodControl = function() {
|
170
|
+
var t = (new Date()).getTime();
|
171
|
+
|
172
|
+
if(lastMessageSentTime==null){
|
173
|
+
lastMessageSentTime = t;
|
174
|
+
return true;
|
175
|
+
}
|
176
|
+
|
177
|
+
if (t - lastMessageSentTime < timeBetweenOwnMessages) {
|
178
|
+
return false;
|
179
|
+
} else {
|
180
|
+
lastMessageSentTime = t;
|
181
|
+
return true;
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
|
186
|
+
////////////////////
|
187
|
+
//Bounce chatbox control
|
188
|
+
////////////////////
|
189
|
+
var lastBounceTimes = new Array();
|
190
|
+
var timeBetweenBounces = 5000; //mseconds
|
191
|
+
|
192
|
+
var mustBounceBoxForChatWindow = function(jqueryUIChatbox){
|
193
|
+
|
194
|
+
var slug = jqueryUIChatbox.elem.uiChatbox.find(".ui-chatbox-content").find(".ui-chatbox-log").attr("id")
|
195
|
+
|
196
|
+
if (typeof slug == 'undefined') {
|
197
|
+
return false;
|
198
|
+
}
|
199
|
+
|
200
|
+
if((slug in contactsInfo)&&(contactsInfo[slug].videoChatStatus!="disconnected")){
|
201
|
+
return false;
|
202
|
+
}
|
203
|
+
|
204
|
+
var t = (new Date()).getTime();
|
205
|
+
|
206
|
+
if(!(slug in lastBounceTimes)){
|
207
|
+
lastBounceTimes[slug] = t;
|
208
|
+
return true;
|
209
|
+
}
|
210
|
+
|
211
|
+
var lastBounceTime = lastBounceTimes[slug];
|
212
|
+
|
213
|
+
if (t - lastBounceTime < timeBetweenBounces) {
|
214
|
+
return false;
|
215
|
+
} else {
|
216
|
+
lastBounceTimes[slug] = t;
|
217
|
+
return true;
|
218
|
+
}
|
219
|
+
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
////////////////////
|
225
|
+
//Prevent user to send data to the chatbox when he is offline.
|
226
|
+
////////////////////
|
227
|
+
|
228
|
+
var offlineDataSendControl = function(){
|
229
|
+
return ((!PRESENCE.XMPPClient.getDisconnectionFlag()) && (PRESENCE.XMPPClient.isStropheConnected()));
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
////////////////////
|
234
|
+
//Special slugs management
|
235
|
+
////////////////////
|
236
|
+
var isAdminSlug = function(slug){
|
237
|
+
return (slug == '<%=SocialStream::Presence.social_stream_presence_username%>');
|
238
|
+
}
|
239
|
+
|
240
|
+
|
241
|
+
////////////////////
|
242
|
+
//Next features...
|
243
|
+
////////////////////
|
244
|
+
//[...]
|
245
|
+
|
246
|
+
|
247
|
+
return {
|
248
|
+
init: init,
|
249
|
+
log : log,
|
250
|
+
onChatFocus : onChatFocus,
|
251
|
+
onChatBlur : onChatBlur,
|
252
|
+
blinkTitleOnMessage : blinkTitleOnMessage,
|
253
|
+
blinkTitle : blinkTitle,
|
254
|
+
userChatDataInputControl : userChatDataInputControl,
|
255
|
+
antifloodControl : antifloodControl,
|
256
|
+
mustBounceBoxForChatWindow : mustBounceBoxForChatWindow,
|
257
|
+
isAdminSlug : isAdminSlug,
|
258
|
+
getChatFocus : getChatFocus
|
259
|
+
};
|
260
|
+
|
261
|
+
|
262
|
+
}) (PRESENCE, jQuery);
|