Permalink
Browse files

Cleanup/reformat message parsing a bit.

  • Loading branch information...
1 parent 3b4b4ff commit 89e0d78e325e958c792e160708dd2248bb34ce02 @akavlie akavlie committed Jan 29, 2012
Showing with 16 additions and 10 deletions.
  1. +14 −8 assets/js/models.js
  2. +2 −2 views/templates.jade
View
@@ -14,17 +14,23 @@ var Message = Backbone.Model.extend({
parse: function(text) {
var nick = this.get('sender') || this.collection.channel.get('name');
- // TODO: add explicit HTML escape before sending to ich.message.
- // Want to add <br> to motd.
var output;
- //This handles whether to output a message or an action
- if(text.substr(1,6) === 'ACTION') {
- output = ich.action({user: nick, content: this.get('raw').substr(8), rendered_time: this._formatDate(Date.now())}, true);
+ // This handles whether to output a message or an action
+ if (text.substr(1, 6) === 'ACTION') {
+ output = ich.action({
+ user: nick,
+ content: this.get('raw').substr(8),
+ renderedTime: this._formatDate(Date.now())
+ }, true);
} else {
- output = ich.message({user: nick, content: this.get('raw'), rendered_time: this._formatDate(Date.now())}, true);
- //This renders the motd the way it looks
- if(this.get('type') === 'motd'){
+ output = ich.message({
+ user: nick,
+ content: this.get('raw'),
+ renderedTime: this._formatDate(Date.now())
+ }, true);
+ // Change rendering for motd
+ if (this.get('type') === 'motd') {
output = output.replace('<span>', '<span><pre>');
output = output.replace('</span>', '</pre></span>');
}
View
@@ -94,12 +94,12 @@ script(id="action", type="text/html")
b * {{user}}&nbsp;
span {{content}}
.chat_time
- span {{rendered_time}}
+ span {{renderedTime}}
script(id="message", type="text/html")
.chat_name
b {{user}}
.chat_message
span {{content}}
.chat_time
- span {{rendered_time}}
+ span {{renderedTime}}

0 comments on commit 89e0d78

Please sign in to comment.