Created
September 25, 2022 17:24
-
-
Save percybolmer/97ee86a62aceddad8e1696843b656e80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ChangeChatRoomEvent is used to switch chatroom | |
* */ | |
class ChangeChatRoomEvent { | |
constructor(name) { | |
this.name = name; | |
} | |
} | |
/** | |
* changeChatRoom will update the value of selectedchat | |
* and also notify the server that it changes chatroom | |
* */ | |
function changeChatRoom() { | |
// Change Header to reflect the Changed chatroom | |
var newchat = document.getElementById("chatroom"); | |
if (newchat != null && newchat.value != selectedchat) { | |
selectedchat = newchat.value; | |
header = document.getElementById("chat-header").innerHTML = "Currently in chat: " + selectedchat; | |
let changeEvent = new ChangeChatRoomEvent(selectedchat); | |
sendEvent("change_room", changeEvent); | |
textarea = document.getElementById("chatmessages"); | |
textarea.innerHTML = `You changed room into: ${selectedchat}`; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment