diff --git a/client/js/lounge.js b/client/js/lounge.js index 2ffa9f6d..b04471b3 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -185,19 +185,18 @@ $(function() { resetInputHeight(input.get(0)); if (text.indexOf("/") === 0) { - const separatorPos = text.indexOf(" "); - const cmd = text.substring(1, separatorPos > 1 ? separatorPos : text.length); - const parameters = separatorPos > text.indexOf(cmd) ? text.substring(text.indexOf(cmd) + cmd.length + 1, text.length) : ""; - if (typeof utils[cmd] === "function") { + const args = text.substr(1).split(" "); + const cmd = args.shift().toLowerCase(); + if (typeof utils.inputCommands[cmd] === "function") { if (cmd === "join") { - const channel = parameters.split(" ")[0]; + const channel = args.shift(); if (channel !== "") { - if (utils[cmd](channel)) { + if (utils.inputCommands[cmd](channel)) { return; } } } else { - if (utils[cmd]()) { + if (utils.inputCommands[cmd]()) { return; } } diff --git a/client/js/utils.js b/client/js/utils.js index 2eae9a29..b916dfc3 100644 --- a/client/js/utils.js +++ b/client/js/utils.js @@ -8,11 +8,8 @@ var serverHash = -1; var lastMessageId = -1; module.exports = { + inputCommands: { collapse, expand, join }, findCurrentNetworkChan, - clear, - collapse, - expand, - join, serverHash, lastMessageId, confirmExit, @@ -47,13 +44,6 @@ function forceFocus() { input.trigger("click").focus(); } -function clear() { - chat.find(".active") - .find(".show-more").addClass("show").end() - .find(".messages .msg, .date-marker-container").remove(); - return true; -} - function collapse() { $(".chan.active .toggle-button.opened").click(); return true;