Added boolean flag if message was sent from "me"

Your own messages now have a different color, and the possibility of
changing colors etc in css of all things sent by yourself
This commit is contained in:
Fredrik Pettersen 2014-09-14 19:06:56 +02:00
parent 4d1aa174a1
commit fabbb43e18
9 changed files with 45 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@ -25,11 +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
}
fetchImage(image, function(name) {
var msg = new Msg({
type: Msg.Type.IMAGE,
from: data.from,
text: "thumbs/" + name
text: "thumbs/" + name,
from_me = from_me
});
chan.messages.push(msg);
client.emit("msg", {

View File

@ -17,6 +17,10 @@ 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();
@ -26,7 +30,8 @@ module.exports = function(irc, network) {
});
var msg = new Msg({
from: data.nick,
type: Msg.Type.JOIN
type: Msg.Type.JOIN,
from_me: from_me
});
chan.messages.push(msg);
client.emit("msg", {

View File

@ -17,10 +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 msg = new Msg({
type: Msg.Type.KICK,
from: data.nick,
text: data.client
text: data.client,
from_me: from_me
});
chan.messages.push(msg);
client.emit("msg", {

View File

@ -30,10 +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 msg = new Msg({
type: type || Msg.Type.MESSAGE,
from: data.from,
text: text
text: text,
from_me: from_me
});
chan.messages.push(msg);
client.emit("msg", {

View File

@ -13,10 +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 msg = new Msg({
type: Msg.Type.MODE,
from: nick,
text: data.mode + " " + data.client,
from_me: from_me
});
chan.messages.push(msg);
client.emit("msg", {

View File

@ -9,10 +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 msg = new Msg({
type: Msg.Type.TOPIC,
from: from,
text: data.topic,
from_me: from_me,
});
chan.messages.push(msg);
client.emit("msg", {