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
Hide 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 @@
...
@@ -702,7 +702,7 @@
template
:
_
.
template
(
template
:
_
.
template
(
'
<form class="add-chatroom" action="" method="post">
'
+
'
<form class="add-chatroom" action="" method="post">
'
+
'
<input type="text" name="chatroom" class="new-chatroom-name" placeholder="Room name"/>
'
+
'
<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>
'
+
'
<button type="submit">Join</button>
'
+
'
</form>
'
+
'
</form>
'
+
'
<dl id="available-chatrooms">
'
+
'
<dl id="available-chatrooms">
'
+
...
@@ -711,8 +711,7 @@
...
@@ -711,8 +711,7 @@
render
:
function
()
{
render
:
function
()
{
this
.
$parent
.
find
(
'
#controlbox-tabs
'
).
append
(
this
.
tab_template
());
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
()).
hide
());
this
.
$parent
.
find
(
'
#controlbox-panes
'
).
append
(
this
.
$el
.
html
(
this
.
template
({
server_name
:
server_name
})).
hide
());
return
this
;
return
this
;
},
},
...
@@ -813,12 +812,12 @@
...
@@ -813,12 +812,12 @@
featureAdded
:
function
(
feature
)
{
featureAdded
:
function
(
feature
)
{
if
(
feature
.
get
(
'
var
'
)
==
'
http://jabber.org/protocol/muc
'
)
{
if
(
feature
.
get
(
'
var
'
)
==
'
http://jabber.org/protocol/muc
'
)
{
if
(
!
this
.
roomspanel
)
{
this
.
roomspanel
.
muc_domain
=
feature
.
get
(
'
from
'
);
this
.
roomspanel
=
new
converse
.
RoomsPanel
();
var
$server
=
this
.
$el
.
find
(
'
input.new-chatroom-server
'
);
this
.
roomspanel
.
muc_domain
=
feature
.
get
(
'
from
'
);
if
(
!
$server
.
is
(
'
:focus
'
))
{
this
.
roomspanel
.
$parent
=
this
.
$el
;
$server
.
val
(
this
.
roomspanel
.
muc_domain
);
this
.
roomspanel
.
render
().
trigger
(
'
update-rooms-list
'
);
}
}
this
.
roomspanel
.
trigger
(
'
update-rooms-list
'
);
}
}
},
},
...
@@ -861,6 +860,9 @@
...
@@ -861,6 +860,9 @@
this
.
contactspanel
=
new
converse
.
ContactsPanel
();
this
.
contactspanel
=
new
converse
.
ContactsPanel
();
this
.
contactspanel
.
$parent
=
this
.
$el
;
this
.
contactspanel
.
$parent
=
this
.
$el
;
this
.
contactspanel
.
render
();
this
.
contactspanel
.
render
();
this
.
roomspanel
=
new
converse
.
RoomsPanel
();
this
.
roomspanel
.
$parent
=
this
.
$el
;
this
.
roomspanel
.
render
();
}
}
return
this
;
return
this
;
}
}
...
@@ -874,7 +876,6 @@
...
@@ -874,7 +876,6 @@
'
click a.close-chatbox-button
'
:
'
closeChat
'
,
'
click a.close-chatbox-button
'
:
'
closeChat
'
,
'
keypress textarea.chat-textarea
'
:
'
keyPressed
'
'
keypress textarea.chat-textarea
'
:
'
keyPressed
'
},
},
info_template
:
_
.
template
(
'
<div class="chat-event">{{message}}</div>
'
),
info_template
:
_
.
template
(
'
<div class="chat-event">{{message}}</div>
'
),
sendChatRoomMessage
:
function
(
body
)
{
sendChatRoomMessage
:
function
(
body
)
{
...
@@ -985,15 +986,42 @@
...
@@ -985,15 +986,42 @@
return
true
;
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
)
{
onChatRoomMessage
:
function
(
message
)
{
var
$message
=
$
(
message
),
var
$message
=
$
(
message
),
body
=
$message
.
children
(
'
body
'
).
text
(),
body
=
$message
.
children
(
'
body
'
).
text
(),
jid
=
$message
.
attr
(
'
from
'
),
jid
=
$message
.
attr
(
'
from
'
),
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
),
$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
,
delayed
=
$message
.
find
(
'
delay
'
).
length
>
0
,
subject
=
$message
.
children
(
'
subject
'
).
text
(),
subject
=
$message
.
children
(
'
subject
'
).
text
(),
match
,
template
,
message_datetime
,
message_date
,
dates
,
isodate
;
match
,
template
,
message_datetime
,
message_date
,
dates
,
isodate
,
stamp
;
if
(
delayed
)
{
if
(
delayed
)
{
stamp
=
$message
.
find
(
'
delay
'
).
attr
(
'
stamp
'
);
stamp
=
$message
.
find
(
'
delay
'
).
attr
(
'
stamp
'
);
message_datetime
=
converse
.
parseISO8601
(
stamp
);
message_datetime
=
converse
.
parseISO8601
(
stamp
);
...
@@ -1003,7 +1031,7 @@
...
@@ -1003,7 +1031,7 @@
// If this message is on a different day than the one received
// If this message is on a different day than the one received
// prior, then indicate it on the chatbox.
// prior, then indicate it on the chatbox.
dates
=
$chat_content
.
find
(
"
time
"
).
map
(
function
(){
return
$
(
this
).
attr
(
"
datetime
"
);}).
get
();
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
);
message_date
.
setUTCHours
(
0
,
0
,
0
,
0
);
isodate
=
converse
.
toISOString
(
message_date
);
isodate
=
converse
.
toISOString
(
message_date
);
if
(
_
.
indexOf
(
dates
,
isodate
)
==
-
1
)
{
if
(
_
.
indexOf
(
dates
,
isodate
)
==
-
1
)
{
...
@@ -1012,6 +1040,7 @@
...
@@ -1012,6 +1040,7 @@
datestring
:
message_date
.
toString
().
substring
(
0
,
15
)
datestring
:
message_date
.
toString
().
substring
(
0
,
15
)
}));
}));
}
}
this
.
communicateStatusCodes
(
$message
,
$chat_content
);
if
(
subject
)
{
if
(
subject
)
{
this
.
$el
.
find
(
'
.chatroom-topic
'
).
text
(
subject
).
attr
(
'
title
'
,
subject
);
this
.
$el
.
find
(
'
.chatroom-topic
'
).
text
(
subject
).
attr
(
'
title
'
,
subject
);
$chat_content
.
append
(
this
.
info_template
({
'
message
'
:
'
Topic set by
'
+
sender
+
'
to:
'
+
subject
}));
$chat_content
.
append
(
this
.
info_template
({
'
message
'
:
'
Topic set by
'
+
sender
+
'
to:
'
+
subject
}));
...
@@ -1030,7 +1059,7 @@
...
@@ -1030,7 +1059,7 @@
$chat_content
.
append
(
$chat_content
.
append
(
template
({
template
({
'
sender
'
:
sender
==
'
me
'
&&
sender
||
'
room
'
,
'
sender
'
:
sender
==
'
me
'
&&
sender
||
'
room
'
,
'
time
'
:
message_date
.
toLocaleTimeString
().
substring
(
0
,
5
),
'
time
'
:
message_date
time
.
toLocaleTimeString
().
substring
(
0
,
5
),
'
message
'
:
body
,
'
message
'
:
body
,
'
username
'
:
sender
,
'
username
'
:
sender
,
'
extra_classes
'
:
delayed
&&
'
delayed
'
||
''
'
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