From 047f8b0302649c190dbf9fdc7ebf165f9613d330 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 13 Jun 2014 13:22:03 +0200 Subject: [PATCH] Show errors in current window --- client/css/style.css | 3 +++ client/js/chat.js | 8 +++----- lib/server.js | 13 +++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 6619d182..1fb8ba97 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -265,6 +265,7 @@ button { color: #bbb; } #chat .action .type, +#chat .error .type, #chat .highlight .type, #chat .motd .type, #chat .normal .type, @@ -278,6 +279,8 @@ button { #chat .action .user:before { content: '* '; } +#chat .error, +#chat .error .from a, #chat .highlight, #chat .highlight .from a { color: #f00; diff --git a/client/js/chat.js b/client/js/chat.js index ba29c14f..5dbaa5a6 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -77,7 +77,8 @@ $(function() { case "messages": case "msg": - var target = $("#window-" + data.id).find(".messages"); + var target = (data.id ? $("#window-" + data.id) : $("#chat .active")) + .find(".messages"); var html = render( "messages", {messages: toArray(data.msg)} @@ -122,10 +123,7 @@ $(function() { case "users": var target = $("#window-" + data.id); - var json = { - name: target.find("h1").html(), - users: data.users - }; + var json = {name: target.find("h1").html(), users: data.users}; target.find(".meta") .replaceWith(render("meta", json)) .end(); diff --git a/lib/server.js b/lib/server.js index 43194f18..11f46749 100644 --- a/lib/server.js +++ b/lib/server.js @@ -652,15 +652,12 @@ function event(e, data) { case "whois": if (!data) { - var chan = channels[0]; - var msg = new Msg({ - type: "error", - text: "No such nick/channel.", - }); - chan.messages.push(msg); sockets.emit("msg", { - id: chan.id, - msg: msg, + msg: new Msg({ + type: "error", + from: "-!-", + text: "No such nick/channel.", + }), }); } else { var chan = _.findWhere(channels, {name: data.nickname});