Use jQuery for parsing, isolate user commands, remove /clear

This commit is contained in:
realies 2017-10-03 23:29:19 +03:00
parent f1c40aa8de
commit 3890aaad6b
2 changed files with 7 additions and 18 deletions

View file

@ -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;
}
}

View file

@ -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;