Remove input history

This commit is contained in:
Pavel Djundik 2018-07-08 22:20:49 +03:00 committed by Pavel Djundik
parent 1e09ccdb90
commit e0e48925b5
2 changed files with 0 additions and 57 deletions

View File

@ -30,8 +30,6 @@ $("#form").on("submit", () => {
} }
}); });
const chat = $("#chat");
const sidebar = $("#sidebar");
const emojiSearchTerms = Object.keys(emojiMap); const emojiSearchTerms = Object.keys(emojiMap);
const emojiStrategy = { const emojiStrategy = {
id: "emoji", id: "emoji",

View File

@ -97,61 +97,6 @@ Mousetrap.bind([
const inputTrap = Mousetrap(input.get(0)); const inputTrap = Mousetrap(input.get(0));
function enableHistory() {
const history = [""];
let position = 0;
input.on("input", () => {
position = 0;
});
inputTrap.bind("enter", function(e) {
position = 0;
const input = $(e.target);
if (input.data("autocompleting")) {
return false;
}
const text = input.val();
if (text.length === 0) {
return false;
}
// Store new message in history if last message isn't already equal
if (history[1] !== text) {
history.splice(1, 0, text);
}
return false;
});
inputTrap.bind(["up", "down"], function(e, key) {
if (e.target.selectionStart !== e.target.selectionEnd || input.data("autocompleting")) {
return;
}
if (position === 0) {
history[position] = input.val();
}
if (key === "up") {
if (position < history.length - 1) {
position++;
}
} else if (position > 0) {
position--;
}
input.val(history[position]);
return false;
});
}
enableHistory();
const colorsHotkeys = { const colorsHotkeys = {
k: "\x03", k: "\x03",
b: "\x02", b: "\x02",