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
a4b69ded
Commit
a4b69ded
authored
Mar 24, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save to localStorage messages sent in chatroom.
Also removed the need for the appendMessage method.
parent
b49f2155
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
37 deletions
+20
-37
converse.js
converse.js
+20
-37
No files found.
converse.js
View file @
a4b69ded
...
@@ -294,11 +294,14 @@
...
@@ -294,11 +294,14 @@
'
<span class="chat-message-content">{{message}}</span>
'
+
'
<span class="chat-message-content">{{message}}</span>
'
+
'
</div>
'
),
'
</div>
'
),
appendMessage
:
function
(
message
)
{
insertStatusNotification
:
function
(
message
,
replace
)
{
var
now
=
new
Date
(),
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
time
=
now
.
toLocaleTimeString
().
substring
(
0
,
5
),
$chat_content
.
find
(
'
div.chat-event
'
).
remove
().
end
()
minutes
=
now
.
getMinutes
().
toString
(),
.
append
(
$
(
'
<div class="chat-event"></div>
'
).
text
(
message
));
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
this
.
scrollDown
();
},
showMessage
:
function
(
message
)
{
/*
/*
* FIXME: we don't use client storage anymore
* FIXME: we don't use client storage anymore
var msg = xmppchat.storage.getLastMessage(this.model.get('jid'));
var msg = xmppchat.storage.getLastMessage(this.model.get('jid'));
...
@@ -310,28 +313,6 @@
...
@@ -310,28 +313,6 @@
}
}
}
}
*/
*/
message
=
xmppchat
.
autoLink
(
message
);
// TODO use minutes logic or remove it
if
(
minutes
.
length
==
1
)
{
minutes
=
'
0
'
+
minutes
;}
$chat_content
.
find
(
'
div.chat-event
'
).
remove
();
$chat_content
.
append
(
this
.
message_template
({
'
sender
'
:
'
me
'
,
'
time
'
:
time
,
'
message
'
:
message
,
'
username
'
:
'
me
'
,
'
extra_classes
'
:
''
}));
this
.
scrollDown
();
},
insertStatusNotification
:
function
(
message
,
replace
)
{
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
$chat_content
.
find
(
'
div.chat-event
'
).
remove
().
end
()
.
append
(
$
(
'
<div class="chat-event"></div>
'
).
text
(
message
));
this
.
scrollDown
();
},
showMessage
:
function
(
message
)
{
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
);
if
(
xmppchat
.
xmppstatus
.
getStatus
()
===
'
offline
'
)
{
if
(
xmppchat
.
xmppstatus
.
getStatus
()
===
'
offline
'
)
{
// only update the UI if the user is not offline
// only update the UI if the user is not offline
...
@@ -357,7 +338,10 @@
...
@@ -357,7 +338,10 @@
},
},
isDifferentDay
:
function
(
prev_date
,
next_date
)
{
isDifferentDay
:
function
(
prev_date
,
next_date
)
{
return
((
next_date
.
getDate
()
!=
prev_date
.
getDate
())
||
(
next_date
.
getFullYear
()
!=
prev_date
.
getFullYear
())
||
(
next_date
.
getMonth
()
!=
prev_date
.
getMonth
()));
return
(
(
next_date
.
getDate
()
!=
prev_date
.
getDate
())
||
(
next_date
.
getFullYear
()
!=
prev_date
.
getFullYear
())
||
(
next_date
.
getMonth
()
!=
prev_date
.
getMonth
()));
},
},
addHelpMessages
:
function
(
msgs
)
{
addHelpMessages
:
function
(
msgs
)
{
...
@@ -520,10 +504,6 @@
...
@@ -520,10 +504,6 @@
return
this
;
return
this
;
},
},
isVisible
:
function
()
{
return
this
.
$el
.
is
(
'
:visible
'
);
},
focus
:
function
()
{
focus
:
function
()
{
this
.
$el
.
find
(
'
.chat-textarea
'
).
focus
();
this
.
$el
.
find
(
'
.chat-textarea
'
).
focus
();
return
this
;
return
this
;
...
@@ -809,7 +789,6 @@
...
@@ -809,7 +789,6 @@
},
},
sendChatRoomMessage
:
function
(
body
)
{
sendChatRoomMessage
:
function
(
body
)
{
this
.
appendMessage
(
body
);
var
match
=
body
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
)
||
[
false
],
var
match
=
body
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
)
||
[
false
],
$chat_content
;
$chat_content
;
switch
(
match
[
1
])
{
switch
(
match
[
1
])
{
...
@@ -844,8 +823,13 @@
...
@@ -844,8 +823,13 @@
this
.
scrollDown
();
this
.
scrollDown
();
break
;
break
;
default
:
default
:
// TODO see why muc is flagged as unresolved variable
this
.
last_msgid
=
xmppchat
.
connection
.
muc
.
groupchat
(
this
.
model
.
get
(
'
jid
'
),
body
);
this
.
last_msgid
=
xmppchat
.
connection
.
muc
.
groupchat
(
this
.
model
.
get
(
'
jid
'
),
body
);
this
.
model
.
messages
.
create
({
fullname
:
'
me
'
,
sender
:
'
me
'
,
time
:
(
new
Date
()).
toLocaleTimeString
().
substring
(
0
,
5
),
message
:
body
});
break
;
break
;
}
}
},
},
...
@@ -872,7 +856,6 @@
...
@@ -872,7 +856,6 @@
'
</div>
'
),
'
</div>
'
),
initialize
:
function
()
{
initialize
:
function
()
{
// TODO see why muc is flagged as unresolved variable
xmppchat
.
connection
.
muc
.
join
(
xmppchat
.
connection
.
muc
.
join
(
this
.
model
.
get
(
'
jid
'
),
this
.
model
.
get
(
'
jid
'
),
this
.
model
.
get
(
'
nick
'
),
this
.
model
.
get
(
'
nick
'
),
...
@@ -881,6 +864,7 @@
...
@@ -881,6 +864,7 @@
$
.
proxy
(
this
.
onChatRoomRoster
,
this
));
$
.
proxy
(
this
.
onChatRoomRoster
,
this
));
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
showMessage
,
this
);
this
.
model
.
on
(
'
destroy
'
,
function
(
model
,
response
,
options
)
{
this
.
model
.
on
(
'
destroy
'
,
function
(
model
,
response
,
options
)
{
this
.
$el
.
hide
(
'
fast
'
);
this
.
$el
.
hide
(
'
fast
'
);
xmppchat
.
connection
.
muc
.
leave
(
xmppchat
.
connection
.
muc
.
leave
(
...
@@ -890,9 +874,8 @@
...
@@ -890,9 +874,8 @@
undefined
);
undefined
);
},
},
this
);
this
);
this
.
$el
.
appendTo
(
xmppchat
.
chatboxesview
.
$el
);
this
.
$el
.
appendTo
(
xmppchat
.
chatboxesview
.
$el
);
this
.
render
().
show
();
this
.
render
().
show
()
.
model
.
messages
.
fetch
({
add
:
true
})
;
},
},
onLeave
:
function
()
{
onLeave
:
function
()
{
...
...
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