Use jQuery for parsing, isolate user commands, remove /clear
This commit is contained in:
parent
f1c40aa8de
commit
3890aaad6b
@ -185,19 +185,18 @@ $(function() {
|
|||||||
resetInputHeight(input.get(0));
|
resetInputHeight(input.get(0));
|
||||||
|
|
||||||
if (text.indexOf("/") === 0) {
|
if (text.indexOf("/") === 0) {
|
||||||
const separatorPos = text.indexOf(" ");
|
const args = text.substr(1).split(" ");
|
||||||
const cmd = text.substring(1, separatorPos > 1 ? separatorPos : text.length);
|
const cmd = args.shift().toLowerCase();
|
||||||
const parameters = separatorPos > text.indexOf(cmd) ? text.substring(text.indexOf(cmd) + cmd.length + 1, text.length) : "";
|
if (typeof utils.inputCommands[cmd] === "function") {
|
||||||
if (typeof utils[cmd] === "function") {
|
|
||||||
if (cmd === "join") {
|
if (cmd === "join") {
|
||||||
const channel = parameters.split(" ")[0];
|
const channel = args.shift();
|
||||||
if (channel !== "") {
|
if (channel !== "") {
|
||||||
if (utils[cmd](channel)) {
|
if (utils.inputCommands[cmd](channel)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (utils[cmd]()) {
|
if (utils.inputCommands[cmd]()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,8 @@ var serverHash = -1;
|
|||||||
var lastMessageId = -1;
|
var lastMessageId = -1;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
inputCommands: { collapse, expand, join },
|
||||||
findCurrentNetworkChan,
|
findCurrentNetworkChan,
|
||||||
clear,
|
|
||||||
collapse,
|
|
||||||
expand,
|
|
||||||
join,
|
|
||||||
serverHash,
|
serverHash,
|
||||||
lastMessageId,
|
lastMessageId,
|
||||||
confirmExit,
|
confirmExit,
|
||||||
@ -47,13 +44,6 @@ function forceFocus() {
|
|||||||
input.trigger("click").focus();
|
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() {
|
function collapse() {
|
||||||
$(".chan.active .toggle-button.opened").click();
|
$(".chan.active .toggle-button.opened").click();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user