export function addMessage(classname: string, message: string) { let chatbox = document.getElementById("chatbox"); let should_scroll = chatbox!.scrollTop == chatbox!.scrollHeight - chatbox!.offsetHeight; let p = document.createElement("p"); p.innerText = message; p.classList.add("message"); p.classList.add(classname); if (chatbox.children.length > 128) { chatbox.children[0]!.remove(); } chatbox!.appendChild(p); if (should_scroll) { chatbox!.scrollTop = chatbox!.scrollHeight; } } /* I'm sorry for this code lmao */ export function chatViewToggle() { let el = document.getElementById("chat-minimax"); let chat_modal = document.getElementById("chat"); console.log("clickl"); let to_hide = [ document.getElementById("chatbox"), document.getElementById("chatentry"), ]; if (el.hasAttribute("minimised")) { chat_modal.style.width = ""; chat_modal.style.paddingRight = ""; for (let element of to_hide) { element.style.display = ""; } } else { chat_modal.style.width = "unset"; chat_modal.style.paddingRight = "4em"; /* magical number. don't touch >:( */ for (let element of to_hide) { element.style.display = "none"; } } /* inject that live svg hell yeah */ if (el.hasAttribute("minimised")) { el.removeAttribute("minimised"); el.innerHTML = ``; } else { el.setAttribute("minimised", ""); el.innerHTML = ``; } }