getProfil Function return html for profil page

This commit is contained in:
NigeParis 2025-12-06 16:33:28 +01:00 committed by apetitco
parent b2867757b6
commit 8f3bedf65a
3 changed files with 26 additions and 7 deletions

View file

@ -1,8 +1,8 @@
@import "tailwindcss"; @import "tailwindcss";
@font-face { /* @font-face {
font-family: "Nimbus Mono L"; font-family: "Nimbus Mono L";
src: url("/fonts/NimbusMonoL.woff2") format("woff2"); src: url("/fonts/NimbusMonoL.woff2") format("woff2");
} } */
@tailwind utilities; @tailwind utilities;

View file

@ -28,12 +28,12 @@
<div id = "div-buddies"> <div id = "div-buddies">
<!-- <p>Alice</p> <!-- <p>Alice</p>
<p>Bob</p> <p>Bob</p>
<p>Charlie</p> --> <p>Charlie</p> -->Marks
</div> </div>
</div> </div>
<div id="profile-modal" class="profilPopup hidden"> <div id="profile-modal" class="profilPopup hidden">
<div class="popUpBox"> <div class="popUpBox">
<p class="text-xl font-bold" id="modal-name"></p> <p class="" id="modal-name"></p>
<button id="close-modal" class="btn-style absolute bottom-32 right-12">Close</button> <button id="close-modal" class="btn-style absolute bottom-32 right-12">Close</button>
</div> </div>
</div> </div>

View file

@ -58,10 +58,20 @@ function addMessage(text: string) {
return ; return ;
}; };
function clearText() {
const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement;
if (!chatWindow) return;
chatWindow.innerHTML = "";
}
function isLoggedIn() { function isLoggedIn() {
return getUser() || null; return getUser() || null;
}; };
function getProfil(user: string): string {
return `Profil: ${user} </br> <button id="popup-b-clear" class="btn-style">Clear Text</button>`
}
async function windowStateHidden() { async function windowStateHidden() {
const socketId = __socket || undefined; const socketId = __socket || undefined;
// let oldName = localStorage.getItem("oldName") ?? undefined; // let oldName = localStorage.getItem("oldName") ?? undefined;
@ -159,8 +169,14 @@ async function listBuddies(buddies: HTMLDivElement, listBuddies: string) {
buddiesElement.addEventListener("dblclick", () => { buddiesElement.addEventListener("dblclick", () => {
console.log("Open profile:", listBuddies); console.log("Open profile:", listBuddies);
openProfilePopup(`Profil: ${listBuddies}`); const profile: string = getProfil(listBuddies);
openProfilePopup(`${profile}`);
setTimeout(() => {
const clearTextBtn = document.querySelector("#popup-b-clear");
clearTextBtn?.addEventListener("click", () => {
clearText();
});
}, 0)
}); });
buddies.appendChild(buddiesElement); buddies.appendChild(buddiesElement);
@ -289,12 +305,15 @@ async function whoami(socket: Socket) {
async function openProfilePopup(profil: string) { async function openProfilePopup(profil: string) {
const modalname = document.getElementById("modal-name") ?? null; const modalname = document.getElementById("modal-name") ?? null;
if (modalname) if (modalname)
modalname.innerHTML = profil; modalname.innerHTML = `${profil}`;
const profilList = document.getElementById("profile-modal") ?? null; const profilList = document.getElementById("profile-modal") ?? null;
if (profilList) if (profilList)
profilList.classList.remove("hidden"); profilList.classList.remove("hidden");
// The popup now exists → attach the event
} }