let LocalHistoryId = 0; let myChats = new Map(); let chatBoxes = new Map(); const roleDeleted = "not-a-member"; function convertStToBox(myMembershipSt){ let chatURI = "/user/" + myMembershipSt.chatNickname; let box = document.createElement("div"); chatBoxes.set(myMembershipSt.chatId, box); box.className = "dynamic-block-list-el CL-my-chat-box"; let inBoxNickname = document.createElement("a"); box.appendChild(inBoxNickname); inBoxNickname.className = "entity-nickname-txt CL-my-chat-box-nickname"; console.log(myMembershipSt); console.log(myMembershipSt.chatNickname); inBoxNickname.innerText = myMembershipSt.chatNickname; inBoxNickname.href = chatURI; let inBoxName = document.createElement("a"); box.appendChild(inBoxName); inBoxName.className = "entity-reg-field-txt CL-my-chat-box-name"; inBoxName.innerText = myMembershipSt.chatName; inBoxName.href = chatURI; let inBoxMyRoleHere = document.createElement("p"); box.appendChild(inBoxMyRoleHere); inBoxMyRoleHere.className = "entity-reg-field-txt CL-my-chat-box-my-role"; inBoxMyRoleHere.innerText = "You are " + myMembershipSt.myRoleHere + " here"; let ID = myMembershipSt.chatId; let inBoxLeaveBtn = document.createElement("img"); box.appendChild(inBoxLeaveBtn); inBoxLeaveBtn.className = "CL-my-chat-box-leave-btn"; inBoxLeaveBtn.src = "/assets/img/delete.svg"; inBoxLeaveBtn.onclick = function (ev) { if (ev.button === 0){ console.log("Tried to leave chat" + ID); } }; return box; } window.onload = function () { console.log("Loading complete"); LocalHistoryId = initial_chatListUpdResp.HistoryId; console.log(initial_chatListUpdResp); let literalChatList = document.getElementById("CL-dblec"); for (let myMembershipSt of initial_chatListUpdResp.myChats){ console.log(myMembershipSt); if (myMembershipSt.myRoleHere !== roleDeleted){ myChats.set(myMembershipSt.chatId, myMembershipSt); let box = convertStToBox(myMembershipSt) chatBoxes.set(myMembershipSt.chatId, box); literalChatList.appendChild(box); } } document.getElementById("CL-bacbe").onclick = function (ev){ if (ev.button === 0){ } }; };