Make whois a client template

This commit is contained in:
Pavel Djundik 2016-03-07 17:10:46 +02:00
parent c4d628db49
commit a61973a156
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 = {
hostname: "from",
realname: "is",
channels: "on",
server: "using"
};
for (var k in data) {
var key = prefix[k];
if (!key || data[k].toString() === "") {
continue;
}
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.WHOIS, type: Msg.Type.WHOIS,
from: data.nickname, whois: data
text: key + " " + data[k]
}); });
chan.messages.push(msg); chan.messages.push(msg);
client.emit("msg", { client.emit("msg", {
chan: chan.id, chan: chan.id,
msg: msg msg: msg
}); });
}
}); });
}; };