diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-10-15 21:01:22 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-10-15 21:01:22 -0400 |
commit | 6c4896d3aa9d618f024b54c8d51f25ca3f625744 (patch) | |
tree | a70ceb0b6d477141e7791b21cb6eaa79316529df /scripts/gui/chat.js | |
parent | fcf01353f94b11b8ca6db8ead14d2ec89a0275f4 (diff) |
[Themes] Theme selection and small fixes
Diffstat (limited to 'scripts/gui/chat.js')
-rw-r--r-- | scripts/gui/chat.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/scripts/gui/chat.js b/scripts/gui/chat.js index fa4b88d..8a5db9f 100644 --- a/scripts/gui/chat.js +++ b/scripts/gui/chat.js @@ -1,11 +1,17 @@ 'use strict'; class Chat { - constructor(e) + constructor(e, soc) { this.chats = []; this.root = e; + this.socket = soc; e.getElementsByClassName("toggle-chat")[0].onclick = this.toggle.bind(this); + let cin = e.getElementsByClassName("chat-input")[0]; + this.chatInput = cin.children[0]; + + cin.children[0].addEventListener("keydown", this.checkEnter.bind(this)); + cin.children[0].addEventListener("click", this.sendMessage.bind(this)); } getChannel (name) @@ -50,7 +56,7 @@ class Chat { b.onclick = this.switchChannel.bind(this, name); - b.innerText = name[0].toUpperCase() + name.slice(1).toLowerCase(); + b.innerText = name; d.className = "chat-text"; @@ -92,6 +98,21 @@ class Chat { }); } + checkEnter(e) + { + if(e.key === "Enter") { + this.sendMessage(); + } + } + + sendMessage () + { + var str = this.chatInput.value; + this.chatInput.value = ""; + this.socket.send("chat", str); + + } + recieveMessage (channel, msg) { let c = this.getChannel(channel); |