diff --git a/client/js/chat.js b/client/js/chat.js index 1331b2c0..d36fd821 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -36,7 +36,7 @@ $(function() { } function handleEvent(event, json) { - var data = json.data; + var data = [].concat(json.data); switch (event) { case "network": @@ -68,7 +68,7 @@ $(function() { break; case "channel": - var id = data.id; + var id = data[0].id; if (json.action == "remove") { $("#channel-" + id + ", #window-" + id).remove(); var highest = 0; @@ -89,13 +89,13 @@ $(function() { sidebar.find(".channel").removeClass("active"); $("#network-" + json.target).append( - render("#channels", {channels: [data]}) + render("#channels", {channels: data}) ).find(".channel") .last() .addClass("active"); chat.append( - render("#windows", {windows: [data]}) + render("#windows", {windows: data}) ).find(".window") .last() .find("input") @@ -123,7 +123,7 @@ $(function() { target = target.parent().find(".active"); } - var msg = $(render("#messages", {messages: [data]})); + var msg = $(render("#messages", {messages: data})); target = target.find(".messages"); target.append(msg); diff --git a/lib/server.js b/lib/server.js index db759a25..14338123 100644 --- a/lib/server.js +++ b/lib/server.js @@ -70,7 +70,7 @@ function connect(params) { client: client, }, {silent: true}); - networks.trigger("network", networks); + networks.trigger("network", {data: networks}); client.nick(params.nick); client.user(params.nick, params.realname); @@ -208,7 +208,7 @@ function input(json) { case "quit": case "disconnect": networks.remove(network); - networks.trigger("network", networks); + networks.trigger("network", {data: networks}); break; }