Merge pull request #161 from xPaw/whois-tpl

Make whois a client template
This commit is contained in:
Jérémie Astori 2016-03-09 00:16:47 -05:00
commit c8664b7cfa
4 changed files with 43 additions and 24 deletions

View File

@ -840,6 +840,12 @@ button,
color: #2ecc40; color: #2ecc40;
} }
#chat .whois .from:before {
font-family: FontAwesome;
content: "\f007";
color: #2ecc40;
}
#chat .nick .from:before { #chat .nick .from:before {
font-family: FontAwesome; font-family: FontAwesome;
content: "\f007"; content: "\f007";

View File

@ -210,7 +210,6 @@ $(function() {
} }
var chan = chat.find(target); var chan = chat.find(target);
var from = data.msg.from;
var msg; var msg;
if ([ if ([
@ -223,6 +222,7 @@ $(function() {
"quit", "quit",
"topic", "topic",
"action", "action",
"whois",
].indexOf(type) !== -1) { ].indexOf(type) !== -1) {
data.msg.template = "actions/" + type; data.msg.template = "actions/" + type;
msg = $(render("msg_action", data.msg)); msg = $(render("msg_action", data.msg));
@ -238,7 +238,7 @@ $(function() {
if ((type === "message" || type === "action") && chan.hasClass("channel")) { if ((type === "message" || type === "action") && chan.hasClass("channel")) {
var nicks = chan.find(".users").data("nicks"); var nicks = chan.find(".users").data("nicks");
if (nicks) { if (nicks) {
var find = nicks.indexOf(from); var find = nicks.indexOf(data.msg.from);
if (find !== -1 && typeof move === "function") { if (find !== -1 && typeof move === "function") {
move(nicks, find, 0); move(nicks, find, 0);
} }

View File

@ -0,0 +1,26 @@
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a>
<i class="hostmask">({{whois.username}}@{{whois.hostname}})</i>:
<b>{{whois.realname}}</b>
</div>
{{#if whois.channels}}
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a>
is on the following channels:
{{#each whois.channels}}
{{{parse this}}}
{{/each}}
</div>
{{/if}}
{{#if whois.server}}
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a>
is connected to {{whois.server}}
</div>
{{/if}}
{{#if whois.away}}
<div>
<a href="#" class="user" data-name="{{whois.nickname}}">{{whois.nickname}}</a>
is away <i>({{whois.away}})</i>
</div>
{{/if}}

View File

@ -20,27 +20,14 @@ module.exports = function(irc, network) {
chan: chan chan: chan
}); });
} }
var prefix = { var msg = new Msg({
hostname: "from", type: Msg.Type.WHOIS,
realname: "is", whois: data
channels: "on", });
server: "using" chan.messages.push(msg);
}; client.emit("msg", {
for (var k in data) { chan: chan.id,
var key = prefix[k]; msg: msg
if (!key || data[k].toString() === "") { });
continue;
}
var msg = new Msg({
type: Msg.Type.WHOIS,
from: data.nickname,
text: key + " " + data[k]
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
});
}
}); });
}; };