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
6a45eee6
Commit
6a45eee6
authored
Aug 25, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename methods to trying and get some consistency.
parent
044fb84c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
38 deletions
+47
-38
converse.js
converse.js
+47
-38
No files found.
converse.js
View file @
6a45eee6
...
@@ -292,7 +292,7 @@
...
@@ -292,7 +292,7 @@
};
};
this
.
otr
=
new
otr
.
OTR
(
options
);
this
.
otr
=
new
otr
.
OTR
(
options
);
this
.
otr
.
on
(
'
ui
'
,
$
.
proxy
(
function
(
msg
)
{
this
.
otr
.
on
(
'
ui
'
,
$
.
proxy
(
function
(
msg
)
{
this
.
trigger
(
'
OTRMessageReceived
'
,
msg
,
'
them
'
);
this
.
trigger
(
'
OTRMessageReceived
'
,
msg
);
},
this
));
},
this
));
this
.
otr
.
on
(
'
io
'
,
$
.
proxy
(
function
(
msg
)
{
this
.
otr
.
on
(
'
io
'
,
$
.
proxy
(
function
(
msg
)
{
this
.
trigger
(
'
sendMessage
'
,
msg
);
this
.
trigger
(
'
sendMessage
'
,
msg
);
...
@@ -399,13 +399,17 @@
...
@@ -399,13 +399,17 @@
),
),
initialize
:
function
(){
initialize
:
function
(){
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
showMessage
,
this
);
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
hide
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
hide
,
this
);
this
.
model
.
on
(
'
change
'
,
this
.
onChange
,
this
);
this
.
model
.
on
(
'
change
'
,
this
.
onChange
,
this
);
this
.
model
.
on
(
'
sendMessage
'
,
this
.
onMessageSend
,
this
);
this
.
model
.
on
(
'
sendMessage
'
,
this
.
onMessageSend
,
this
);
this
.
model
.
on
(
'
sendOTRMessage
'
,
this
.
showOTRMessage
,
this
);
this
.
model
.
on
(
'
sendOTRMessage
'
,
function
(
text
)
{
this
.
model
.
on
(
'
OTRMessageReceived
'
,
this
.
showOTRMessage
,
this
);
this
.
showOTRMessage
(
text
,
'
me
'
);
},
this
);
this
.
model
.
on
(
'
OTRMessageReceived
'
,
function
(
text
)
{
this
.
showOTRMessage
(
text
,
'
them
'
);
},
this
);
this
.
updateVCard
();
this
.
updateVCard
();
this
.
$el
.
appendTo
(
converse
.
chatboxesview
.
$el
);
this
.
$el
.
appendTo
(
converse
.
chatboxesview
.
$el
);
this
.
render
().
show
().
model
.
messages
.
fetch
({
add
:
true
});
this
.
render
().
show
().
model
.
messages
.
fetch
({
add
:
true
});
...
@@ -414,7 +418,14 @@
...
@@ -414,7 +418,14 @@
}
}
},
},
appendMessage
:
function
(
$el
,
msg_dict
)
{
showStatusNotification
:
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
(
$el
,
msg_dict
)
{
var
this_date
=
converse
.
parseISO8601
(
msg_dict
.
time
),
var
this_date
=
converse
.
parseISO8601
(
msg_dict
.
time
),
text
=
msg_dict
.
message
,
text
=
msg_dict
.
message
,
match
=
text
.
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
),
match
=
text
.
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
),
...
@@ -441,14 +452,9 @@
...
@@ -441,14 +452,9 @@
this
.
scrollDown
();
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
();
},
showOTRMessage
:
function
(
text
,
sender
)
{
showOTRMessage
:
function
(
text
,
sender
)
{
// "Off-the-record" messages are not stored at all, so we don't
// have a backbone converse.Message object to work with.
var
username
=
sender
===
'
me
'
&&
sender
||
this
.
model
.
get
(
'
fullname
'
);
var
username
=
sender
===
'
me
'
&&
sender
||
this
.
model
.
get
(
'
fullname
'
);
var
$el
=
this
.
$el
.
find
(
'
.chat-content
'
);
var
$el
=
this
.
$el
.
find
(
'
.chat-content
'
);
$el
.
find
(
'
div.chat-event
'
).
remove
();
$el
.
find
(
'
div.chat-event
'
).
remove
();
...
@@ -463,7 +469,16 @@
...
@@ -463,7 +469,16 @@
this
.
scrollDown
();
this
.
scrollDown
();
},
},
showMessage
:
function
(
message
)
{
showHelpMessages
:
function
(
msgs
)
{
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
),
i
,
msgs_length
=
msgs
.
length
;
for
(
i
=
0
;
i
<
msgs_length
;
i
++
)
{
$chat_content
.
append
(
$
(
'
<div class="chat-info">
'
+
msgs
[
i
]
+
'
</div>
'
));
}
this
.
scrollDown
();
},
onMessageAdded
:
function
(
message
)
{
var
time
=
message
.
get
(
'
time
'
),
var
time
=
message
.
get
(
'
time
'
),
times
=
this
.
model
.
messages
.
pluck
(
'
time
'
),
times
=
this
.
model
.
messages
.
pluck
(
'
time
'
),
this_date
=
converse
.
parseISO8601
(
time
),
this_date
=
converse
.
parseISO8601
(
time
),
...
@@ -487,10 +502,10 @@
...
@@ -487,10 +502,10 @@
}
}
}
}
if
(
message
.
get
(
'
composing
'
))
{
if
(
message
.
get
(
'
composing
'
))
{
this
.
insert
StatusNotification
(
message
.
get
(
'
fullname
'
)
+
'
'
+
'
is typing
'
);
this
.
show
StatusNotification
(
message
.
get
(
'
fullname
'
)
+
'
'
+
'
is typing
'
);
return
;
return
;
}
else
{
}
else
{
this
.
append
Message
(
$chat_content
,
_
.
clone
(
message
.
attributes
));
this
.
show
Message
(
$chat_content
,
_
.
clone
(
message
.
attributes
));
}
}
if
((
message
.
get
(
'
sender
'
)
!=
'
me
'
)
&&
(
converse
.
windowState
==
'
blur
'
))
{
if
((
message
.
get
(
'
sender
'
)
!=
'
me
'
)
&&
(
converse
.
windowState
==
'
blur
'
))
{
converse
.
incrementMsgCounter
();
converse
.
incrementMsgCounter
();
...
@@ -505,15 +520,6 @@
...
@@ -505,15 +520,6 @@
(
next_date
.
getMonth
()
!=
prev_date
.
getMonth
()));
(
next_date
.
getMonth
()
!=
prev_date
.
getMonth
()));
},
},
addHelpMessages
:
function
(
msgs
)
{
var
$chat_content
=
this
.
$el
.
find
(
'
.chat-content
'
),
i
,
msgs_length
=
msgs
.
length
;
for
(
i
=
0
;
i
<
msgs_length
;
i
++
)
{
$chat_content
.
append
(
$
(
'
<div class="chat-info">
'
+
msgs
[
i
]
+
'
</div>
'
));
}
this
.
scrollDown
();
},
sendMessage
:
function
(
text
)
{
sendMessage
:
function
(
text
)
{
var
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
)\s
*$/
),
msgs
;
var
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
)\s
*$/
),
msgs
;
if
(
match
)
{
if
(
match
)
{
...
@@ -528,7 +534,7 @@
...
@@ -528,7 +534,7 @@
'
<strong>/me</strong>:
'
+
__
(
'
Write in the third person
'
)
+
''
,
'
<strong>/me</strong>:
'
+
__
(
'
Write in the third person
'
)
+
''
,
'
<strong>/clear</strong>:
'
+
__
(
'
Remove messages
'
)
+
''
'
<strong>/clear</strong>:
'
+
__
(
'
Remove messages
'
)
+
''
];
];
this
.
add
HelpMessages
(
msgs
);
this
.
show
HelpMessages
(
msgs
);
return
;
return
;
}
}
else
if
(
match
[
1
]
===
"
otr
"
)
{
else
if
(
match
[
1
]
===
"
otr
"
)
{
...
@@ -537,13 +543,13 @@
...
@@ -537,13 +543,13 @@
__
(
'
Generating private key
'
),
__
(
'
Generating private key
'
),
__
(
'
...this might take a few seconds.
'
)
__
(
'
...this might take a few seconds.
'
)
];
];
this
.
add
HelpMessages
(
msgs
);
this
.
show
HelpMessages
(
msgs
);
setTimeout
(
$
.
proxy
(
function
()
{
setTimeout
(
$
.
proxy
(
function
()
{
var
privKey
=
this
.
model
.
getPrivateKey
();
var
privKey
=
this
.
model
.
getPrivateKey
();
msgs
=
[
msgs
=
[
__
(
'
Private key generated.
'
)
__
(
'
Private key generated.
'
)
];
];
this
.
add
HelpMessages
(
msgs
);
this
.
show
HelpMessages
(
msgs
);
this
.
model
.
initiateOTR
(
privKey
);
this
.
model
.
initiateOTR
(
privKey
);
},
this
));
},
this
));
return
;
return
;
...
@@ -555,7 +561,7 @@
...
@@ -555,7 +561,7 @@
}
}
if
(
this
.
model
.
otr
)
{
if
(
this
.
model
.
otr
)
{
this
.
model
.
otr
.
sendMsg
(
text
);
this
.
model
.
otr
.
sendMsg
(
text
);
this
.
model
.
trigger
(
'
sendOTRMessage
'
,
text
,
'
me
'
);
this
.
model
.
trigger
(
'
sendOTRMessage
'
,
text
);
}
}
else
{
else
{
// We only save unencrypted messages.
// We only save unencrypted messages.
...
@@ -626,11 +632,11 @@
...
@@ -626,11 +632,11 @@
fullname
=
item
.
get
(
'
fullname
'
);
fullname
=
item
.
get
(
'
fullname
'
);
if
(
this
.
$el
.
is
(
'
:visible
'
))
{
if
(
this
.
$el
.
is
(
'
:visible
'
))
{
if
(
chat_status
===
'
offline
'
)
{
if
(
chat_status
===
'
offline
'
)
{
this
.
insert
StatusNotification
(
fullname
+
'
'
+
'
has gone offline
'
);
this
.
show
StatusNotification
(
fullname
+
'
'
+
'
has gone offline
'
);
}
else
if
(
chat_status
===
'
away
'
)
{
}
else
if
(
chat_status
===
'
away
'
)
{
this
.
insert
StatusNotification
(
fullname
+
'
'
+
'
has gone away
'
);
this
.
show
StatusNotification
(
fullname
+
'
'
+
'
has gone away
'
);
}
else
if
((
chat_status
===
'
dnd
'
))
{
}
else
if
((
chat_status
===
'
dnd
'
))
{
this
.
insert
StatusNotification
(
fullname
+
'
'
+
'
is busy
'
);
this
.
show
StatusNotification
(
fullname
+
'
'
+
'
is busy
'
);
}
else
if
(
chat_status
===
'
online
'
)
{
}
else
if
(
chat_status
===
'
online
'
)
{
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
}
}
...
@@ -1204,8 +1210,8 @@
...
@@ -1204,8 +1210,8 @@
});
});
},
},
add
HelpMessages
:
function
(
msgs
)
{
show
HelpMessages
:
function
(
msgs
)
{
// Override
add
HelpMessages in ChatBoxView, for now do nothing.
// Override
show
HelpMessages in ChatBoxView, for now do nothing.
return
;
return
;
},
},
...
@@ -1274,7 +1280,7 @@
...
@@ -1274,7 +1280,7 @@
'
<strong>/ban</strong>:
'
+
__
(
'
Ban user from chatroom
'
)
+
''
,
'
<strong>/ban</strong>:
'
+
__
(
'
Ban user from chatroom
'
)
+
''
,
'
<strong>/clear</strong>:
'
+
__
(
'
Remove messages
'
)
+
''
'
<strong>/clear</strong>:
'
+
__
(
'
Remove messages
'
)
+
''
];
];
this
.
add
HelpMessages
(
msgs
);
this
.
show
HelpMessages
(
msgs
);
break
;
break
;
default
:
default
:
this
.
last_msgid
=
converse
.
connection
.
muc
.
groupchat
(
this
.
model
.
get
(
'
jid
'
),
body
);
this
.
last_msgid
=
converse
.
connection
.
muc
.
groupchat
(
this
.
model
.
get
(
'
jid
'
),
body
);
...
@@ -1338,7 +1344,7 @@
...
@@ -1338,7 +1344,7 @@
initialize
:
function
()
{
initialize
:
function
()
{
this
.
connect
(
null
);
this
.
connect
(
null
);
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
showMessage
,
this
);
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
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
'
);
converse
.
connection
.
muc
.
leave
(
converse
.
connection
.
muc
.
leave
(
...
@@ -1460,7 +1466,7 @@
...
@@ -1460,7 +1466,7 @@
},
},
onErrorConfigSaved
:
function
(
stanza
)
{
onErrorConfigSaved
:
function
(
stanza
)
{
this
.
insert
StatusNotification
(
__
(
"
An error occurred while trying to save the form.
"
));
this
.
show
StatusNotification
(
__
(
"
An error occurred while trying to save the form.
"
));
},
},
cancelConfiguration
:
function
(
ev
)
{
cancelConfiguration
:
function
(
ev
)
{
...
@@ -1709,10 +1715,13 @@
...
@@ -1709,10 +1715,13 @@
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
.
info_template
({
'
message
'
:
__
(
'
Topic set by %1$s to: %2$s
'
,
sender
,
subject
)}));
$chat_content
.
append
(
this
.
info_template
({
'
message
'
:
__
(
'
Topic set by %1$s to: %2$s
'
,
sender
,
subject
)
}));
}
}
if
(
!
body
)
{
return
true
;
}
if
(
!
body
)
{
return
true
;
}
this
.
append
Message
(
$chat_content
,
this
.
show
Message
(
$chat_content
,
{
'
message
'
:
body
,
{
'
message
'
:
body
,
'
sender
'
:
sender
===
this
.
model
.
get
(
'
nick
'
)
&&
'
me
'
||
'
room
'
,
'
sender
'
:
sender
===
this
.
model
.
get
(
'
nick
'
)
&&
'
me
'
||
'
room
'
,
'
fullname
'
:
sender
,
'
fullname
'
:
sender
,
...
...
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