social_stream 0.12.8 → 0.12.9
Sign up to get free protection for your applications and to get access to all the features.
- data/base/app/assets/stylesheets/header.css.scss +2 -2
- data/base/app/controllers/conversations_controller.rb +1 -1
- data/base/app/views/settings/_index.html.erb +3 -0
- data/base/app/views/toolbar/_home.html.erb +1 -1
- data/base/config/locales/en.yml +2 -1
- data/base/config/locales/es.yml +3 -2
- data/base/lib/social_stream/base/version.rb +1 -1
- data/documents/config/locales/es.yml +1 -1
- data/documents/lib/social_stream/documents/version.rb +1 -1
- data/documents/social_stream-documents.gemspec +1 -1
- data/lib/social_stream/version.rb +1 -1
- data/presence/app/assets/javascripts/chat_audio.js +73 -0
- data/presence/app/assets/javascripts/chat_interface_manager.js.erb +197 -0
- data/presence/app/assets/javascripts/chat_parser.js +243 -0
- data/presence/app/assets/javascripts/chat_utilities.js +71 -0
- data/presence/app/assets/javascripts/chat_window_manager.js +138 -0
- data/presence/app/assets/javascripts/social_stream-presence.js +3 -0
- data/presence/app/assets/javascripts/store.js +0 -7
- data/presence/app/assets/javascripts/xmpp_client_management.js.erb +304 -0
- data/presence/app/assets/stylesheets/chat.css +40 -0
- data/presence/app/assets/stylesheets/social_stream-presence.css +1 -0
- data/presence/app/controllers/xmpp_controller.rb +43 -9
- data/presence/app/views/{xmpp/_chat_connecting.html.erb → chat/_connecting.html.erb} +0 -0
- data/presence/app/views/{xmpp/_chat_contacts.html.erb → chat/_contacts.html.erb} +0 -0
- data/presence/app/views/{xmpp/_chat.html.erb → chat/_index.html.erb} +3 -13
- data/presence/app/views/{xmpp/_chat_off.html.erb → chat/_off.html.erb} +0 -0
- data/presence/app/views/chat/_settings.html.erb +38 -0
- data/presence/config/routes.rb +1 -1
- data/presence/db/migrate/20111116194112_add_chat_enabled_column_to_user.rb +9 -0
- data/presence/{app → vendor}/assets/javascripts/jquery.tools.tooltip.js +0 -0
- data/presence/{app → vendor}/assets/javascripts/jquery.ui.chatbox.js +14 -12
- data/presence/{app → vendor}/assets/javascripts/strophe.js +0 -0
- data/presence/{app → vendor}/assets/stylesheets/jquery.ui.chatbox.css +0 -0
- data/social_stream.gemspec +2 -2
- metadata +26 -21
- data/presence/app/assets/javascripts/jquery-ui-1.8.14.custom.min.js +0 -789
- data/presence/app/assets/javascripts/jquery.tools.min.js +0 -17
- data/presence/app/assets/javascripts/xmpp_client.js.erb +0 -962
@@ -0,0 +1,71 @@
|
|
1
|
+
////////////////////
|
2
|
+
//Test functions
|
3
|
+
////////////////////
|
4
|
+
|
5
|
+
function log(msg) {
|
6
|
+
//console.log(msg)
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
////////////////////
|
11
|
+
//Blink page title when focus lost on new messages
|
12
|
+
////////////////////
|
13
|
+
|
14
|
+
var chatFocus;
|
15
|
+
|
16
|
+
function onChatBlur() {
|
17
|
+
chatFocus = false;
|
18
|
+
};
|
19
|
+
|
20
|
+
function onChatFocus(){
|
21
|
+
stopBlink();
|
22
|
+
titles = []; //Remove titles after StopBlink!
|
23
|
+
chatFocus = true;
|
24
|
+
};
|
25
|
+
|
26
|
+
function initFocusListeners(){
|
27
|
+
if (/*@cc_on!@*/false) { // check for Internet Explorer
|
28
|
+
document.onfocusin = onFocus;
|
29
|
+
document.onfocusout = onBlur;
|
30
|
+
} else {
|
31
|
+
window.onfocus = onChatFocus;
|
32
|
+
window.onblur = onChatBlur;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
var blinkTimer;
|
38
|
+
var titles=[];
|
39
|
+
|
40
|
+
function blinkTitle(titles,index){
|
41
|
+
$(document).attr("title", titles[index]);
|
42
|
+
index = (index+1)%titles.length
|
43
|
+
blinkTimer=setTimeout(function(){blinkTitle(titles,index)}, 2000);
|
44
|
+
}
|
45
|
+
|
46
|
+
function stopBlink(){
|
47
|
+
clearTimeout(blinkTimer);
|
48
|
+
if (titles.length > 0) {
|
49
|
+
$(document).attr("title", titles[0]);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function blinkTitleOnMessage(username){
|
54
|
+
if (!chatFocus){
|
55
|
+
if (titles.length==0){
|
56
|
+
titles.push($(document).attr("title"))
|
57
|
+
}
|
58
|
+
if (titles.indexOf(username) == -1){
|
59
|
+
titles.push(username + " says...")
|
60
|
+
}
|
61
|
+
stopBlink();
|
62
|
+
blinkTitle(titles,titles.length-1);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
////////////////////
|
68
|
+
//Next features...
|
69
|
+
////////////////////
|
70
|
+
|
71
|
+
|
@@ -0,0 +1,138 @@
|
|
1
|
+
////////////////////
|
2
|
+
//Chat functions
|
3
|
+
////////////////////
|
4
|
+
|
5
|
+
var nBox = 0;
|
6
|
+
var maxBox = 5;
|
7
|
+
var chatBoxWidth = 230;
|
8
|
+
var visibleChatBoxes = new Array();
|
9
|
+
var chatBoxSeparation = chatBoxWidth+12;
|
10
|
+
|
11
|
+
|
12
|
+
function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
13
|
+
|
14
|
+
//Create chatbox for new conversations
|
15
|
+
//Open chatbox for old conversations
|
16
|
+
|
17
|
+
//Box Variable name = getChatVariableFromSlug(guest_slug)
|
18
|
+
if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') {
|
19
|
+
|
20
|
+
//Add div with id = guest_slug
|
21
|
+
$("#chat_divs").append("<div id=" + guest_slug + " name=" + guest_name + "></div>")
|
22
|
+
|
23
|
+
//Add CSS [...]
|
24
|
+
|
25
|
+
|
26
|
+
//Offset Management for new box
|
27
|
+
boxParams = getBoxParams();
|
28
|
+
var offset = boxParams[0];
|
29
|
+
var position = boxParams[1];
|
30
|
+
|
31
|
+
|
32
|
+
window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name,
|
33
|
+
user:{key : "value"},
|
34
|
+
hidden: false,
|
35
|
+
offset: offset, // relative to right edge of the browser window
|
36
|
+
width: chatBoxWidth, // width of the chatbox
|
37
|
+
title : guest_name,
|
38
|
+
position: position,
|
39
|
+
priority: visibleChatBoxes.length+1,
|
40
|
+
boxClosed: function(id) {
|
41
|
+
|
42
|
+
position = $("#" + guest_slug).chatbox("option", "position");
|
43
|
+
|
44
|
+
for (i=position+1;i<visibleChatBoxes.length+1;i++){
|
45
|
+
visibleChatBoxes[i-1].chatbox("option", "offset", visibleChatBoxes[i-1].chatbox("option", "offset") - chatBoxSeparation);
|
46
|
+
visibleChatBoxes[i-1].chatbox("option", "position", visibleChatBoxes[i-1].chatbox("option", "position") - 1 );
|
47
|
+
}
|
48
|
+
|
49
|
+
visibleChatBoxes.splice(position-1,1);
|
50
|
+
$("#" + guest_slug).chatbox("option", "hidden", true);
|
51
|
+
nBox--;
|
52
|
+
},
|
53
|
+
|
54
|
+
messageSent : function(id, user, msg) {
|
55
|
+
rotatePriority(guest_slug);
|
56
|
+
$("#" + guest_slug).chatbox("option", "boxManager").addMsg(id, getParsedContent(msg,true));
|
57
|
+
sendChatMessage(user_jid,guest_jid,msg);
|
58
|
+
}});
|
59
|
+
|
60
|
+
visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
|
61
|
+
|
62
|
+
return true;
|
63
|
+
|
64
|
+
} else {
|
65
|
+
|
66
|
+
if (visibleChatBoxes.indexOf(window[getChatVariableFromSlug(guest_slug)]) == -1) {
|
67
|
+
|
68
|
+
//Offset Management for old box
|
69
|
+
boxParams = getBoxParams();
|
70
|
+
var offset = boxParams[0];
|
71
|
+
var position = boxParams[1];
|
72
|
+
|
73
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "offset", offset);
|
74
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "position", position);
|
75
|
+
visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)];
|
76
|
+
}
|
77
|
+
|
78
|
+
window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false);
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
function getBoxParams(){
|
85
|
+
|
86
|
+
var boxParams = new Array(2);
|
87
|
+
|
88
|
+
if (nBox==maxBox){
|
89
|
+
//Select box to replaced
|
90
|
+
replaced = visibleChatBoxes[getBoxIndexToReplace()];
|
91
|
+
replaced.chatbox("option", "hidden", true)
|
92
|
+
index = visibleChatBoxes.indexOf(replaced);
|
93
|
+
boxParams[0] = replaced.chatbox("option", "offset")
|
94
|
+
boxParams[1] = replaced.chatbox("option", "position")
|
95
|
+
} else {
|
96
|
+
nBox++;
|
97
|
+
boxParams[0] = (nBox-1)*(chatBoxSeparation);
|
98
|
+
boxParams[1] = nBox;
|
99
|
+
}
|
100
|
+
|
101
|
+
return boxParams
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
function getBoxIndexToReplace(){
|
106
|
+
|
107
|
+
tmp = visibleChatBoxes[0];
|
108
|
+
for (i=0;i<visibleChatBoxes.length;i++){
|
109
|
+
if (visibleChatBoxes[i].chatbox("option", "priority") > tmp.chatbox("option", "priority")) {
|
110
|
+
tmp = visibleChatBoxes[i];
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
return visibleChatBoxes.indexOf(tmp);
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
function rotatePriority(guest_slug){
|
119
|
+
priority = $("#" + guest_slug).chatbox("option", "priority")
|
120
|
+
if(priority>1){
|
121
|
+
for (i=0;i<visibleChatBoxes.length;i++){
|
122
|
+
if(visibleChatBoxes[i].chatbox("option", "priority")<priority){
|
123
|
+
visibleChatBoxes[i].chatbox("option", "priority",visibleChatBoxes[i].chatbox("option", "priority")+1);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
$("#" + guest_slug).chatbox("option", "priority", 1);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
function getChatVariableFromSlug(slug){
|
132
|
+
return "slug_" + slug;
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
function getSlugFromChatVariable(variable){
|
137
|
+
return variable.split("_")[1];
|
138
|
+
}
|
@@ -2,13 +2,6 @@
|
|
2
2
|
//Store password with session storage
|
3
3
|
////////////////////
|
4
4
|
|
5
|
-
$(document).ready(function () {
|
6
|
-
$('.storePass').bind('click', function () {
|
7
|
-
storePassword();
|
8
|
-
});
|
9
|
-
});
|
10
|
-
|
11
|
-
|
12
5
|
function storePassword() {
|
13
6
|
|
14
7
|
//Dont store password if cookie authentication is enable
|
@@ -0,0 +1,304 @@
|
|
1
|
+
////////////////////
|
2
|
+
//Hash table
|
3
|
+
////////////////////
|
4
|
+
var statusMessage = new Array();
|
5
|
+
statusMessage[''] = "";
|
6
|
+
statusMessage['chat'] = "";
|
7
|
+
statusMessage['away'] = "Away";
|
8
|
+
statusMessage['xa'] = "Away";
|
9
|
+
statusMessage['dnd'] = "Busy";
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
////////////////////
|
14
|
+
//Connect functions
|
15
|
+
////////////////////
|
16
|
+
|
17
|
+
function connectToServerWithCookie(){
|
18
|
+
try {
|
19
|
+
connection = new Strophe.Connection(BOSH_SERVICE);
|
20
|
+
connection.connect(user_jid, cookie, onConnect);
|
21
|
+
} catch (err) {
|
22
|
+
//"Handle errors"
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
//Password: Get from chatPassword param if exists, instead try to get from sessionStorage.
|
28
|
+
function connectToServerWithPassword(chatPassword){
|
29
|
+
|
30
|
+
//Get Password
|
31
|
+
if ((chatPassword!=null)&&(chatPassword!="")){
|
32
|
+
var password = chatPassword;
|
33
|
+
} else if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)) {
|
34
|
+
var password = sessionStorage.getItem("ss_user_pass");
|
35
|
+
} else {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
|
39
|
+
try {
|
40
|
+
//Connect actual user to the chat
|
41
|
+
connection = new Strophe.Connection(BOSH_SERVICE);
|
42
|
+
connection.connect(user_jid, password, onConnect);
|
43
|
+
} catch (err) {
|
44
|
+
//"Handle errors"
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
|
48
|
+
return true;
|
49
|
+
}
|
50
|
+
|
51
|
+
////////
|
52
|
+
//Auth Methods
|
53
|
+
///////
|
54
|
+
function authByCookie(){
|
55
|
+
var authMethod = '<%= SocialStream::Presence.auth_method %>';
|
56
|
+
return authMethod=="cookie";
|
57
|
+
}
|
58
|
+
|
59
|
+
function authByPassword(){
|
60
|
+
var authMethod = '<%= SocialStream::Presence.auth_method %>';
|
61
|
+
return authMethod=="password";
|
62
|
+
}
|
63
|
+
|
64
|
+
function ifCookie(){
|
65
|
+
return (!(typeof cookie == 'undefined'))
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
////////////////////
|
70
|
+
//Stanza management using Strophe
|
71
|
+
////////////////////
|
72
|
+
|
73
|
+
//Global variables
|
74
|
+
var userStatus = "chat";
|
75
|
+
var awayTimerPeriod = 16000;
|
76
|
+
var timerPeriod = 5000;
|
77
|
+
var refreshMinTime = 3*timerPeriod;
|
78
|
+
var awayTime = 300000;
|
79
|
+
var awayCounter = 0;
|
80
|
+
var timerCounter = 0;
|
81
|
+
var connection = null;
|
82
|
+
var userConnected = false;
|
83
|
+
var reconnectAttempts = 3;
|
84
|
+
var awayTimer;
|
85
|
+
var timer;
|
86
|
+
var requestContacts=false;
|
87
|
+
var cyclesToRefresh = (refreshMinTime/timerPeriod);
|
88
|
+
|
89
|
+
|
90
|
+
function onConnect(status) {
|
91
|
+
|
92
|
+
//Status.ERROR An error has occurred
|
93
|
+
//Status.CONNECTING The connection is currently being made
|
94
|
+
//Status.CONNFAIL The connection attempt failed
|
95
|
+
//Status.AUTHENTICATING The connection is authenticating
|
96
|
+
//Status.AUTHFAIL The authentication attempt failed
|
97
|
+
//Status.CONNECTED The connection has succeeded
|
98
|
+
//Status.DISCONNECTED The connection has been terminated
|
99
|
+
//Status.DISCONNECTING The connection is currently being terminated
|
100
|
+
//Status.ATTACHED The connection has been attached
|
101
|
+
|
102
|
+
log('Strophe onConnect callback call with status ' + status);
|
103
|
+
|
104
|
+
if (status == Strophe.Status.ATTACHED){
|
105
|
+
log('Strophe connection attached');
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (status == Strophe.Status.AUTHENTICATING ){
|
110
|
+
log('Strophe connection AUTHENTICATING');
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
if (status == Strophe.Status.CONNECTING) {
|
115
|
+
log('Strophe is connecting.');
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
|
119
|
+
clearTimeout(initialTimer);
|
120
|
+
|
121
|
+
if (status == Strophe.Status.CONNFAIL) {
|
122
|
+
log('Strophe failed to connect.');
|
123
|
+
userConnected = false;
|
124
|
+
setTimeout ("onReconnect()", 3000);
|
125
|
+
} else if (status == Strophe.Status.AUTHFAIL) {
|
126
|
+
log('Strophe authentication fail.');
|
127
|
+
if ((window.sessionStorage)&&(sessionStorage.getItem("ss_user_pass") != null)){
|
128
|
+
sessionStorage.setItem("ss_user_pass",null);
|
129
|
+
}
|
130
|
+
userConnected = false;
|
131
|
+
} else if (status == Strophe.Status.ERROR) {
|
132
|
+
log('Strophe error.');
|
133
|
+
userConnected = false;
|
134
|
+
} else if (status == Strophe.Status.DISCONNECTED) {
|
135
|
+
log('Strophe is disconnected.');
|
136
|
+
userConnected = false;
|
137
|
+
clearTimeout(awayTimer);
|
138
|
+
setTimeout ("onReconnect()", 3000);
|
139
|
+
} else if (status == Strophe.Status.CONNECTED) {
|
140
|
+
log('Strophe is connected.');
|
141
|
+
log('Presenze stanza send for:' + connection.jid);
|
142
|
+
connection.addHandler(onMessage, null, 'message', null, null, null);
|
143
|
+
connection.addHandler(onPresence, null, 'presence', null, null, null);
|
144
|
+
//addHandler:(callback, namespace to match, stanza name, stanza type, stanza id , stanza from, options)
|
145
|
+
sendStatus(userStatus);
|
146
|
+
userConnected = true;
|
147
|
+
awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
|
148
|
+
timer = setInterval("timerFunction()", timerPeriod);
|
149
|
+
}
|
150
|
+
|
151
|
+
updateChatWindow();
|
152
|
+
}
|
153
|
+
|
154
|
+
function onReconnect(){
|
155
|
+
if ((connection != null)&&(!userConnected)) {
|
156
|
+
if (reconnectAttempts>0) {
|
157
|
+
reconnectAttempts--;
|
158
|
+
|
159
|
+
if (authByCookie()){
|
160
|
+
//Authentication by cookie
|
161
|
+
connectToServerWithCookie();
|
162
|
+
} else {
|
163
|
+
//Authentication by password
|
164
|
+
connectToServerWithPassword(null);
|
165
|
+
}
|
166
|
+
setTimeout ("onReconnect()", 9000);
|
167
|
+
} else {
|
168
|
+
//Notify issue to Rails App Server?
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
////////
|
175
|
+
//Manage Message stanzas
|
176
|
+
///////
|
177
|
+
function onMessage(msg) {
|
178
|
+
var to = msg.getAttribute('to');
|
179
|
+
var from = msg.getAttribute('from');
|
180
|
+
var type = msg.getAttribute('type');
|
181
|
+
var elems = msg.getElementsByTagName('body');
|
182
|
+
|
183
|
+
if (type == "chat" && elems.length > 0) {
|
184
|
+
|
185
|
+
var body = elems[0];
|
186
|
+
var from_slug = from.split("@")[0];
|
187
|
+
var from_name = $("#" + from_slug).attr("name");
|
188
|
+
var from_jid = from_slug + "@" + domain;
|
189
|
+
|
190
|
+
|
191
|
+
if (typeof ($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
|
192
|
+
//No connectionBox for this user!
|
193
|
+
var from_name = from_slug;
|
194
|
+
refreshChatWindow();
|
195
|
+
} else {
|
196
|
+
showConnectionBoxFromSlug(from_slug);
|
197
|
+
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
198
|
+
}
|
199
|
+
|
200
|
+
if (createChatBox(from_slug,from_name,from_jid,user_name,user_jid)) {
|
201
|
+
} else {
|
202
|
+
window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
|
203
|
+
}
|
204
|
+
|
205
|
+
var content = getParsedContent(Strophe.getText(body),false)
|
206
|
+
//Send message to chatBox and post-message functions.
|
207
|
+
$("#" + from_slug).chatbox("option", "boxManager").addMsg(from_name, content);
|
208
|
+
rotatePriority(from_slug);
|
209
|
+
blinkTitleOnMessage(from_name);
|
210
|
+
if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])){
|
211
|
+
playSound("onMessageAudio");
|
212
|
+
}
|
213
|
+
|
214
|
+
}
|
215
|
+
|
216
|
+
// we must return true to keep the handler alive.
|
217
|
+
// returning false would remove it after it finishes.
|
218
|
+
return true;
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
////////
|
223
|
+
//Manage Presence stanzas
|
224
|
+
///////
|
225
|
+
function onPresence(presence) {
|
226
|
+
|
227
|
+
//Check presence stanza type
|
228
|
+
ptype = $(presence).attr('type');
|
229
|
+
|
230
|
+
switch (ptype){
|
231
|
+
case undefined:
|
232
|
+
processAvailablePresenceStanza(presence)
|
233
|
+
break;
|
234
|
+
case "available":
|
235
|
+
processAvailablePresenceStanza(presence)
|
236
|
+
break;
|
237
|
+
case "unavailable":
|
238
|
+
processUnavailablePresenceStanza(presence)
|
239
|
+
break;
|
240
|
+
default :
|
241
|
+
//Stanza type not recognize
|
242
|
+
processAvailablePresenceStanza(presence)
|
243
|
+
}
|
244
|
+
|
245
|
+
return true;
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
function processAvailablePresenceStanza(presence){
|
250
|
+
from = $(presence).attr('from');
|
251
|
+
slug = from.split("@")[0];
|
252
|
+
|
253
|
+
if (slug != user_slug) {
|
254
|
+
if (getConnectionBoxFromSlug(slug)!=null){
|
255
|
+
status = $(presence).find('show').text();
|
256
|
+
setUserIconStatus(slug, status);
|
257
|
+
if (cacheConnectedUsers.indexOf(slug) != -1) {
|
258
|
+
showConnectionBoxFromSlug(slug);
|
259
|
+
}
|
260
|
+
} else {
|
261
|
+
setTimeout("refreshChatWindow()", 3000);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
function processUnavailablePresenceStanza(presence){
|
267
|
+
from = $(presence).attr('from');
|
268
|
+
slug = from.split("@")[0];
|
269
|
+
|
270
|
+
if (slug != user_slug) {
|
271
|
+
if (getConnectionBoxFromSlug(slug)!=null){
|
272
|
+
hideConnectionBoxFromSlug(slug)
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
////////
|
278
|
+
//Send Message stanzas
|
279
|
+
///////
|
280
|
+
function sendChatMessage(from,to,text){
|
281
|
+
var type = "chat";
|
282
|
+
var body= $build("body");
|
283
|
+
body.t(text);
|
284
|
+
var message = $msg({to: to, from: from, type: 'chat'}).cnode(body.tree());
|
285
|
+
connection.send(message.tree());
|
286
|
+
resumeAwayTimerIfAway();
|
287
|
+
return true;
|
288
|
+
}
|
289
|
+
|
290
|
+
|
291
|
+
////////
|
292
|
+
//Send Presence stanzas with status
|
293
|
+
///////
|
294
|
+
function sendStatus(status){
|
295
|
+
if (status in statusMessage){
|
296
|
+
//Send status to the XMPP Server
|
297
|
+
var pres = $pres()
|
298
|
+
.c('status')
|
299
|
+
.t(statusMessage[status]).up() //Status message
|
300
|
+
.c('show')
|
301
|
+
.t(status);
|
302
|
+
connection.send(pres.tree());
|
303
|
+
}
|
304
|
+
}
|
@@ -8,6 +8,16 @@
|
|
8
8
|
background: #CCCCCC;
|
9
9
|
}
|
10
10
|
|
11
|
+
.ui-state-highlight {
|
12
|
+
background: #CCCCCC;
|
13
|
+
background-color: #CCCCCC;
|
14
|
+
border: 1px solid lightgrey;
|
15
|
+
}
|
16
|
+
|
17
|
+
.chatWindowhighlighted {
|
18
|
+
color: #CAC8F4;
|
19
|
+
}
|
20
|
+
|
11
21
|
.ui-chatbox-titlebar {
|
12
22
|
padding: 3px 3px 3px 3px;
|
13
23
|
height: 20px;
|
@@ -53,6 +63,28 @@
|
|
53
63
|
}
|
54
64
|
|
55
65
|
|
66
|
+
/* Ticks */
|
67
|
+
|
68
|
+
.chat-thick {
|
69
|
+
/* Possible background-image for thicks provided by jquery.ui 454545 , 222222 , 888888 , cd0a0a , ... */
|
70
|
+
background-image: url("images/ui-icons_454545_256x240.png");
|
71
|
+
background-repeat: no-repeat;
|
72
|
+
display: block;
|
73
|
+
overflow: hidden;
|
74
|
+
text-indent: -99999px;
|
75
|
+
height: 16px;
|
76
|
+
width: 16px;
|
77
|
+
}
|
78
|
+
|
79
|
+
.chat-minusthick{
|
80
|
+
background-position: -64px -128px;
|
81
|
+
}
|
82
|
+
|
83
|
+
.chat-closethick{
|
84
|
+
background-position: -96px -128px;
|
85
|
+
}
|
86
|
+
|
87
|
+
|
56
88
|
/* Presence Partial */
|
57
89
|
|
58
90
|
div.user_presence {
|
@@ -241,6 +273,14 @@ input.connectChatButton{
|
|
241
273
|
|
242
274
|
/* Chat text style */
|
243
275
|
|
276
|
+
.ownChatText {
|
277
|
+
color: #342E82;
|
278
|
+
}
|
279
|
+
|
280
|
+
.guestChatText {
|
281
|
+
color: #342E82;
|
282
|
+
}
|
283
|
+
|
244
284
|
.chatImage {
|
245
285
|
max-width: 100px;
|
246
286
|
max-height: 100px;
|
@@ -6,9 +6,7 @@ class XmppController < ApplicationController
|
|
6
6
|
'chat' => 'available',
|
7
7
|
'away' => 'away',
|
8
8
|
'xa' => 'away',
|
9
|
-
'dnd' => 'dnd'
|
10
|
-
#Special status to disable chat
|
11
|
-
'disable' => 'disable'
|
9
|
+
'dnd' => 'dnd'
|
12
10
|
}
|
13
11
|
|
14
12
|
|
@@ -127,16 +125,52 @@ class XmppController < ApplicationController
|
|
127
125
|
|
128
126
|
|
129
127
|
def chatWindow
|
130
|
-
|
131
|
-
|
128
|
+
|
129
|
+
if current_user and current_user.chat_enabled and (params[:userConnected]=="true")
|
130
|
+
render :partial => 'chat/contacts'
|
131
|
+
elsif current_user and current_user.chat_enabled
|
132
|
+
#User not connected
|
133
|
+
render :partial => 'chat/off'
|
132
134
|
else
|
133
|
-
#User
|
134
|
-
render :
|
135
|
-
end
|
135
|
+
#User with chat disabled
|
136
|
+
render :text => ''
|
137
|
+
end
|
136
138
|
end
|
137
139
|
|
138
|
-
|
139
140
|
|
141
|
+
def updateSettings
|
142
|
+
|
143
|
+
success = false
|
144
|
+
|
145
|
+
#If no section selected, skips and gives error
|
146
|
+
if params[:settings_section].present?
|
147
|
+
section = params[:settings_section].to_s
|
148
|
+
|
149
|
+
#Updating User Chat settings
|
150
|
+
if section.eql? "chat"
|
151
|
+
if current_user and current_subject and current_subject==current_user
|
152
|
+
current_user.chat_enabled = true if params[:enable_chat].present? and params[:enable_chat].to_s.eql? "true"
|
153
|
+
current_user.chat_enabled = false if !params[:enable_chat]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
#Here sections to add
|
158
|
+
#if section.eql? "section_name"
|
159
|
+
# blah blah blah
|
160
|
+
#end
|
161
|
+
|
162
|
+
#Was everything ok?
|
163
|
+
success = current_subject.save
|
164
|
+
end
|
165
|
+
|
166
|
+
#Flashing and redirecting
|
167
|
+
if success
|
168
|
+
flash[:success] = t('settings.success')
|
169
|
+
else
|
170
|
+
flash[:error] = t('settings.error')
|
171
|
+
end
|
172
|
+
redirect_to :controller => :settings, :action => :index
|
173
|
+
end
|
140
174
|
|
141
175
|
#TEST METHODS
|
142
176
|
def active_users
|
File without changes
|
File without changes
|
@@ -1,16 +1,6 @@
|
|
1
|
-
<% if current_user and current_subject.subject_type=="User" %>
|
2
|
-
|
3
|
-
<% content_for :headers do %>
|
4
|
-
<%= stylesheet_link_tag "chat.css", :media => "screen, projection" %>
|
5
|
-
<%= javascript_include_tag 'jquery-ui-1.8.14.custom.min'%>
|
6
|
-
<%= javascript_include_tag 'jquery.ui.chatbox'%>
|
7
|
-
<%= javascript_include_tag 'jquery.tools.min'%>
|
8
|
-
<%= javascript_include_tag 'strophe'%>
|
9
|
-
<%= javascript_include_tag 'xmpp_client'%>
|
10
|
-
<%= javascript_include_tag 'store'%>
|
11
|
-
<% end %>
|
12
|
-
|
1
|
+
<% if current_user and current_user.chat_enabled and current_subject.subject_type=="User" %>
|
13
2
|
|
3
|
+
|
14
4
|
<script type="text/javascript">
|
15
5
|
|
16
6
|
//Global variables
|
@@ -45,7 +35,7 @@
|
|
45
35
|
|
46
36
|
|
47
37
|
<div id="chat_partial">
|
48
|
-
<%= render :partial => '
|
38
|
+
<%= render :partial => 'chat/connecting' %>
|
49
39
|
</div>
|
50
40
|
|
51
41
|
<% end %>
|