Show filtered list of commands available with the currently input text

This commit is contained in:
Debanjum Singh Solanky
2023-08-27 15:20:34 -07:00
parent 74605f6159
commit 75c1016ec0

View File

@@ -168,12 +168,15 @@
function onChatInput() { function onChatInput() {
let chatInput = document.getElementById("chat-input"); let chatInput = document.getElementById("chat-input");
if (chatInput.value === "/") { if (chatInput.value.startsWith("/") && chatInput.value.split(" ").length === 1) {
let chatTooltip = document.getElementById("chat-tooltip"); let chatTooltip = document.getElementById("chat-tooltip");
chatTooltip.style.display = "block"; chatTooltip.style.display = "block";
let helpText = "<div>"; let helpText = "<div>";
const command = chatInput.value.split(" ")[0].substring(1);
for (let key in chatOptions) { for (let key in chatOptions) {
helpText += "<b>/" + key + "</b>: " + chatOptions[key] + "<br>"; if (!!!command || key.startsWith(command)) {
helpText += "<b>/" + key + "</b>: " + chatOptions[key] + "<br>";
}
} }
chatTooltip.innerHTML = helpText; chatTooltip.innerHTML = helpText;
} else if (chatInput.value.startsWith("/")) { } else if (chatInput.value.startsWith("/")) {
@@ -514,6 +517,7 @@
div#chat-tooltip { div#chat-tooltip {
text-align: left; text-align: left;
font-size: medium;
} }
@keyframes gradient { @keyframes gradient {