Merge pull request 'retain usernames and selected agent' (#18) from yellows111/MSAgent-Chat:master into master

Reviewed-on: #18
This commit is contained in:
MDMCK10 2024-07-17 13:51:20 -04:00
commit 4478befa8d

View file

@ -65,6 +65,8 @@ logonWindow.show();
let loggingIn = false;
elements.logonForm.addEventListener('submit', (e) => {
e.preventDefault();
localStorage.setItem("MSAUser", elements.logonUsername.value);
localStorage.setItem("MSAgent", elements.agentSelect.value);
connectToRoom();
});
@ -95,12 +97,18 @@ async function connectToRoom() {
document.addEventListener('DOMContentLoaded', async () => {
await agentInit();
elements.logonUsername.value = localStorage.getItem("MSAUser") || "";
for (const agent of await Room.getAgents()) {
let option = document.createElement('option');
option.innerText = agent.friendlyName;
option.value = agent.filename;
elements.agentSelect.appendChild(option);
}
elements.agentSelect.value = localStorage.getItem("MSAgent") || "";
if(elements.agentSelect.value === "") {
// HTMLSelectElement is like this, don't complain.
elements.agentSelect.value = "";
}
let motd = await Room.getMotd();
elements.motdContainer.innerHTML = motd.html;
let ver = localStorage.getItem('msagent-chat-motd-version');