Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move actions to templates #94

Merged
merged 1 commit into from Feb 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 1 addition & 12 deletions client/js/lounge.js
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions client/views/actions/action.tpl
@@ -0,0 +1,2 @@
<a href="#" class="user">{{mode}}{{from}}</a>
{{{parse text}}}
5 changes: 5 additions & 0 deletions client/views/actions/invite.tpl
@@ -0,0 +1,5 @@
<a href="#" class="user">{{from}}</a>
invited
<a href="#" class="user">{{target}}</a>
to
{{{parse text}}}
3 changes: 3 additions & 0 deletions client/views/actions/join.tpl
@@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
<i class="hostmask">({{hostmask}})</i>
has joined the channel
6 changes: 6 additions & 0 deletions client/views/actions/kick.tpl
@@ -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 changes: 3 additions & 0 deletions client/views/actions/mode.tpl
@@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
sets mode
{{{parse text}}}
3 changes: 3 additions & 0 deletions client/views/actions/nick.tpl
@@ -0,0 +1,3 @@
<a href="#" class="user">{{mode}}{{from}}</a>
is now known as
<a href="#" class="user">{{mode}}{{text}}</a>
6 changes: 6 additions & 0 deletions client/views/actions/part.tpl
@@ -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 changes: 6 additions & 0 deletions client/views/actions/quit.tpl
@@ -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 changes: 8 additions & 0 deletions client/views/actions/topic.tpl
@@ -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 changes: 1 addition & 3 deletions client/views/msg_action.tpl
Expand Up @@ -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>
1 change: 1 addition & 0 deletions src/plugins/irc-events/join.js
Expand Up @@ -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
});
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/irc-events/kick.js
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/irc-events/part.js
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/irc-events/quit.js
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/irc-events/topic.js
Expand Up @@ -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);
Expand Down