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
d278f803
Commit
d278f803
authored
Jul 21, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rudimentary chatroom roster support
parent
d8c68449
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
14 deletions
+43
-14
chat.js
chat.js
+43
-14
No files found.
chat.js
View file @
d278f803
...
...
@@ -464,28 +464,16 @@ xmppchat.ControlBoxView = xmppchat.ChatBoxView.extend({
});
xmppchat
.
ChatRoom
=
xmppchat
.
ChatBox
.
extend
({
onPresence
:
function
(
x
,
y
,
z
)
{
//alert('onPresence');
},
onMessage
:
function
(
x
,
y
,
z
)
{
alert
(
'
onMessage
'
);
},
onRoster
:
function
(
x
,
y
,
z
)
{
alert
(
'
onRoster
'
);
},
initialize
:
function
(
jid
)
{
var
nick
=
Strophe
.
getNodeFromJid
(
xmppchat
.
connection
.
jid
);
this
.
set
({
'
id
'
:
jid
,
'
name
'
:
Strophe
.
getNodeFromJid
(
jid
),
'
nick
'
:
Strophe
.
getNodeFromJid
(
xmppchat
.
connection
.
jid
),
'
jid
'
:
jid
,
'
participants
'
:
[],
'
box_id
'
:
this
.
hash
(
jid
)
},
{
'
silent
'
:
true
});
var
result
=
xmppchat
.
connection
.
muc
.
join
(
jid
,
nick
,
this
.
onMessage
,
this
.
onPresence
,
this
.
onRoomMessage
);
}
});
...
...
@@ -502,6 +490,7 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
this
.
closeChat
();
},
// XXX: add $participants to the template?
template
:
_
.
template
(
'
<div class="chat-head chat-head-chatroom">
'
+
'
<div class="chat-title"> <%= name %> </div>
'
+
...
...
@@ -526,6 +515,46 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
'
</div>
'
+
'
</div>
'
),
initialize
:
function
()
{
xmppchat
.
connection
.
muc
.
join
(
this
.
model
.
get
(
'
jid
'
),
this
.
model
.
get
(
'
nick
'
),
$
.
proxy
(
this
.
onMessage
,
this
),
$
.
proxy
(
this
.
onPresence
,
this
),
$
.
proxy
(
this
.
onRoomMessage
,
this
));
},
onPresence
:
function
(
presence
,
room
)
{
var
nick
=
room
.
nick
,
from
=
$
(
presence
).
attr
(
'
from
'
),
participants
=
this
.
model
.
get
(
'
participants
'
);
if
(
!
participants
[
nick
]
&&
$
(
presence
).
attr
(
'
type
'
)
!==
'
unavailable
'
)
{
// add to participants list
participants
[
nick
]
=
$
(
presence
).
attr
(
'
jid
'
);
this
.
model
.
set
({
'
participants
'
:
participants
});
}
if
(
$
(
presence
).
attr
(
'
type
'
)
!==
'
error
'
)
{
// check for status 110 to see if it's our own presence
if
(
$
(
presence
).
find
(
"
status[code='110']
"
).
length
>
0
)
{
// check if server changed our nick
if
(
$
(
presence
).
find
(
"
status[code='210']
"
).
length
>
0
)
{
this
.
model
.
set
({
'
nick
'
:
Strophe
.
getResourceFromJid
(
from
)});
}
}
}
this
.
$el
.
find
(
'
.participant-list
'
).
append
(
'
<li>
'
+
nick
+
'
</li>
'
);
},
onMessage
:
function
(
x
,
y
,
z
)
{
alert
(
'
onMessage
'
);
},
onRoster
:
function
(
x
,
y
,
z
)
{
alert
(
'
onRoster
'
);
},
render
:
function
()
{
$
(
this
.
el
).
attr
(
'
id
'
,
this
.
model
.
get
(
'
box_id
'
));
$
(
this
.
el
).
html
(
this
.
template
(
this
.
model
.
toJSON
()));
...
...
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