Render user actions separately

This commit is contained in:
Pavel Djundik 2016-01-23 16:39:54 +02:00
parent 97bb284078
commit bb98be475a
13 changed files with 111 additions and 55 deletions

View file

@ -603,11 +603,6 @@ button {
#chat .msg:last-child .text { #chat .msg:last-child .text {
padding-bottom: 10px; padding-bottom: 10px;
} }
#chat .msg .type {
color: #ccc;
display: none;
font-style: normal;
}
#chat .msg .inline-channel { #chat .msg .inline-channel {
cursor: pointer; cursor: pointer;
} }
@ -641,7 +636,6 @@ button {
} }
#chat.no-colors .from button, #chat.no-colors .from button,
#chat.no-colors .sidebar button { #chat.no-colors .sidebar button {
color: #84ce88 !important;
color: #50a656 !important; color: #50a656 !important;
} }
#chat .text { #chat .text {
@ -657,16 +651,6 @@ button {
#chat .self .text { #chat .self .text {
color: #999; color: #999;
} }
#chat .join .type,
#chat .part .type,
#chat .mode .type,
#chat .nick .type,
#chat .kick .type,
#chat .quit .type,
#chat .quit .type,
#chat .topic .type {
display: inline;
}
#chat .error, #chat .error,
#chat .error .from, #chat .error .from,
#chat .highlight, #chat .highlight,
@ -681,19 +665,55 @@ button {
#chat.hide-quit .quit { #chat.hide-quit .quit {
display: none !important; display: none !important;
} }
#chat .notice .type { #chat .join .from:before {
display: none; font-family: FontAwesome;
content: "\f090";
color: #2ECC40;
} }
#chat .action, #chat .kick .from:before {
#chat .chan .action .user { font-family: FontAwesome;
color: #f39c12 !important; content: "\f05e";
color: #FF4136;
} }
#chat .action .user:before { #chat .part .from:before,
content: "* "; #chat .quit .from:before {
font-family: FontAwesome;
content: "\f08b";
color: #FF4136;
} }
#chat .action .user:after { #chat .topic .from:before {
content: ""; font-family: FontAwesome;
content: "\f0a1";
color: #2ECC40;
} }
#chat .mode .from:before {
font-family: FontAwesome;
content: "\f05a";
color: #2ECC40;
}
#chat .nick .from:before {
font-family: FontAwesome;
content: "\f007";
color: #2ECC40;
}
#chat .action .text,
#chat .action .user {
color: #F39C12;
}
#chat .action .from:before {
font-family: FontAwesome;
content: "\f005";
color: #F39C12;
}
#chat .notice .time,
#chat .notice .text,
#chat .chan .notice .user {
color: #0074D9 !important;
}
#chat .notice .user:before {
content: "Notice: ";
}
#chat .toggle-button { #chat .toggle-button {
background: #f5f5f5; background: #f5f5f5;
border-radius: 2px; border-radius: 2px;

View file

@ -185,14 +185,40 @@ $(function() {
}); });
function buildChatMessage(data) { function buildChatMessage(data) {
var type = data.msg.type;
var target = "#chan-" + data.chan; var target = "#chan-" + data.chan;
if (data.msg.type === "error") { if (type === "error") {
target = "#chan-" + chat.find(".active").data("id"); target = "#chan-" + chat.find(".active").data("id");
} }
var chan = chat.find(target); var chan = chat.find(target);
var from = data.msg.from; var from = data.msg.from;
if ([
"join",
"mode",
"kick",
"nick",
"part",
"quit",
"topic",
"action",
].indexOf(type) !== -1) {
switch (type) {
case "join": data.msg.formattedAction = "has joined the channel"; break;
case "mode": data.msg.formattedAction = "sets mode"; break;
case "kick": data.msg.formattedAction = "has kicked"; break;
case "nick": data.msg.formattedAction = "is now known as"; break;
case "part": data.msg.formattedAction = "has left the channel"; break;
case "quit": data.msg.formattedAction = "has quit"; break;
case "topic": data.msg.formattedAction = "has changed the topic to:"; break;
default: data.msg.formattedAction = "";
}
var action = $(render("msg_action", data.msg));
return action;
}
var msg = $(render("msg", data.msg)); var msg = $(render("msg", data.msg));
var text = msg.find(".text"); var text = msg.find(".text");
@ -220,15 +246,12 @@ $(function() {
} }
}); });
if (chan.hasClass("channel")) { if ((type === "message" || type === "action") && chan.hasClass("channel")) {
var type = data.msg.type; var nicks = chan.find(".users").data("nicks");
if (type === "message" || type === "action") { if (nicks) {
var nicks = chan.find(".users").data("nicks"); var find = nicks.indexOf(from);
if (nicks) { if (find !== -1 && typeof move === "function") {
var find = nicks.indexOf(from); move(nicks, find, 0);
if (find !== -1 && typeof move === "function") {
move(nicks, find, 0);
}
} }
} }
} }

View file

@ -76,7 +76,6 @@ a:hover, #chat a:hover {
line-height: 30px; line-height: 30px;
} }
.chan:first-child.activeat .msg .type,
#sidebar .chan:first-child { #sidebar .chan:first-child {
color: #00FF0E; color: #00FF0E;
} }
@ -85,7 +84,6 @@ a:hover, #chat a:hover {
#sidebar .chan, #sidebar .chan,
#sidebar .sign-out, #sidebar .sign-out,
#chat .time, #chat .time,
#chat .msg .type,
#chat .count:before, #chat .count:before,
#sidebar .empty { #sidebar .empty {
color: #666; color: #666;

View file

@ -164,21 +164,16 @@ QUIT #d0907d
} }
#chat .msg.quit .time, #chat .msg.quit .time,
#chat .msg.quit .from button, #chat .msg.quit .from button {
#chat .msg.quit .type {
color: #d0907d !important; color: #d0907d !important;
} }
#chat .msg.topic { #chat .msg.topic {
color: #fefefe; color: #fefefe;
} }
#chat .msg .type {
margin-right: 0.5em;
}
#chat .msg.join .time, #chat .msg.join .time,
#chat .msg.join .from button, #chat .msg.join .from button {
#chat .msg.join .type {
color: #84ce88 !important; color: #84ce88 !important;
} }
/* Embeds */ /* Embeds */

View file

@ -179,21 +179,16 @@ body {
} }
#chat .msg.quit .time, #chat .msg.quit .time,
#chat .msg.quit .from button, #chat .msg.quit .from button {
#chat .msg.quit .type {
color: #bc6c9c !important; color: #bc6c9c !important;
} }
#chat .msg.topic { #chat .msg.topic {
color: #dcdccc; color: #dcdccc;
} }
#chat .msg .type {
margin-right: 0.5em;
}
#chat .msg.join .time, #chat .msg.join .time,
#chat .msg.join .from button, #chat .msg.join .from button {
#chat .msg.join .type {
color: #8cd0d3 !important; color: #8cd0d3 !important;
} }
/* Embeds */ /* Embeds */

View file

@ -8,7 +8,6 @@
{{/if}} {{/if}}
</span> </span>
<span class="text"> <span class="text">
<em class="type">{{type}}</em>
{{#equal type "toggle"}} {{#equal type "toggle"}}
<div class="force-newline"> <div class="force-newline">
<button id="toggle-{{id}}" class="toggle-button">···</button> <button id="toggle-{{id}}" class="toggle-button">···</button>

View file

@ -0,0 +1,11 @@
<div class="msg {{type}} {{#if self}}self{{/if}}">
<span class="time">
{{tz time}}
</span>
<span class="from"></span>
<span class="text">
<a href="#" class="user">{{mode}}{{from}}</a>
{{formattedAction}}
{{{parse text}}}
</span>
</div>

View file

@ -25,6 +25,7 @@ module.exports = function(network, chan, cmd, args) {
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.ACTION, type: Msg.Type.ACTION,
mode: chan.getMode(irc.me),
from: irc.me, from: irc.me,
text: text text: text
}); });

View file

@ -27,12 +27,15 @@ module.exports = function(irc, network) {
if (data.nick.toLowerCase() === irc.me.toLowerCase()) { if (data.nick.toLowerCase() === irc.me.toLowerCase()) {
self = true; self = true;
} }
var reason = data.message || "";
if (reason.length > 0) {
reason = " (" + reason + ")";
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.KICK, type: Msg.Type.KICK,
mode: mode, mode: mode,
from: from, from: from,
text: data.client, text: data.client + reason,
self: self self: self
}); });
chan.messages.push(msg); chan.messages.push(msg);

View file

@ -21,7 +21,7 @@ module.exports = function(irc, network) {
type: Msg.Type.MODE, type: Msg.Type.MODE,
mode: chan.getMode(from), mode: chan.getMode(from),
from: from, from: from,
text: data.mode + " " + data.client, text: data.mode + " " + (data.client || ""),
self: self self: self
}); });
chan.messages.push(msg); chan.messages.push(msg);

View file

@ -20,6 +20,7 @@ module.exports = function(irc, network) {
} }
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.NOTICE, type: Msg.Type.NOTICE,
mode: chan.getMode(from),
from: from, from: from,
text: data.message text: data.message
}); });

View file

@ -22,9 +22,14 @@ module.exports = function(irc, network) {
chan: chan.id, chan: chan.id,
users: chan.users users: chan.users
}); });
var reason = data.message || "";
if (reason.length > 0) {
reason = "(" + reason + ")";
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.PART, type: Msg.Type.PART,
mode: chan.getMode(from), mode: chan.getMode(from),
text: reason,
from: from from: from
}); });
chan.messages.push(msg); chan.messages.push(msg);

View file

@ -15,9 +15,14 @@ module.exports = function(irc, network) {
chan: chan.id, chan: chan.id,
users: chan.users users: chan.users
}); });
var reason = data.message || "";
if (reason.length > 0) {
reason = "(" + reason + ")";
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.QUIT, type: Msg.Type.QUIT,
mode: chan.getMode(from), mode: chan.getMode(from),
text: reason,
from: from from: from
}); });
chan.messages.push(msg); chan.messages.push(msg);