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
eb8fb67b
Commit
eb8fb67b
authored
Jun 24, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the last messages and append them (still not 100% bugfree)
parent
de73fb21
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
chatui.js
chatui.js
+31
-4
No files found.
chatui.js
View file @
eb8fb67b
...
...
@@ -91,8 +91,7 @@ xmppchat.UI = (function (xmppUI, $, console) {
data
:
{
chat_id
:
'
chatbox_
'
+
jid
,
box_id
:
chat_id
,
jid
:
jid
,
tzoffset
:
-
(
new
Date
().
getTimezoneOffset
())
jid
:
jid
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
console
.
log
(
textStatus
);
...
...
@@ -100,8 +99,8 @@ xmppchat.UI = (function (xmppUI, $, console) {
return
;
},
success
:
function
(
data
)
{
var
chat_id
=
$
(
data
).
attr
(
'
id
'
)
;
var
$chat
=
$
(
'
body
'
).
append
(
data
).
find
(
'
#
'
+
chat_id
);
var
chat_id
=
$
(
data
).
attr
(
'
id
'
)
,
$chat
=
$
(
'
body
'
).
append
(
data
).
find
(
'
#
'
+
chat_id
);
$chat
.
find
(
'
.chat-message .time
'
).
each
(
function
()
{
var
jthis
=
$
(
this
);
var
time
=
jthis
.
text
().
split
(
'
:
'
);
...
...
@@ -112,6 +111,34 @@ xmppchat.UI = (function (xmppUI, $, console) {
date
.
setMinutes
(
minutes
);
jthis
.
replaceWith
(
date
.
toLocaleTimeString
().
substring
(
0
,
5
));
});
xmppchat
.
Collections
.
getLastMessages
(
jid
,
function
(
result
)
{
$
(
result
).
find
(
'
chat
'
).
children
().
each
(
function
(
idx
,
el
)
{
if
(
el
.
tagName
!==
'
set
'
)
{
// TODO: Calculate the time. We have the start time and the offset for each message...
var
chat_id
=
$
(
data
).
attr
(
'
id
'
);
var
$chat
=
$
(
'
body
'
).
append
(
data
).
find
(
'
#
'
+
chat_id
);
var
$content
=
$chat
.
find
(
"
.chat-content
"
);
var
text
=
$
(
el
).
find
(
'
body
'
).
text
();
var
now
=
new
Date
();
var
time
=
now
.
toLocaleTimeString
().
substring
(
0
,
5
),
div
=
$
(
'
<div class="chat-message delayed"></div>
'
);
if
(
el
.
tagName
==
'
to
'
)
{
message_html
=
div
.
append
(
'
<span class="chat-message-me">
'
+
time
+
'
me: </span>
'
+
'
<span class="chat-message-content">
'
+
text
+
'
</span>
'
);
}
else
{
message_html
=
div
.
append
(
'
<span class="chat-message-them">
'
+
time
+
'
'
+
data
.
fullname
+
'
: </span>
'
+
'
<span class="chat-message-content">
'
+
text
+
'
</span>
'
);
}
$content
.
append
(
message_html
);
$content
.
scrollTop
(
$content
[
0
].
scrollHeight
);
}
});
});
callback
(
$chat
);
}
});
...
...
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