Commit e8976dc4 authored by JC Brand's avatar JC Brand

More UI improvements.

Don't show encrypted messages when we don't have an encrypted session set up on
our side (show error message instead).
parent f0204dd5
...@@ -171,7 +171,10 @@ ul.participant-list li.moderator { ...@@ -171,7 +171,10 @@ ul.participant-list li.moderator {
} }
.chat-info { .chat-info {
color:#666666; color: #666666;
}
.chat-error {
color: #8f2831;
} }
.chat-message-room, .chat-message-room,
......
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
'url': this.get('url'), 'url': this.get('url'),
'image_type': this.get('image_type'), 'image_type': this.get('image_type'),
'image': this.get('image'), 'image': this.get('image'),
'otr_status': 'unencrypted' 'otr_status': UNENCRYPTED
}); });
} }
}, },
...@@ -397,12 +397,17 @@ ...@@ -397,12 +397,17 @@
if (this.otr) { if (this.otr) {
this.otr.receiveMsg(text); this.otr.receiveMsg(text);
} else { } else {
var match = text.match(/^\?OTR(.*\?)/); if (text.match(/^\?OTR(.*\?)/)) {
if (match) {
// They want to initiate OTR // They want to initiate OTR
if (!this.otr) { if (!this.otr) {
this.trigger('buddyStartsOTR'); this.trigger('buddyStartsOTR');
} }
} else if (text.match(/^\?OTR\:/)) {
this.trigger(
'showHelpMessages',
[__("You were sent an encrypted message, but you don't have encryption set up.")],
'error'
);
} else { } else {
// Normal unencrypted message. // Normal unencrypted message.
this.createMessage(message); this.createMessage(message);
...@@ -462,10 +467,17 @@ ...@@ -462,10 +467,17 @@
'<span class="icon-unlocked"></span>'+ '<span class="icon-unlocked"></span>'+
'{[ } ]}' + '{[ } ]}' +
'<ul>'+ '<ul>'+
'<li><a class="start-otr" href="#">Start private conversation</a></li>'+ '{[ if (otr_status === "'+UNENCRYPTED+'") { ]}' +
'<li><a class="end-otr" href="#">End private conversation</a></li>'+ '<li><a class="start-otr" href="#">'+__('Start encrypted conversation')+'</a></li>'+
'<li><a class="auth-otr" href="#">Authenticate buddy</a></li>'+ '{[ } ]}' +
'<li><a href="http://www.cypherpunks.ca/otr/help/3.2.0/levels.php" target="_blank">What\'s this?</a></li>'+ '{[ if (otr_status !== "'+UNENCRYPTED+'") { ]}' +
'<li><a class="start-otr" href="#">'+__('Refresh encrypted conversation')+'</a></li>'+
'<li><a class="end-otr" href="#">'+__('End encrypted conversation')+'</a></li>'+
'{[ } ]}' +
'{[ if (otr_status === "'+UNVERIFIED+'") { ]}' +
'<li><a class="auth-otr" href="#">'+__('Verify buddy')+'</a></li>'+
'{[ } ]}' +
'<li><a href="http://www.cypherpunks.ca/otr/help/3.2.0/levels.php" target="_blank">'+__("What\'s this?")+'</a></li>'+
'</ul>'+ '</ul>'+
'</li>'), '</li>'),
...@@ -491,6 +503,7 @@ ...@@ -491,6 +503,7 @@
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('buddyStartsOTR', this.buddyStartsOTR, this); this.model.on('buddyStartsOTR', this.buddyStartsOTR, this);
this.model.on('showHelpMessages', this.showHelpMessages, this);
this.model.on('sendMessageStanza', this.sendMessageStanza, this); this.model.on('sendMessageStanza', this.sendMessageStanza, this);
this.model.on('showSentOTRMessage', function (text) { this.model.on('showSentOTRMessage', function (text) {
this.showOTRMessage(text, 'me'); this.showOTRMessage(text, 'me');
...@@ -565,11 +578,11 @@ ...@@ -565,11 +578,11 @@
this.scrollDown(); this.scrollDown();
}, },
showHelpMessages: function (msgs) { showHelpMessages: function (msgs, type) {
var $chat_content = this.$el.find('.chat-content'), i, var $chat_content = this.$el.find('.chat-content'), i,
msgs_length = msgs.length; msgs_length = msgs.length;
for (i=0; i<msgs_length; i++) { for (i=0; i<msgs_length; i++) {
$chat_content.append($('<div class="chat-info">'+msgs[i]+'</div>')); $chat_content.append($('<div class="chat-'+(type||'info')+'">'+msgs[i]+'</div>'));
} }
this.scrollDown(); this.scrollDown();
}, },
......
...@@ -200,8 +200,8 @@ ...@@ -200,8 +200,8 @@
<p></p> <p></p>
</div> </div>
<div class="chat-content"> <div class="chat-content">
<div class="chat-info"><strong>/help</strong>:Show this menu</div> <div class="chat-info"><strong>/help</strong>:This is an info message</div>
<div class="chat-info"><strong>/me</strong>:Write in the third person</div> <div class="chat-error">This is an error message</div>
<div class="chat-message"> <div class="chat-message">
<span class="chat-message-me">09:35 me:&nbsp;</span> <span class="chat-message-me">09:35 me:&nbsp;</span>
<span class="chat-message-content">Hello world</span> <span class="chat-message-content">Hello world</span>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment