From 66785be20056ba63d71c51d0e7de72ff9f2a37c4 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Sun, 14 Sep 2014 11:49:42 -0700 Subject: [PATCH] Fix bugs --- client/css/style.css | 8 +++----- client/js/shout.templates.js | 15 ++++++++++----- client/templates/msg.tpl | 6 +----- src/models/msg.js | 2 +- src/plugins/irc-events/image.js | 8 ++++---- src/plugins/irc-events/join.js | 10 +++++----- src/plugins/irc-events/kick.js | 8 ++++---- src/plugins/irc-events/message.js | 8 ++++---- src/plugins/irc-events/mode.js | 8 ++++---- src/plugins/irc-events/nick.js | 5 ++++- src/plugins/irc-events/topic.js | 8 ++++---- 11 files changed, 44 insertions(+), 42 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 9a0bc389..1ee03698 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -454,10 +454,6 @@ button { height: 100%; width: 100%; } - -#chat .from_me .text { - color: #999; -} #chat .msg { display: table-row; word-wrap: break-word; @@ -482,7 +478,6 @@ button { display: table-cell; padding: 3px 0; vertical-align: top; - } #chat .time { color: #d0dbe2; @@ -510,6 +505,9 @@ button { #chat .text a { word-break: break-all; } +#chat .self .text { + color: #999; +} #chat .join .type, #chat .part .type, #chat .mode .type, diff --git a/client/js/shout.templates.js b/client/js/shout.templates.js index 6b232778..3509a49e 100644 --- a/client/js/shout.templates.js +++ b/client/js/shout.templates.js @@ -54,28 +54,33 @@ templates['chat'] = template({"1":function(depth0,helpers,partials,data) { templates['msg'] = template({"1":function(depth0,helpers,partials,data) { var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "
\n \n " + + " "; + stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.self : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); + if (stack1 != null) { buffer += stack1; } + buffer += "\">\n \n " + escapeExpression(((helpers.tz || (depth0 && depth0.tz) || helperMissing).call(depth0, (depth0 != null ? depth0.time : depth0), {"name":"tz","hash":{},"data":data}))) + "\n \n \n"; - stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.from : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); + stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.from : depth0), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.noop,"data":data}); if (stack1 != null) { buffer += stack1; } buffer += " \n \n " + escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"type","hash":{},"data":data}) : helper))) + "\n"; - stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "image", {"name":"equal","hash":{},"fn":this.program(4, data),"inverse":this.program(6, data),"data":data})); + stack1 = ((helpers.equal || (depth0 && depth0.equal) || helperMissing).call(depth0, (depth0 != null ? depth0.type : depth0), "image", {"name":"equal","hash":{},"fn":this.program(6, data),"inverse":this.program(8, data),"data":data})); if (stack1 != null) { buffer += stack1; } return buffer + " \n
\n"; },"2":function(depth0,helpers,partials,data) { + return "self"; + },"4":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; return " \n"; -},"4":function(depth0,helpers,partials,data) { +},"6":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; return " \n"; -},"6":function(depth0,helpers,partials,data) { +},"8":function(depth0,helpers,partials,data) { var stack1, helperMissing=helpers.helperMissing, buffer = " "; stack1 = ((helpers.uri || (depth0 && depth0.uri) || helperMissing).call(depth0, (depth0 != null ? depth0.text : depth0), {"name":"uri","hash":{},"data":data})); if (stack1 != null) { buffer += stack1; } diff --git a/client/templates/msg.tpl b/client/templates/msg.tpl index ad78480a..3dc90a96 100644 --- a/client/templates/msg.tpl +++ b/client/templates/msg.tpl @@ -1,9 +1,5 @@ {{#each messages}} -{{#if from_me}} -
-{{else}} -
-{{/if}} +
{{tz time}} diff --git a/src/models/msg.js b/src/models/msg.js index b3f65e56..a544316c 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -26,6 +26,6 @@ function Msg(attr) { text: "", time: moment().utc().format("HH:mm:ss"), type: Msg.Type.MESSAGE, - from_me: false, + self: false }, attr)); } diff --git a/src/plugins/irc-events/image.js b/src/plugins/irc-events/image.js index 538c61cb..ce281bf5 100644 --- a/src/plugins/irc-events/image.js +++ b/src/plugins/irc-events/image.js @@ -25,16 +25,16 @@ module.exports = function(irc, network) { if (typeof chan === "undefined") { return; } - var from_me = false - if (data.from.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true + var self = false; + if (data.from.toLowerCase() == irc.me.toLowerCase()) { + self = true; } fetchImage(image, function(name) { var msg = new Msg({ type: Msg.Type.IMAGE, from: data.from, text: "thumbs/" + name, - from_me = from_me + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/join.js b/src/plugins/irc-events/join.js index dfc17f23..0ba09985 100644 --- a/src/plugins/irc-events/join.js +++ b/src/plugins/irc-events/join.js @@ -17,10 +17,6 @@ module.exports = function(irc, network) { chan: chan }); } - var from_me = false - if (data.from.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true - } var users = chan.users; users.push(new User({name: data.nick})); chan.sortUsers(); @@ -28,10 +24,14 @@ module.exports = function(irc, network) { chan: chan.id, users: users }); + var self = false; + if (data.nick.toLowerCase() == irc.me.toLowerCase()) { + self = true; + } var msg = new Msg({ from: data.nick, type: Msg.Type.JOIN, - from_me: from_me + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/kick.js b/src/plugins/irc-events/kick.js index be4da463..0ee6a5e3 100644 --- a/src/plugins/irc-events/kick.js +++ b/src/plugins/irc-events/kick.js @@ -17,15 +17,15 @@ module.exports = function(irc, network) { chan: chan.id, users: chan.users }); - var from_me = false - if (data.nick.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true + var self = false; + if (data.nick.toLowerCase() == irc.me.toLowerCase()) { + self = true; } var msg = new Msg({ type: Msg.Type.KICK, from: data.nick, text: data.client, - from_me: from_me + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 15952fdd..51dceff7 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -30,15 +30,15 @@ module.exports = function(irc, network) { text.split(" ").forEach(function(w) { if (w.indexOf(irc.me) === 0) type += " highlight"; }); - var from_me = false - if (data.from.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true + var self = false; + if (data.from.toLowerCase() == irc.me.toLowerCase()) { + self = true; } var msg = new Msg({ type: type || Msg.Type.MESSAGE, from: data.from, text: text, - from_me: from_me + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/mode.js b/src/plugins/irc-events/mode.js index ee4fb41c..95bf8ea6 100644 --- a/src/plugins/irc-events/mode.js +++ b/src/plugins/irc-events/mode.js @@ -13,15 +13,15 @@ module.exports = function(irc, network) { if (nick.indexOf(".") !== -1) { nick = data.target; } - var from_me = false - if (nick.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true + var self = false; + if (nick.toLowerCase() == irc.me.toLowerCase()) { + self = true; } var msg = new Msg({ type: Msg.Type.MODE, from: nick, text: data.mode + " " + data.client, - from_me: from_me + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/nick.js b/src/plugins/irc-events/nick.js index 1d8d80e4..7311f92c 100644 --- a/src/plugins/irc-events/nick.js +++ b/src/plugins/irc-events/nick.js @@ -3,6 +3,7 @@ var Msg = require("../../models/msg"); module.exports = function(irc, network) { var client = this; + var self = false; irc.on("nick", function(data) { if (data["new"] == irc.me) { var lobby = network.channels[0]; @@ -14,6 +15,7 @@ module.exports = function(irc, network) { chan: lobby.id, msg: msg }); + self = true; } network.channels.forEach(function(chan) { var user = _.findWhere(chan.users, {name: data.nick}); @@ -29,7 +31,8 @@ module.exports = function(irc, network) { var msg = new Msg({ type: Msg.Type.NICK, from: data.nick, - text: data["new"] + text: data["new"], + self: self }); chan.messages.push(msg); client.emit("msg", { diff --git a/src/plugins/irc-events/topic.js b/src/plugins/irc-events/topic.js index afe12676..e13bfaa9 100644 --- a/src/plugins/irc-events/topic.js +++ b/src/plugins/irc-events/topic.js @@ -9,15 +9,15 @@ module.exports = function(irc, network) { return; } var from = data.nick || chan.name; - var from_me = false - if (data.nick.toLowerCase() == irc.me.toLowerCase() ) { - from_me = true + var self = false; + if (from.toLowerCase() == irc.me.toLowerCase()) { + self = true; } var msg = new Msg({ type: Msg.Type.TOPIC, from: from, text: data.topic, - from_me: from_me, + self: self }); chan.messages.push(msg); client.emit("msg", {