From b8b4bbd1cb0a378f58ccf51c088bdaba936a8688 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Fri, 2 Jan 2026 12:56:27 +0100 Subject: [PATCH] Added notification state sign and cmd @help --- frontend/src/pages/chat/chat.html | 1 + frontend/src/pages/chat/chat.ts | 17 ++++++++++++++++- src/chat/src/makeProfil.ts | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/chat/chat.html b/frontend/src/pages/chat/chat.html index c5e0d75..869e687 100644 --- a/frontend/src/pages/chat/chat.html +++ b/frontend/src/pages/chat/chat.html @@ -17,6 +17,7 @@
+
🔕
diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index f4642eb..8bc8993 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -122,7 +122,7 @@ function parseCmdMsg(msgText: string): string[] | undefined { command[1] = msgText; return command; } - const noArgCommands = ['@quit', '@who', '@cls']; + const noArgCommands = ['@quit', '@help', '@cls']; if (noArgCommands.includes(msgText)) { command[0] = msgText; command[1] = ''; @@ -456,6 +456,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn // Send button sendButton?.addEventListener("click", () => { + const notify = document.getElementById("notify") ?? null; if (sendtextbox && sendtextbox.value.trim()) { let msgText: string = sendtextbox.value.trim(); const msgCommand = parseCmdMsg(msgText) ?? ""; @@ -466,18 +467,32 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn broadcastMsg(socket, msgCommand); break; case '@notify': + if (notify === null) {break;}; if (inviteMsgFlag === false) { + notify.innerText = '🔔'; inviteMsgFlag = true; } else { + notify.innerText = '🔕'; inviteMsgFlag = false; } break; case '@profil': + if (msgCommand[1] === '') {break;}; getProfil(socket, msgCommand[1]); break; case '@cls': chatWindow.innerHTML = ''; break; + case '@help': + addMessage('*'); + addMessage('** ********** List of @cmds ********** **'); + addMessage('\'@cls\' - clear chat screen conversations'); + addMessage('\'@profil \' - pulls ups user profil'); + addMessage('\'@notify\' - toggles notifications on / off'); + addMessage('\'@quit\' - disconnect user from the chat'); + addMessage('** *********************************** **'); + addMessage('*'); + break; case '@quit': quitChat(socket); break; diff --git a/src/chat/src/makeProfil.ts b/src/chat/src/makeProfil.ts index 25d4b15..04745ef 100644 --- a/src/chat/src/makeProfil.ts +++ b/src/chat/src/makeProfil.ts @@ -39,5 +39,24 @@ export async function makeProfil(fastify: FastifyInstance, user: string, socket: innerHtml: '', }; } + else { + clientProfil = + { + command: 'makeProfil', + destination: 'profilMsg', + type: 'chat' as const, + user: user, + loginName: 'Not Found', + userID: 'Not Found', + text: 'Not Found', + timestamp: Date.now(), + SenderWindowID: socket.id, + SenderName: '', + Sendertext: '', + SenderID: '', + innerHtml: '', + }; + + } return clientProfil; };