Allow calling /part from queries

This commit is contained in:
Mattias Erming 2014-04-06 22:53:07 +02:00
parent 57f4071f27
commit 087ae21137
2 changed files with 25 additions and 11 deletions

View File

@ -175,18 +175,26 @@ $(function() {
input.val(""); input.val("");
socket.emit("input", { socket.emit("input", {
id: input.data("target"), id: input.data("target"),
text: text text: text,
}); });
}); });
chat.on("focus", "input[type=text]", function() { chat.on("click", ".close", function() {
$(this).closest(".window").find(".messages").scrollToBottom(); var id = parseInt($(this).closest(".window").attr("id").replace("window-", ""));
socket.emit("input", {
id: id,
text: "/part",
});
}); });
chat.on("click", ".user", function(e) { chat.on("click", ".user", function(e) {
e.preventDefault(); e.preventDefault();
}); });
chat.on("focus", "input[type=text]", function() {
$(this).closest(".window").find(".messages").scrollToBottom();
});
var highest = 1; var highest = 1;
$.fn.bringToTop = function() { $.fn.bringToTop = function() {
return this.css('z-index', highest++) return this.css('z-index', highest++)

View File

@ -130,13 +130,21 @@ function input(json) {
break; break;
case "join": case "join":
case "part":
case "nick": case "nick":
if (client && args[1]) { if (client && args[1]) {
client[cmd].apply(client, args.slice(1)); client[cmd].apply(client, args.slice(1));
} }
break; break;
case "leave":
case "part":
if (channel.get("type") == "query") {
network.get("channels").remove(channel);
} else if (client) {
client.part(channel.get("name"));
}
break;
case "topic": case "topic":
var chan = channel.get("name"); var chan = channel.get("name");
if (client) { if (client) {
@ -205,12 +213,10 @@ function event(event, data) {
var chan = channels.findWhere({name: data[0].channel}); var chan = channels.findWhere({name: data[0].channel});
var users = chan.get("users"); var users = chan.get("users");
if (data[0].client == this.get("client").me) { if (data[0].client != this.get("client").me) {
users.reset(); users.remove(users.findWhere({name: data[0].client}));
} else { } else {
users.remove( users.reset();
users.findWhere({name: data[0].client})
);
} }
chan.addMessage({ chan.addMessage({