From 3244ec91e8a8fd6c9e2a79d743f56c2003c3074f Mon Sep 17 00:00:00 2001 From: realies Date: Tue, 3 Oct 2017 23:59:19 +0300 Subject: [PATCH] Remove unused var, satisfy linter rules, simplify calls --- client/js/lounge.js | 13 ++----------- client/js/utils.js | 17 +++++++++-------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index b04471b3..24790c6a 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -188,17 +188,8 @@ $(function() { const args = text.substr(1).split(" "); const cmd = args.shift().toLowerCase(); if (typeof utils.inputCommands[cmd] === "function") { - if (cmd === "join") { - const channel = args.shift(); - if (channel !== "") { - if (utils.inputCommands[cmd](channel)) { - return; - } - } - } else { - if (utils.inputCommands[cmd]()) { - return; - } + if (utils.inputCommands[cmd](args)) { + return; } } } diff --git a/client/js/utils.js b/client/js/utils.js index b916dfc3..04974c13 100644 --- a/client/js/utils.js +++ b/client/js/utils.js @@ -1,14 +1,13 @@ "use strict"; const $ = require("jquery"); -const chat = $("#chat"); const input = $("#input"); var serverHash = -1; var lastMessageId = -1; module.exports = { - inputCommands: { collapse, expand, join }, + inputCommands: {collapse, expand, join}, findCurrentNetworkChan, serverHash, lastMessageId, @@ -54,12 +53,14 @@ function expand() { return true; } -function join(channel) { - var chan = findCurrentNetworkChan(channel); - - if (chan.length) { - chan.click(); - return true; +function join(args) { + const channel = args[0]; + if (channel) { + const chan = findCurrentNetworkChan(channel); + if (chan.length) { + chan.click(); + return true; + } } }