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
c07c0f56
Commit
c07c0f56
authored
Apr 30, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Communicate status code information to chatroom users.
Also bugfix that showed the wrong time for delayed messages.
parent
dd1d56b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
13 deletions
+42
-13
converse.js
converse.js
+42
-13
No files found.
converse.js
View file @
c07c0f56
...
...
@@ -702,7 +702,7 @@
template
:
_
.
template
(
'
<form class="add-chatroom" action="" method="post">
'
+
'
<input type="text" name="chatroom" class="new-chatroom-name" placeholder="Room name"/>
'
+
'
<input type="text" name="server" class="new-chatroom-server" placeholder="Server"
value="{{server_name}}"
/>
'
+
'
<input type="text" name="server" class="new-chatroom-server" placeholder="Server"/>
'
+
'
<button type="submit">Join</button>
'
+
'
</form>
'
+
'
<dl id="available-chatrooms">
'
+
...
...
@@ -711,8 +711,7 @@
render
:
function
()
{
this
.
$parent
.
find
(
'
#controlbox-tabs
'
).
append
(
this
.
tab_template
());
var
server_name
=
this
.
muc_domain
;
this
.
$parent
.
find
(
'
#controlbox-panes
'
).
append
(
this
.
$el
.
html
(
this
.
template
({
server_name
:
server_name
})).
hide
());
this
.
$parent
.
find
(
'
#controlbox-panes
'
).
append
(
this
.
$el
.
html
(
this
.
template
()).
hide
());
return
this
;
},
...
...
@@ -813,12 +812,12 @@
featureAdded
:
function
(
feature
)
{
if
(
feature
.
get
(
'
var
'
)
==
'
http://jabber.org/protocol/muc
'
)
{
if
(
!
this
.
roomspanel
)
{
this
.
roomspanel
=
new
converse
.
RoomsPanel
();
this
.
roomspanel
.
muc_domain
=
feature
.
get
(
'
from
'
);
this
.
roomspanel
.
$parent
=
this
.
$el
;
this
.
roomspanel
.
render
().
trigger
(
'
update-rooms-list
'
);
var
$server
=
this
.
$el
.
find
(
'
input.new-chatroom-server
'
);
if
(
!
$server
.
is
(
'
:focus
'
))
{
$server
.
val
(
this
.
roomspanel
.
muc_domain
);
}
this
.
roomspanel
.
trigger
(
'
update-rooms-list
'
);
}
},
...
...
@@ -861,6 +860,9 @@
this
.
contactspanel
=
new
converse
.
ContactsPanel
();
this
.
contactspanel
.
$parent
=
this
.
$el
;
this
.
contactspanel
.
render
();
this
.
roomspanel
=
new
converse
.
RoomsPanel
();
this
.
roomspanel
.
$parent
=
this
.
$el
;
this
.
roomspanel
.
render
();
}
return
this
;
}
...
...
@@ -874,7 +876,6 @@
'
click a.close-chatbox-button
'
:
'
closeChat
'
,
'
keypress textarea.chat-textarea
'
:
'
keyPressed
'
},
info_template
:
_
.
template
(
'
<div class="chat-event">{{message}}</div>
'
),
sendChatRoomMessage
:
function
(
body
)
{
...
...
@@ -985,15 +986,42 @@
return
true
;
},
communicateStatusCodes
:
function
(
$message
,
$chat_content
)
{
/* Parse the message for status codes and communicate their purpose
* to the user.
* See: http://xmpp.org/registrar/mucstatus.html
*/
var
status_messages
=
{
100
:
'
This room is not anonymous
'
,
102
:
'
This room now shows unavailable members
'
,
103
:
'
This room does not show unavailable members
'
,
104
:
'
Non-privacy-related room configuration has changed
'
,
170
:
'
Room logging is now enabled
'
,
171
:
'
Room logging is now disabled
'
,
172
:
'
This room is now non-anonymous
'
,
173
:
'
This room is now semi-anonymous
'
,
174
:
'
This room is now fully-anonymous
'
};
$message
.
find
(
'
x
'
).
find
(
'
status
'
).
each
(
$
.
proxy
(
function
(
idx
,
item
)
{
var
code
=
$
(
item
).
attr
(
'
code
'
);
var
message
=
code
&&
status_messages
[
code
]
||
null
;
if
(
message
)
{
$chat_content
.
append
(
this
.
info_template
({
message
:
message
}));
}
},
this
));
},
onChatRoomMessage
:
function
(
message
)
{
var
$message
=
$
(
message
),
body
=
$message
.
children
(
'
body
'
).
text
(),
jid
=
$message
.
attr
(
'
from
'
),
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
),
sender
=
Strophe
.
unescapeNode
(
Strophe
.
getResourceFromJid
(
jid
)),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
sender
=
resource
&&
Strophe
.
unescapeNode
(
resource
)
||
''
,
delayed
=
$message
.
find
(
'
delay
'
).
length
>
0
,
subject
=
$message
.
children
(
'
subject
'
).
text
(),
match
,
template
,
message_datetime
,
message_date
,
dates
,
isodate
;
match
,
template
,
message_datetime
,
message_date
,
dates
,
isodate
,
stamp
;
if
(
delayed
)
{
stamp
=
$message
.
find
(
'
delay
'
).
attr
(
'
stamp
'
);
message_datetime
=
converse
.
parseISO8601
(
stamp
);
...
...
@@ -1003,7 +1031,7 @@
// If this message is on a different day than the one received
// prior, then indicate it on the chatbox.
dates
=
$chat_content
.
find
(
"
time
"
).
map
(
function
(){
return
$
(
this
).
attr
(
"
datetime
"
);}).
get
();
message_date
=
message_datetime
;
message_date
=
new
Date
(
message_datetime
.
getTime
())
;
message_date
.
setUTCHours
(
0
,
0
,
0
,
0
);
isodate
=
converse
.
toISOString
(
message_date
);
if
(
_
.
indexOf
(
dates
,
isodate
)
==
-
1
)
{
...
...
@@ -1012,6 +1040,7 @@
datestring
:
message_date
.
toString
().
substring
(
0
,
15
)
}));
}
this
.
communicateStatusCodes
(
$message
,
$chat_content
);
if
(
subject
)
{
this
.
$el
.
find
(
'
.chatroom-topic
'
).
text
(
subject
).
attr
(
'
title
'
,
subject
);
$chat_content
.
append
(
this
.
info_template
({
'
message
'
:
'
Topic set by
'
+
sender
+
'
to:
'
+
subject
}));
...
...
@@ -1030,7 +1059,7 @@
$chat_content
.
append
(
template
({
'
sender
'
:
sender
==
'
me
'
&&
sender
||
'
room
'
,
'
time
'
:
message_date
.
toLocaleTimeString
().
substring
(
0
,
5
),
'
time
'
:
message_date
time
.
toLocaleTimeString
().
substring
(
0
,
5
),
'
message
'
:
body
,
'
username
'
:
sender
,
'
extra_classes
'
:
delayed
&&
'
delayed
'
||
''
...
...
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