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
95a77e3f
Commit
95a77e3f
authored
Sep 12, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat room messages are now stored in browser storage.
parent
c04ed35b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
35 deletions
+17
-35
converse.js
converse.js
+17
-35
No files found.
converse.js
View file @
95a77e3f
...
@@ -910,12 +910,18 @@
...
@@ -910,12 +910,18 @@
createMessage
:
function
(
$message
)
{
createMessage
:
function
(
$message
)
{
var
body
=
$message
.
children
(
'
body
'
).
text
(),
var
body
=
$message
.
children
(
'
body
'
).
text
(),
from
=
Strophe
.
getBareJidFromJid
(
$message
.
attr
(
'
from
'
)),
composing
=
$message
.
find
(
'
composing
'
),
composing
=
$message
.
find
(
'
composing
'
),
paused
=
$message
.
find
(
'
paused
'
),
paused
=
$message
.
find
(
'
paused
'
),
delayed
=
$message
.
find
(
'
delay
'
).
length
>
0
,
delayed
=
$message
.
find
(
'
delay
'
).
length
>
0
,
fullname
=
this
.
get
(
'
fullname
'
),
fullname
=
this
.
get
(
'
fullname
'
),
stamp
,
time
,
sender
;
is_groupchat
=
$message
.
attr
(
'
type
'
)
===
'
groupchat
'
,
stamp
,
time
,
sender
,
from
;
if
(
is_groupchat
)
{
from
=
Strophe
.
unescapeNode
(
Strophe
.
getResourceFromJid
(
$message
.
attr
(
'
from
'
)));
}
else
{
from
=
Strophe
.
getBareJidFromJid
(
$message
.
attr
(
'
from
'
));
}
fullname
=
(
_
.
isEmpty
(
fullname
)?
from
:
fullname
).
split
(
'
'
)[
0
];
fullname
=
(
_
.
isEmpty
(
fullname
)?
from
:
fullname
).
split
(
'
'
)[
0
];
if
(
!
body
)
{
if
(
!
body
)
{
...
@@ -936,7 +942,7 @@
...
@@ -936,7 +942,7 @@
}
else
{
}
else
{
time
=
moment
().
format
();
time
=
moment
().
format
();
}
}
if
(
from
==
converse
.
bare_jid
)
{
if
(
(
is_groupchat
&&
from
===
this
.
get
(
'
nick
'
))
||
(
!
is_groupchat
&&
from
==
converse
.
bare_jid
)
)
{
sender
=
'
me
'
;
sender
=
'
me
'
;
}
else
{
}
else
{
sender
=
'
them
'
;
sender
=
'
them
'
;
...
@@ -2648,52 +2654,28 @@
...
@@ -2648,52 +2654,28 @@
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
'
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
sender
=
resource
&&
Strophe
.
unescapeNode
(
resource
)
||
''
,
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
,
dates
,
message_datetime
,
message_date
,
message_date_str
;
if
(
delayed
)
{
message_datetime
=
moment
(
$message
.
find
(
'
delay
'
).
attr
(
'
stamp
'
));
}
else
{
message_datetime
=
moment
();
}
// 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
.
clone
().
startOf
(
'
day
'
);
message_date_str
=
message_date
.
format
(
"
YYYY-MM-DD
"
);
if
(
_
.
indexOf
(
dates
,
message_date_str
)
===
-
1
)
{
$chat_content
.
append
(
converse
.
templates
.
new_day
({
isodate
:
message_date_str
,
datestring
:
message_date
.
format
(
"
dddd MMM Do YYYY
"
)
}));
}
this
.
showStatusMessages
(
$message
);
this
.
showStatusMessages
(
$message
);
if
(
subject
)
{
if
(
subject
)
{
this
.
$el
.
find
(
'
.chatroom-topic
'
).
text
(
subject
).
attr
(
'
title
'
,
subject
);
this
.
$el
.
find
(
'
.chatroom-topic
'
).
text
(
subject
).
attr
(
'
title
'
,
subject
);
// # For translators: the %1$s and %2$s parts will get replaced by the user and topic text respectively
// # For translators: the %1$s and %2$s parts will get replaced by the user and topic text respectively
// # Example: Topic set by JC Brand to: Hello World!
// # Example: Topic set by JC Brand to: Hello World!
$chat_content
.
append
(
this
.
$el
.
find
(
'
.chat-content
'
)
.
append
(
converse
.
templates
.
info
({
converse
.
templates
.
info
({
'
message
'
:
__
(
'
Topic set by %1$s to: %2$s
'
,
sender
,
subject
)
'
message
'
:
__
(
'
Topic set by %1$s to: %2$s
'
,
sender
,
subject
)
}));
}));
}
}
if
(
!
body
)
{
return
true
;
}
if
(
sender
===
''
)
{
var
display_sender
=
sender
===
this
.
model
.
get
(
'
nick
'
)
&&
'
me
'
||
'
room
'
;
return
true
;
if
(
!
delayed
&&
display_sender
===
'
room
'
&&
(
new
RegExp
(
"
\\
b
"
+
this
.
model
.
get
(
'
nick
'
)
+
"
\\
b
"
)).
test
(
body
))
{
}
this
.
model
.
createMessage
(
$message
);
if
(
!
delayed
&&
sender
!==
this
.
model
.
get
(
'
nick
'
)
&&
(
new
RegExp
(
"
\\
b
"
+
this
.
model
.
get
(
'
nick
'
)
+
"
\\
b
"
)).
test
(
body
))
{
playNotification
();
playNotification
();
}
}
this
.
showMessage
({
if
(
sender
!==
this
.
model
.
get
(
'
nick
'
))
{
'
message
'
:
body
,
'
sender
'
:
display_sender
,
'
fullname
'
:
sender
,
'
time
'
:
message_datetime
.
format
()
});
if
(
display_sender
===
'
room
'
)
{
// We only emit an event if it's not our own message
// We only emit an event if it's not our own message
converse
.
emit
(
'
message
'
,
message
);
converse
.
emit
(
'
message
'
,
message
);
}
}
...
...
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