Merge pull request #94 from xPaw/action-templates
Move actions to templates
This commit is contained in:
commit
31d938440b
@ -201,18 +201,7 @@ $(function() {
|
||||
"topic",
|
||||
"action",
|
||||
].indexOf(type) !== -1) {
|
||||
switch (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 = "";
|
||||
}
|
||||
|
||||
data.msg.template = "actions/" + type;
|
||||
msg = $(render("msg_action", data.msg));
|
||||
} else {
|
||||
msg = $(render("msg", data.msg));
|
||||
|
2
client/views/actions/action.tpl
Normal file
2
client/views/actions/action.tpl
Normal file
@ -0,0 +1,2 @@
|
||||
<a href="#" class="user">{{mode}}{{from}}</a>
|
||||
{{{parse text}}}
|
5
client/views/actions/invite.tpl
Normal file
5
client/views/actions/invite.tpl
Normal file
@ -0,0 +1,5 @@
|
||||
<a href="#" class="user">{{from}}</a>
|
||||
invited
|
||||
<a href="#" class="user">{{target}}</a>
|
||||
to
|
||||
{{{parse text}}}
|
3
client/views/actions/join.tpl
Normal file
3
client/views/actions/join.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
<a href="#" class="user">{{mode}}{{from}}</a>
|
||||
<i class="hostmask">({{hostmask}})</i>
|
||||
has joined the channel
|
6
client/views/actions/kick.tpl
Normal file
6
client/views/actions/kick.tpl
Normal 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}}
|
3
client/views/actions/mode.tpl
Normal file
3
client/views/actions/mode.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
<a href="#" class="user">{{mode}}{{from}}</a>
|
||||
sets mode
|
||||
{{{parse text}}}
|
3
client/views/actions/nick.tpl
Normal file
3
client/views/actions/nick.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
<a href="#" class="user">{{mode}}{{from}}</a>
|
||||
is now known as
|
||||
<a href="#" class="user">{{mode}}{{text}}</a>
|
6
client/views/actions/part.tpl
Normal file
6
client/views/actions/part.tpl
Normal 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}}
|
6
client/views/actions/quit.tpl
Normal file
6
client/views/actions/quit.tpl
Normal 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}}
|
8
client/views/actions/topic.tpl
Normal file
8
client/views/actions/topic.tpl
Normal 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>
|
@ -4,8 +4,6 @@
|
||||
</span>
|
||||
<span class="from"></span>
|
||||
<span class="text">
|
||||
<a href="#" class="user">{{mode}}{{from}}</a>
|
||||
{{formattedAction}}
|
||||
{{{parse text}}}
|
||||
{{partial template}}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -29,6 +29,7 @@ module.exports = function(irc, network) {
|
||||
}
|
||||
var msg = new Msg({
|
||||
from: data.nick,
|
||||
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
|
||||
type: Msg.Type.JOIN,
|
||||
self: self
|
||||
});
|
||||
|
@ -26,15 +26,12 @@ module.exports = function(irc, network) {
|
||||
if (data.nick.toLowerCase() === irc.me.toLowerCase()) {
|
||||
self = true;
|
||||
}
|
||||
var reason = data.message || "";
|
||||
if (reason.length > 0) {
|
||||
reason = " (" + reason + ")";
|
||||
}
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.KICK,
|
||||
mode: mode,
|
||||
from: from,
|
||||
text: data.client + reason,
|
||||
target: data.client,
|
||||
text: data.message || "",
|
||||
self: self
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
@ -21,14 +21,11 @@ module.exports = function(irc, network) {
|
||||
client.emit("users", {
|
||||
chan: chan.id
|
||||
});
|
||||
var reason = data.message || "";
|
||||
if (reason.length > 0) {
|
||||
reason = "(" + reason + ")";
|
||||
}
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.PART,
|
||||
mode: chan.getMode(from),
|
||||
text: reason,
|
||||
text: data.message || "",
|
||||
hostmask:data.hostmask.username + "@" + data.hostmask.hostname,
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
@ -14,14 +14,11 @@ module.exports = function(irc, network) {
|
||||
client.emit("users", {
|
||||
chan: chan.id
|
||||
});
|
||||
var reason = data.message || "";
|
||||
if (reason.length > 0) {
|
||||
reason = "(" + reason + ")";
|
||||
}
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.QUIT,
|
||||
mode: chan.getMode(from),
|
||||
text: reason,
|
||||
text: data.message || "",
|
||||
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
@ -16,6 +16,7 @@ module.exports = function(irc, network) {
|
||||
mode: chan.getMode(from),
|
||||
from: from,
|
||||
text: topic,
|
||||
isSetByChan: from === chan.name,
|
||||
self: (from.toLowerCase() === irc.me.toLowerCase())
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
Loading…
Reference in New Issue
Block a user