iu9-ca-web-chat/assets/js/list-rooms.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

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);
2024-08-11 12:17:53 +00:00
}
};
2024-08-11 12:17:53 +00:00
return box;
}
2024-08-05 11:42:32 +00:00
window.onload = function () {
console.log("Loading complete");
LocalHistoryId = initial_chatListUpdResp.HistoryId;
2024-08-05 11:42:32 +00:00
console.log(initial_chatListUpdResp);
2024-08-05 11:42:32 +00:00
let literalChatList = document.getElementById("CL-dblec");
2024-08-05 11:42:32 +00:00
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){
2024-08-11 12:17:53 +00:00
}
};
};