fix url bugs and improve account switcher

This commit is contained in:
MathMan05 2024-08-11 15:16:49 -05:00
parent 0fe2966ad1
commit 5148e1b77b
19 changed files with 186 additions and 175 deletions

View file

@ -26,36 +26,27 @@ thisuser.initwebsocket().then(_ => {
const userinfo = document.getElementById("userinfo");
const userdock = document.getElementById("userdock");
userinfo.addEventListener("click", function (event) {
const table = document.createElement("table");
const table = document.createElement("div");
for (const thing of Object.values(users.users)) {
const specialuser = thing;
console.log(specialuser.pfpsrc);
const tr = document.createElement("tr");
const td = document.createElement("td");
const userinfo = document.createElement("table");
userinfo.classList.add("switchtable");
const row = document.createElement("tr");
userinfo.append(row);
const pfpcell = document.createElement("td");
row.append(pfpcell);
const userinfo = document.createElement("div");
userinfo.classList.add("flexltr", "switchtable");
const pfp = document.createElement("img");
pfpcell.append(pfp);
const usertd = document.createElement("td");
row.append(usertd);
userinfo.append(pfp);
const user = document.createElement("div");
usertd.append(user);
userinfo.append(user);
user.append(specialuser.username);
user.append(document.createElement("br"));
const span = document.createElement("span");
span.textContent = specialuser.serverurls.wellknown.hostname;
span.textContent = specialuser.serverurls.wellknown.replace("https://", "").replace("http://", "");
user.append(span);
user.classList.add("userinfo");
span.classList.add("serverURL");
pfp.src = specialuser.pfpsrc;
pfp.classList.add("pfp");
td.append(userinfo);
tr.append(td);
table.append(tr);
tr.addEventListener("click", _ => {
table.append(userinfo);
userinfo.addEventListener("click", _ => {
thisuser.unload();
document.getElementById("loading").classList.remove("doneloading");
document.getElementById("loading").classList.add("loading");
@ -72,14 +63,13 @@ thisuser.initwebsocket().then(_ => {
});
}
{
const tr = document.createElement("tr");
const td = document.createElement("td");
tr.append(td);
const td = document.createElement("div");
td.classList.add("switchtable");
td.append("Switch accounts ⇌");
td.addEventListener("click", _ => {
window.location.href = "/login.html";
});
table.append(tr);
table.append(td);
}
table.classList.add("accountSwitcher");
if (Contextmenu.currentmenu != "") {
@ -87,7 +77,7 @@ thisuser.initwebsocket().then(_ => {
}
Contextmenu.currentmenu = table;
console.log(table);
userdock.before(table);
document.body.append(table);
event.stopImmediatePropagation();
});
}