getProfil Function return html for profil page
This commit is contained in:
parent
3550303a93
commit
01f85c2779
3 changed files with 26 additions and 7 deletions
|
|
@ -1,8 +1,8 @@
|
|||
@import "tailwindcss";
|
||||
@font-face {
|
||||
/* @font-face {
|
||||
font-family: "Nimbus Mono L";
|
||||
src: url("/fonts/NimbusMonoL.woff2") format("woff2");
|
||||
}
|
||||
} */
|
||||
|
||||
@tailwind utilities;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
<div id = "div-buddies">
|
||||
<!-- <p>Alice</p>
|
||||
<p>Bob</p>
|
||||
<p>Charlie</p> -->
|
||||
<p>Charlie</p> -->Marks
|
||||
</div>
|
||||
</div>
|
||||
<div id="profile-modal" class="profilPopup hidden">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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} </br> <button id="popup-b-clear" class="btn-style">Clear Text</button>`
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue