From 01f85c2779052970bf28271648cf97ebbf1212a7 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Sat, 6 Dec 2025 16:33:28 +0100 Subject: [PATCH] getProfil Function return html for profil page --- frontend/src/chat/chat.css | 4 ++-- frontend/src/pages/chat/chat.html | 4 ++-- frontend/src/pages/chat/chat.ts | 25 ++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/frontend/src/chat/chat.css b/frontend/src/chat/chat.css index e12d5f3..d98a4fb 100644 --- a/frontend/src/chat/chat.css +++ b/frontend/src/chat/chat.css @@ -1,8 +1,8 @@ @import "tailwindcss"; -@font-face { +/* @font-face { font-family: "Nimbus Mono L"; src: url("/fonts/NimbusMonoL.woff2") format("woff2"); -} +} */ @tailwind utilities; diff --git a/frontend/src/pages/chat/chat.html b/frontend/src/pages/chat/chat.html index 6314eff..bf06259 100644 --- a/frontend/src/pages/chat/chat.html +++ b/frontend/src/pages/chat/chat.html @@ -28,12 +28,12 @@
+

Charlie

-->Marks
diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 406a731..ac7ec31 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -58,10 +58,20 @@ function addMessage(text: string) { return ; }; +function clearText() { + const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; + if (!chatWindow) return; + chatWindow.innerHTML = ""; +} + function isLoggedIn() { return getUser() || null; }; +function getProfil(user: string): string { + return `Profil: ${user}
` +} + async function windowStateHidden() { const socketId = __socket || undefined; // let oldName = localStorage.getItem("oldName") ?? undefined; @@ -159,8 +169,14 @@ async function listBuddies(buddies: HTMLDivElement, listBuddies: string) { buddiesElement.addEventListener("dblclick", () => { 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); @@ -289,12 +305,15 @@ async function whoami(socket: Socket) { async function openProfilePopup(profil: string) { + const modalname = document.getElementById("modal-name") ?? null; if (modalname) - modalname.innerHTML = profil; + modalname.innerHTML = `${profil}`; const profilList = document.getElementById("profile-modal") ?? null; if (profilList) profilList.classList.remove("hidden"); + // The popup now exists → attach the event + }