2024-08-31 22:29:32 +00:00
|
|
|
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) {
|
2024-09-01 10:03:52 +00:00
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
console.log("Tried to leave chat" + ID);
|
|
|
|
activatePopupWindowById("chat-renunciation-win");
|
2024-08-14 22:07:59 +00:00
|
|
|
};
|
2024-08-11 12:17:53 +00:00
|
|
|
|
2024-08-31 22:29:32 +00:00
|
|
|
return box;
|
2024-08-14 22:07:59 +00:00
|
|
|
}
|
2024-08-05 11:42:32 +00:00
|
|
|
|
2024-09-01 10:03:52 +00:00
|
|
|
function configureChatCreationInterface(){
|
|
|
|
document.getElementById("chat-creation-win-yes").onclick = function (ev) {
|
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
deactivateActivePopup();
|
|
|
|
// todo: create chat, send request
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementById("chat-creation-win-no").onclick = function (ev) {
|
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
deactivateActivePopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("CL-bacbe").onclick = function (ev){
|
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
activatePopupWindowById("chat-creation-win");
|
|
|
|
console.log("Tried to show chat creation window");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureChatRenunciationInterfaceWinPart(){
|
|
|
|
document.getElementById("chat-renunciation-win-yes").onclick = function (ev){
|
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
deactivateActivePopup();
|
|
|
|
// todo: actually leave chat
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("chat-renunciation-win-no").onclick = function(ev) {
|
|
|
|
if (ev.button !== 0)
|
|
|
|
return;
|
|
|
|
deactivateActivePopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-31 22:29:32 +00:00
|
|
|
window.onload = function () {
|
|
|
|
console.log("Loading complete");
|
|
|
|
LocalHistoryId = initial_chatListUpdResp.HistoryId;
|
2024-08-05 11:42:32 +00:00
|
|
|
|
2024-08-31 22:29:32 +00:00
|
|
|
console.log(initial_chatListUpdResp);
|
2024-08-05 11:42:32 +00:00
|
|
|
|
2024-08-31 22:29:32 +00:00
|
|
|
let literalChatList = document.getElementById("CL-dblec");
|
2024-08-05 11:42:32 +00:00
|
|
|
|
2024-08-31 22:29: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);
|
2024-08-14 22:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-01 10:03:52 +00:00
|
|
|
configureChatCreationInterface();
|
|
|
|
configureChatRenunciationInterfaceWinPart();
|
2024-08-31 22:29:32 +00:00
|
|
|
};
|