social_stream 0.26.1 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/README.rdoc +10 -0
  2. data/base/lib/social_stream/base/version.rb +1 -1
  3. data/base/social_stream-base.gemspec +1 -1
  4. data/lib/social_stream/release/component.rb +5 -0
  5. data/lib/social_stream/release/global.rb +8 -7
  6. data/lib/social_stream/release/kernel.rb +24 -0
  7. data/lib/social_stream/version.rb +1 -1
  8. data/presence/app/assets/javascripts/jquery.flexselect.sstreampresence.js +2 -2
  9. data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +5 -5
  10. data/presence/app/assets/javascripts/presence.js.erb +6 -4
  11. data/presence/app/assets/javascripts/presence_XmppClient.js.erb +1146 -996
  12. data/presence/app/assets/javascripts/presence_audio.js.erb +74 -60
  13. data/presence/app/assets/javascripts/presence_game.js.erb +35 -22
  14. data/presence/app/assets/javascripts/presence_game_comunication.js.erb +22 -5
  15. data/presence/app/assets/javascripts/presence_game_factory.js.erb +1 -1
  16. data/presence/app/assets/javascripts/presence_game_interface.js.erb +33 -13
  17. data/presence/app/assets/javascripts/presence_notifications.js +206 -183
  18. data/presence/app/assets/javascripts/presence_parser.js +265 -247
  19. data/presence/app/assets/javascripts/presence_persistence.js +199 -188
  20. data/presence/app/assets/javascripts/presence_store.js +22 -11
  21. data/presence/app/assets/javascripts/presence_uiManager.js.erb +553 -530
  22. data/presence/app/assets/javascripts/presence_utilities.js +244 -219
  23. data/presence/app/assets/javascripts/presence_videochat.js.erb +436 -409
  24. data/presence/app/assets/javascripts/presence_windowManager.js +586 -532
  25. data/presence/app/views/chat/_index.html.erb +7 -13
  26. data/presence/config/locales/en.yml +2 -1
  27. data/presence/config/locales/es.yml +2 -1
  28. data/presence/ejabberd/ejabberd_files.zip +0 -0
  29. data/presence/ejabberd/ejabberd_scripts/authentication_script +9 -2
  30. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  31. data/presence/lib/generators/social_stream/presence/templates/initializer.rb +4 -0
  32. data/presence/lib/social_stream-presence.rb +3 -0
  33. data/presence/lib/social_stream/presence/version.rb +1 -1
  34. data/presence/lib/social_stream/presence/xmpp_server_order.rb +1 -0
  35. data/release.thor +33 -13
  36. data/social_stream.gemspec +2 -2
  37. metadata +90 -29
@@ -1,237 +1,262 @@
1
1
  ////////////////////
2
- //Debug functions
2
+ //SOCIAL STREAM PRESENCE: UTILITIES
3
3
  ////////////////////
4
- var sspresence_debugging=false;
5
4
 
6
- function log(msg) {
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
- //Blink page title when focus lost on new messages
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
- if( from_slug in lastMessageTimes){
98
-
99
- } else {
100
- lastMessageTimes[from_slug] = [,[]];
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
- if (msgID==null){
104
- msgID = generateMessageID();
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 lastMessageTime = lastMessageTimes[from_slug][0];
108
-
109
- var t = (new Date()).getTime();
110
- if(t - lastMessageTime < timeBetweenMessages) {
111
- //Flood detected
112
- return retryToShowMessage(from_slug,msg,msgID);
113
- }
114
-
115
- //Check if is the first message of this user to be send.
116
- //var messageQueue = lastMessageTimes[from_slug][1];
117
-
118
- if (lastMessageTimes[from_slug][1].length>0){
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
- //Message can be send
129
- lastMessageTimes[from_slug][0] = t;
130
- return false;
131
- };
132
-
133
-
134
- var rootMessageID=1;
135
- function generateMessageID(){
136
- return (++rootMessageID);
137
- }
138
-
139
-
140
- function retryToShowMessage(from_slug,msg,msgID){
141
- //Enque the message if isn't in the queue
142
- if (lastMessageTimes[from_slug][1].indexOf(msgID)==-1){
143
- lastMessageTimes[from_slug][1].push(msgID);
144
- }
145
-
146
- setTimeout(function(){afterReceivedChatMessage(from_slug,msg,msgID)}, timeBetweenMessages);
147
- return true;
148
- }
149
-
150
-
151
-
152
-
153
-
154
- ////////////////////
155
- //Controlflood
156
- ////////////////////
157
- var timeBetweenOwnMessages = 500; //mseconds
158
- var lastMessageSentTime=null;
159
-
160
- function floodControl() {
161
- var t = (new Date()).getTime();
162
-
163
- if(lastMessageSentTime==null){
164
- lastMessageSentTime = t;
165
- return true;
166
- }
167
-
168
- if (t - lastMessageSentTime < timeBetweenOwnMessages) {
169
- return false;
170
- } else {
171
- lastMessageSentTime = t;
172
- return true;
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
- function mustBounceBoxForChatWindow(jqueryUIChatbox){
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
- if (typeof slug == 'undefined') {
188
- return false;
146
+ var rootMessageID=1;
147
+ var generateMessageID = function(){
148
+ return (++rootMessageID);
189
149
  }
190
150
 
191
- if((slug in contactsInfo)&&(contactsInfo[slug].videoChatStatus!="disconnected")){
192
- return false;
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
- var t = (new Date()).getTime();
196
-
197
- if(!(slug in lastBounceTimes)){
198
- lastBounceTimes[slug] = t;
199
- return true;
200
- }
201
-
202
- var lastBounceTime = lastBounceTimes[slug];
203
-
204
- if (t - lastBounceTime < timeBetweenBounces) {
205
- return false;
206
- } else {
207
- lastBounceTimes[slug] = t;
208
- return true;
209
- }
210
-
211
- }
212
-
213
-
214
-
215
- ////////////////////
216
- //Prevent user to send data to the chatbox when he is offline.
217
- ////////////////////
218
-
219
- function offlineDataSendControl(){
220
- return ((!disconnectionFlag) && (isStropheConnected()));
221
- }
222
-
223
-
224
- ////////////////////
225
- //Special slugs management
226
- ////////////////////
227
- function isAdminSlug(slug){
228
- return (slug == '<%=SocialStream::Presence.social_stream_presence_username%>');
229
- }
230
-
231
-
232
-
233
- ////////////////////
234
- //Next features...
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);