Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
4b94968f
Commit
4b94968f
authored
Jul 01, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better status handling. We shouldn't access ClientStorage from UI side
parent
de549fe8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
+24
-21
chatui.js
chatui.js
+24
-21
No files found.
chatui.js
View file @
4b94968f
...
@@ -11,33 +11,36 @@ xmppchat.UI = (function (xmppUI, $, console) {
...
@@ -11,33 +11,36 @@ xmppchat.UI = (function (xmppUI, $, console) {
ob
.
updateOnPresence
=
function
(
jid
,
status
,
presence
)
{
ob
.
updateOnPresence
=
function
(
jid
,
status
,
presence
)
{
var
user_id
=
Strophe
.
getNodeFromJid
(
jid
),
var
user_id
=
Strophe
.
getNodeFromJid
(
jid
),
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
),
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
),
resource
,
existing_user_element
,
online_count
;
resource
,
online_count
,
$chat
=
$
(
"
#
"
+
helpers
.
hash
(
bare_jid
)),
$chat_content
,
existing_user_element
=
$
(
'
#online-users-
'
+
user_id
);
if
(
xmppchat
.
isOwnUser
(
jid
))
{
return
;
}
if
(
xmppchat
.
isOwnUser
(
jid
))
{
return
;
}
existing_user_element
=
$
(
'
#online-users-
'
+
user_id
);
if
(
$chat
.
length
>
0
)
{
if
((
status
===
'
offline
'
)
||
(
status
===
'
unavailable
'
))
{
$chat_content
=
$chat
.
find
(
"
.chat-content
"
);
// Remove the resource.
$chat_content
.
find
(
'
div.chat-event
'
).
remove
();
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
);
if
(
status
===
'
offline
'
)
{
resource
=
Strophe
.
getResourceFromJid
(
jid
);
xmppchat
.
Presence
.
getUserInfo
(
user_id
,
function
(
data
)
{
if
(
xmppchat
.
ChatPartners
.
remove
(
bare_jid
,
resource
)
===
0
)
{
$chat_content
.
append
(
$
(
'
<div></div>
'
).
addClass
(
'
chat-event
'
).
text
(
data
.
fullname
+
'
has gone offline.
'
));
// Only set the status offline if there aren't any other resources for that user
$chat_content
.
scrollTop
(
$content
[
0
].
scrollHeight
);
if
(
existing_user_element
.
length
>
0
)
{
});
existing_user_element
.
attr
(
'
class
'
,
status
);
}
}
return
;
}
}
}
else
{
if
(
existing_user_element
.
length
>
0
)
{
if
(
existing_user_element
.
length
>
0
)
{
existing_user_element
.
attr
(
'
class
'
,
status
);
existing_user_element
.
attr
(
'
class
'
,
status
);
}
else
{
}
else
if
((
status
!==
'
offline
'
)
&&
(
status
!==
'
unavailable
'
))
{
xmppchat
.
Presence
.
getUserInfo
(
user_id
,
function
(
data
)
{
xmppchat
.
Presence
.
getUserInfo
(
user_id
,
function
(
data
)
{
if
(
$
(
'
#online-users-
'
+
user_id
).
length
>
0
)
{
return
;
}
if
(
$
(
'
#online-users-
'
+
user_id
).
length
>
0
)
{
return
;
}
var
li
=
$
(
'
<li></li>
'
).
attr
(
'
id
'
,
'
online-users-
'
+
user_id
).
attr
(
'
data-recipient
'
,
bare_jid
);
var
li
=
$
(
'
<li></li>
'
).
attr
(
'
id
'
,
'
online-users-
'
+
user_id
).
attr
(
'
data-recipient
'
,
bare_jid
);
li
.
append
(
$
(
'
<a></a>
'
).
addClass
(
'
user-details-toggle
'
).
text
(
data
.
fullname
));
li
.
append
(
$
(
'
<a></a>
'
).
addClass
(
'
user-details-toggle
'
).
text
(
data
.
fullname
));
$
(
'
#online-users
'
).
append
(
li
);
$
(
'
#online-users
'
).
append
(
li
);
});
});
}
}
else
{
// status is offline and the user isn't shown as online
return
;
}
}
$
(
'
#online-count
'
).
text
(
xmppchat
.
Presence
.
onlineCount
());
$
(
'
#online-count
'
).
text
(
xmppchat
.
Presence
.
onlineCount
());
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment