From 712bdafd9efccf971282af25163c4a74dfa2e91f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 12 Sep 2017 15:52:16 +0300 Subject: [PATCH] Remove unnecessary end() calls --- client/js/lounge.js | 8 +++++--- client/js/socket-events/auth.js | 10 +++------- client/js/socket-events/network.js | 3 +-- client/js/socket-events/quit.js | 6 +++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 4fececa3..1bbdc968 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -520,23 +520,25 @@ $(function() { e.preventDefault(); var event = "auth"; var form = $(this); - form.find(".btn") - .attr("disabled", true) - .end(); + form.find(".btn").attr("disabled", true); + if (form.closest(".window").attr("id") === "connect") { event = "conn"; } else if (form.closest("div").attr("id") === "change-password") { event = "change-password"; } + var values = {}; $.each(form.serializeArray(), function(i, obj) { if (obj.value !== "") { values[obj.name] = obj.value; } }); + if (values.user) { storage.set("user", values.user); } + socket.emit( event, values ); diff --git a/client/js/socket-events/auth.js b/client/js/socket-events/auth.js index ad3539da..08ce2ebd 100644 --- a/client/js/socket-events/auth.js +++ b/client/js/socket-events/auth.js @@ -34,13 +34,9 @@ socket.on("auth", function(data) { return; } - $("#footer").find(".sign-in") + $("#footer") + .find(".sign-in") .trigger("click", { pushState: false, - }) - .end() - .find(".networks") - .html("") - .next() - .show(); + }); }); diff --git a/client/js/socket-events/network.js b/client/js/socket-events/network.js index 1fb8036f..846a6a34 100644 --- a/client/js/socket-events/network.js +++ b/client/js/socket-events/network.js @@ -14,8 +14,7 @@ socket.on("network", function(data) { $("#connect") .find(".btn") - .prop("disabled", false) - .end(); + .prop("disabled", false); }); socket.on("network_changed", function(data) { diff --git a/client/js/socket-events/quit.js b/client/js/socket-events/quit.js index dcf1b8bd..8caa26bc 100644 --- a/client/js/socket-events/quit.js +++ b/client/js/socket-events/quit.js @@ -6,12 +6,12 @@ const sidebar = $("#sidebar"); socket.on("quit", function(data) { const id = data.network; - sidebar.find("#network-" + id) - .remove() - .end(); + sidebar.find("#network-" + id).remove(); + const chan = sidebar.find(".chan") .eq(0) .trigger("click"); + if (chan.length === 0) { sidebar.find(".empty").show(); }