diff --git a/client/css/style.css b/client/css/style.css index fbb66d06..c52a4f75 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -59,22 +59,25 @@ h2 { padding: 0 10px; width: 100%; } -#chat .channel, -#chat .network { +#chat .window { background: #fff; height: 100%; position: absolute; width: 100%; } -#chat .network .close { - display: none; -} +#chat .network .close, #chat .network .users { display: none; } #chat .network .messages { right: 0; } +#chat .query .users { + display: none; +} +#chat .query .messages { + right: 0; +} #chat .title { border-bottom: 1px solid #ccc; height: 43px; diff --git a/client/index.html b/client/index.html index 025d4cdf..c7f20631 100644 --- a/client/index.html +++ b/client/index.html @@ -18,7 +18,7 @@ {{#networks}}
{{#channels}} - + {{name}} @@ -50,9 +50,9 @@ @@ -60,7 +60,7 @@ {{#messages}}
{{time}} - {{mode}}{{user}} + {{mode}}{{user}} {{text}}
{{/messages}} diff --git a/client/js/chat.js b/client/js/chat.js index a664a0ef..0a5072af 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -65,33 +65,6 @@ $(function() { } } - chat.on("submit", "form", function() { - var input = $(this).find(".input"); - var text = input.val(); - if (text != "") { - input.val(""); - socket.emit("input", { - id: input.data("target"), - text: text - }); - } - }); - - chat.on("click", ".close", function() { - var btn = $(this); - btn.prop("disabled", true); - socket.emit("input", { - id: btn.closest(".window").data("id"), - text: "/leave" - }); - }); - - chat.on("append", ".window", function() { - var id = $(this).data("id"); - var badge = sidebar.find(".channel[data-id='" + id + "']:not(.active) .badge"); - badge.html((parseInt(badge.html()) + 1) || "1"); - }); - sidebar.on("click", ".channel", function(e) { e.preventDefault(); sidebar.find(".active").removeClass("active"); @@ -104,6 +77,56 @@ $(function() { chat.find(".window[data-id='" + id + "']") .bringToTop(); }); + + chat.on("submit", "form", function() { + var input = $(this).find(".input"); + var text = input.val(); + if (text != "") { + input.val(""); + socket.emit("input", { + id: input.data("target"), + text: text + }); + } + }); + + chat.on("click", ".close", function() { + var btn = $(this); + btn.prop("disabled", true); + socket.emit("input", { + id: btn.closest(".window").data("id"), + text: "/LEAVE" + }); + }); + + chat.on("append", ".window", function() { + var id = $(this).data("id"); + var badge = sidebar.find(".channel[data-id='" + id + "']:not(.active) .badge"); + badge.html((parseInt(badge.html()) + 1) || "1"); + }); + + chat.on("click", ".user", function(e) { + e.preventDefault(); + }); + + chat.on("dblclick", ".user", function() { + var user = $(this); + var id = user.closest(".window").data("id"); + var name = user.attr("href"); + + var channel = sidebar + .find(".channel[data-id='" + id + "']") + .siblings(".channel[data-name='" + name + "']"); + if (channel.size() != 0) { + channel.trigger("click"); + return; + } + + socket.emit("input", { + id: id, + text: "/QUERY " + name + }); + }); }); (function($) { diff --git a/lib/models.js b/lib/models.js index 49830d57..13174516 100644 --- a/lib/models.js +++ b/lib/models.js @@ -13,6 +13,7 @@ var id = 1; models.User = Backbone.Model.extend({ defaults: { + mode: "", name: "" } }); diff --git a/lib/server.js b/lib/server.js index 8bb9953c..0bce1190 100644 --- a/lib/server.js +++ b/lib/server.js @@ -138,22 +138,6 @@ function handleInput(input) { ); break; - case "QUERY": - var irc = network.irc; - if (!argv[1] || typeof irc === "undefined") { - break; - } - - var channels = network.get("channels"); - if (argv[1].charAt(0) != "#" && !channels.findWhere({name: argv[1]})) { - channels.add( - new models.Channel({ - name: argv[1] - }) - ); - } - break; - case "TOPIC": var irc = network.irc; if (typeof irc === "undefined") { @@ -192,6 +176,7 @@ function handleInput(input) { } break; + case "QUERY": case "WHOIS": var irc = network.irc; if (typeof irc !== "undefined") { @@ -275,6 +260,7 @@ function handleEvent(argv) { if (typeof channel == "undefined") { channel = channels.add( new models.Channel({ + type: "query", name: target }) ); @@ -551,6 +537,7 @@ function handleEvent(argv) { if (typeof channel == "undefined") { channel = channels.add( new models.Channel({ + type: "query", name: argv.args[1] }) );