Merge pull request #147 from Fumler/test

Added boolean flag if message was sent from "me"
This commit is contained in:
Mattias Erming 2014-09-14 20:09:14 +02:00
commit 3cf870bc06
9 changed files with 45 additions and 5 deletions

View File

@ -454,6 +454,10 @@ button {
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
#chat .from_me .text {
color: #999;
}
#chat .msg { #chat .msg {
display: table-row; display: table-row;
word-wrap: break-word; word-wrap: break-word;
@ -478,6 +482,7 @@ button {
display: table-cell; display: table-cell;
padding: 3px 0; padding: 3px 0;
vertical-align: top; vertical-align: top;
} }
#chat .time { #chat .time {
color: #d0dbe2; color: #d0dbe2;

View File

@ -1,5 +1,9 @@
{{#each messages}} {{#each messages}}
{{#if from_me}}
<div class="msg {{type}} from_me">
{{else}}
<div class="msg {{type}}"> <div class="msg {{type}}">
{{/if}}
<span class="time"> <span class="time">
{{tz time}} {{tz time}}
</span> </span>

View File

@ -25,6 +25,7 @@ function Msg(attr) {
from: "", from: "",
text: "", text: "",
time: moment().utc().format("HH:mm:ss"), time: moment().utc().format("HH:mm:ss"),
type: Msg.Type.MESSAGE type: Msg.Type.MESSAGE,
from_me: false,
}, attr)); }, attr));
} }

View File

@ -25,11 +25,16 @@ module.exports = function(irc, network) {
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
return; return;
} }
var from_me = false
if (data.from.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
fetchImage(image, function(name) { fetchImage(image, function(name) {
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.IMAGE, type: Msg.Type.IMAGE,
from: data.from, from: data.from,
text: "thumbs/" + name text: "thumbs/" + name,
from_me = from_me
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {

View File

@ -17,6 +17,10 @@ module.exports = function(irc, network) {
chan: chan chan: chan
}); });
} }
var from_me = false
if (data.from.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
var users = chan.users; var users = chan.users;
users.push(new User({name: data.nick})); users.push(new User({name: data.nick}));
chan.sortUsers(); chan.sortUsers();
@ -26,7 +30,8 @@ module.exports = function(irc, network) {
}); });
var msg = new Msg({ var msg = new Msg({
from: data.nick, from: data.nick,
type: Msg.Type.JOIN type: Msg.Type.JOIN,
from_me: from_me
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {

View File

@ -17,10 +17,15 @@ module.exports = function(irc, network) {
chan: chan.id, chan: chan.id,
users: chan.users users: chan.users
}); });
var from_me = false
if (data.nick.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.KICK, type: Msg.Type.KICK,
from: data.nick, from: data.nick,
text: data.client text: data.client,
from_me: from_me
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {

View File

@ -30,10 +30,15 @@ module.exports = function(irc, network) {
text.split(" ").forEach(function(w) { text.split(" ").forEach(function(w) {
if (w.indexOf(irc.me) === 0) type += " highlight"; if (w.indexOf(irc.me) === 0) type += " highlight";
}); });
var from_me = false
if (data.from.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
var msg = new Msg({ var msg = new Msg({
type: type || Msg.Type.MESSAGE, type: type || Msg.Type.MESSAGE,
from: data.from, from: data.from,
text: text text: text,
from_me: from_me
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {

View File

@ -13,10 +13,15 @@ module.exports = function(irc, network) {
if (nick.indexOf(".") !== -1) { if (nick.indexOf(".") !== -1) {
nick = data.target; nick = data.target;
} }
var from_me = false
if (nick.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.MODE, type: Msg.Type.MODE,
from: nick, from: nick,
text: data.mode + " " + data.client, text: data.mode + " " + data.client,
from_me: from_me
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {

View File

@ -9,10 +9,15 @@ module.exports = function(irc, network) {
return; return;
} }
var from = data.nick || chan.name; var from = data.nick || chan.name;
var from_me = false
if (data.nick.toLowerCase() == irc.me.toLowerCase() ) {
from_me = true
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.TOPIC, type: Msg.Type.TOPIC,
from: from, from: from,
text: data.topic, text: data.topic,
from_me: from_me,
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {