Move actions to templates

This commit is contained in:
Pavel Djundik 2016-02-23 18:22:41 +02:00
parent 1e8ca51d47
commit 2c8c84aec5
16 changed files with 52 additions and 30 deletions

View File

@ -201,18 +201,7 @@ $(function() {
"topic", "topic",
"action", "action",
].indexOf(type) !== -1) { ].indexOf(type) !== -1) {
switch (type) { data.msg.template = "actions/" + type;
case "invite": data.msg.formattedAction = "invited " + data.msg.target + " to"; break;
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 = "";
}
msg = $(render("msg_action", data.msg)); msg = $(render("msg_action", data.msg));
} else { } else {
msg = $(render("msg", data.msg)); msg = $(render("msg", data.msg));

View File

@ -0,0 +1,2 @@
<a href="#" class="user">{{mode}}{{from}}</a>
{{{parse text}}}

View File

@ -0,0 +1,5 @@
<a href="#" class="user">{{from}}</a>
invited
<a href="#" class="user">{{target}}</a>
to
{{{parse text}}}

View File

@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
<i class="hostmask">({{hostmask}})</i>
has joined the channel

View File

@ -0,0 +1,6 @@
<a href="#" class="user">{{mode}}{{from}}</a>
has kicked
<a href="#" class="user">{{target}}</a>
{{#if text}}
<i class="part-reason">({{{parse text}}})</i>
{{/if}}

View File

@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
sets mode
{{{parse text}}}

View File

@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
is now known as
<a href="#" class="user">{{mode}}{{text}}</a>

View File

@ -0,0 +1,6 @@
<a href="#" class="user">{{mode}}{{from}}</a>
<i class="hostmask">({{hostmask}})</i>
has left the channel
{{#if text}}
<i class="part-reason">({{{parse text}}})</i>
{{/if}}

View File

@ -0,0 +1,6 @@
<a href="#" class="user">{{mode}}{{from}}</a>
<i class="hostmask">({{hostmask}})</i>
has quit
{{#if text}}
<i class="quit-reason">({{{parse text}}})</i>
{{/if}}

View File

@ -0,0 +1,8 @@
{{#if isSetByChan}}
The topic is:
{{else}}
<a href="#" class="user">{{mode}}{{from}}</a>
has changed the topic to:
{{/if}}
<span class="new-topic">{{{parse text}}}</span>

View File

@ -4,8 +4,6 @@
</span> </span>
<span class="from"></span> <span class="from"></span>
<span class="text"> <span class="text">
<a href="#" class="user">{{mode}}{{from}}</a> {{partial template}}
{{formattedAction}}
{{{parse text}}}
</span> </span>
</div> </div>

View File

@ -29,6 +29,7 @@ module.exports = function(irc, network) {
} }
var msg = new Msg({ var msg = new Msg({
from: data.nick, from: data.nick,
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
type: Msg.Type.JOIN, type: Msg.Type.JOIN,
self: self self: self
}); });

View File

@ -26,15 +26,12 @@ 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 + reason, target: data.client,
text: data.message || "",
self: self self: self
}); });
chan.messages.push(msg); chan.messages.push(msg);

View File

@ -21,14 +21,11 @@ module.exports = function(irc, network) {
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id
}); });
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, text: data.message || "",
hostmask:data.hostmask.username + "@" + data.hostmask.hostname,
from: from from: from
}); });
chan.messages.push(msg); chan.messages.push(msg);

View File

@ -14,14 +14,11 @@ module.exports = function(irc, network) {
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id
}); });
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, text: data.message || "",
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
from: from from: from
}); });
chan.messages.push(msg); chan.messages.push(msg);

View File

@ -16,6 +16,7 @@ module.exports = function(irc, network) {
mode: chan.getMode(from), mode: chan.getMode(from),
from: from, from: from,
text: topic, text: topic,
isSetByChan: from === chan.name,
self: (from.toLowerCase() === irc.me.toLowerCase()) self: (from.toLowerCase() === irc.me.toLowerCase())
}); });
chan.messages.push(msg); chan.messages.push(msg);