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
3e964ccd
Commit
3e964ccd
authored
Jun 24, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't make a @@xmpp-userDetails ajax call. We can do it all client side.
parent
92a18780
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
chatui.js
chatui.js
+13
-20
No files found.
chatui.js
View file @
3e964ccd
...
@@ -13,36 +13,31 @@ xmppchat.UI = (function (xmppUI, $, console) {
...
@@ -13,36 +13,31 @@ xmppchat.UI = (function (xmppUI, $, console) {
// gone offline, we need to look in the ChatPartners storage to see
// gone offline, we need to look in the ChatPartners storage to see
// if there are more storages before we mark the user as offline in the UI.
// if there are more storages before we mark the user as offline in the UI.
var
user_id
=
Strophe
.
getNodeFromJid
(
jid
),
var
user_id
=
Strophe
.
getNodeFromJid
(
jid
),
barejid
=
Strophe
.
getBareJidFromJid
(
jid
),
bare
_
jid
=
Strophe
.
getBareJidFromJid
(
jid
),
existing_user_element
=
$
(
'
#online-users-
'
+
user_id
),
existing_user_element
=
$
(
'
#online-users-
'
+
user_id
),
online_count
;
online_count
;
if
(
bare
jid
===
Strophe
.
getBareJidFromJid
(
jarnxmpp
.
connection
.
jid
))
{
if
(
bare
_jid
===
Strophe
.
getBareJidFromJid
(
xmppchat
.
connection
.
jid
))
{
return
;
return
;
}
}
if
(
existing_user_element
.
length
)
{
if
(
existing_user_element
.
length
)
{
if
(
status
===
'
offline
'
&&
jarnxmpp
.
Presence
.
online
.
hasOwnProperty
(
user_id
))
{
if
(
status
===
'
offline
'
&&
xmppchat
.
Presence
.
online
.
hasOwnProperty
(
user_id
))
{
existing_user_element
.
attr
(
'
class
'
,
status
);
existing_user_element
.
attr
(
'
class
'
,
status
);
return
;
return
;
}
}
existing_user_element
.
attr
(
'
class
'
,
status
);
existing_user_element
.
attr
(
'
class
'
,
status
);
}
else
{
}
else
{
$
.
get
(
portal_url
+
'
/xmpp-userDetails?jid=
'
+
barejid
,
function
(
user_details
)
{
// FIXME: this ajax call returns a bunch of unnecessary stuff...
if
(
$
(
'
#online-users-
'
+
user_id
).
length
>
0
)
{
if
(
$
(
'
#online-users-
'
+
user_id
).
length
>
0
)
{
return
;
return
;
}
}
user_details
=
$
(
user_details
);
var
li
=
$
(
'
<li></li>
'
).
attr
(
'
id
'
,
'
online-users-
'
+
user_id
).
attr
(
'
data-recipient
'
,
jid
);
$
(
'
#online-users
'
).
append
(
user_details
);
li
.
append
(
$
(
'
<a></a>
'
).
addClass
(
'
user-details-toggle
'
).
text
(
user_id
));
$
(
'
#online-users li[data-userid]
'
).
sortElements
(
function
(
a
,
b
)
{
$
(
'
#online-users
'
).
append
(
li
);
return
$
(
'
a.user-details-toggle
'
,
a
).
text
().
trim
()
>
$
(
'
a.user-details-toggle
'
,
b
).
text
().
trim
()
?
1
:
-
1
;
});
});
// Pre-fetch user info if we have a session storage.
// Pre-fetch user info if we have a session storage.
if
(
jarnxmpp
.
Storage
.
storage
!==
null
)
{
if
(
xmppchat
.
Storage
.
storage
!==
null
)
{
jarnxmpp
.
Presence
.
getUserInfo
(
user_id
,
function
(
data
)
{});
xmppchat
.
Presence
.
getUserInfo
(
user_id
,
function
(
data
)
{});
}
}
}
}
online_count
=
jarnxmpp
.
Presence
.
onlineCount
();
online_count
=
xmppchat
.
Presence
.
onlineCount
();
if
(
online_count
>
0
)
{
if
(
online_count
>
0
)
{
$
(
'
#no-users-online
'
).
hide
();
$
(
'
#no-users-online
'
).
hide
();
}
else
{
}
else
{
...
@@ -431,10 +426,8 @@ $(document).ready(function () {
...
@@ -431,10 +426,8 @@ $(document).ready(function () {
});
});
$
(
'
a.user-details-toggle
'
).
live
(
'
click
'
,
function
(
e
)
{
$
(
'
a.user-details-toggle
'
).
live
(
'
click
'
,
function
(
e
)
{
var
$field
=
$
(
'
[name="message"]:input
'
,
$
(
this
).
parent
()[
0
]),
jid
=
$field
.
attr
(
'
data-recipient
'
);
e
.
preventDefault
();
e
.
preventDefault
();
xmppchat
.
UI
.
getChatbox
(
jid
);
xmppchat
.
UI
.
getChatbox
(
$
(
this
).
parent
().
attr
(
'
data-recipient
'
)
);
});
});
$
(
'
textarea.chat-textarea
'
).
live
(
'
keypress
'
,
function
(
ev
)
{
$
(
'
textarea.chat-textarea
'
).
live
(
'
keypress
'
,
function
(
ev
)
{
...
...
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