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;
}
#chat .whois .from:before {
font-family: FontAwesome;
content: "\f007";
color: #2ecc40;
}
#chat .nick .from:before {
font-family: FontAwesome;
content: "\f007";

View File

@ -210,7 +210,6 @@ $(function() {
}
var chan = chat.find(target);
var from = data.msg.from;
var msg;
if ([
@ -223,6 +222,7 @@ $(function() {
"quit",
"topic",
"action",
"whois",
].indexOf(type) !== -1) {
data.msg.template = "actions/" + type;
msg = $(render("msg_action", data.msg));
@ -238,7 +238,7 @@ $(function() {
if ((type === "message" || type === "action") && chan.hasClass("channel")) {
var nicks = chan.find(".users").data("nicks");
if (nicks) {
var find = nicks.indexOf(from);
var find = nicks.indexOf(data.msg.from);
if (find !== -1 && typeof move === "function") {
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
});
}
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({
type: Msg.Type.WHOIS,
from: data.nickname,
text: key + " " + data[k]
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
});
}
var msg = new Msg({
type: Msg.Type.WHOIS,
whois: data
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
});
});
};