Added notification state sign and cmd @help

This commit is contained in:
NigeParis 2026-01-02 12:56:27 +01:00 committed by Maix0
parent 2ed524872b
commit b8b4bbd1cb
3 changed files with 36 additions and 1 deletions

View file

@ -17,6 +17,7 @@
<div id="t-chatbox" class="chatbox-style"></div> <div id="t-chatbox" class="chatbox-style"></div>
<div id="t-input-send" class="flex gap-1 mt-2"> <div id="t-input-send" class="flex gap-1 mt-2">
<input id="t-chat-window" placeholder="Type your message..." class="chat-window-style" /> <input id="t-chat-window" placeholder="Type your message..." class="chat-window-style" />
<div id="notify">🔕</div>
<button id="b-send" class="send-btn-style">Send</button> <button id="b-send" class="send-btn-style">Send</button>
</div> </div>
</div> </div>

View file

@ -122,7 +122,7 @@ function parseCmdMsg(msgText: string): string[] | undefined {
command[1] = msgText; command[1] = msgText;
return command; return command;
} }
const noArgCommands = ['@quit', '@who', '@cls']; const noArgCommands = ['@quit', '@help', '@cls'];
if (noArgCommands.includes(msgText)) { if (noArgCommands.includes(msgText)) {
command[0] = msgText; command[0] = msgText;
command[1] = ''; command[1] = '';
@ -456,6 +456,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
// Send button // Send button
sendButton?.addEventListener("click", () => { sendButton?.addEventListener("click", () => {
const notify = document.getElementById("notify") ?? null;
if (sendtextbox && sendtextbox.value.trim()) { if (sendtextbox && sendtextbox.value.trim()) {
let msgText: string = sendtextbox.value.trim(); let msgText: string = sendtextbox.value.trim();
const msgCommand = parseCmdMsg(msgText) ?? ""; const msgCommand = parseCmdMsg(msgText) ?? "";
@ -466,18 +467,32 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
broadcastMsg(socket, msgCommand); broadcastMsg(socket, msgCommand);
break; break;
case '@notify': case '@notify':
if (notify === null) {break;};
if (inviteMsgFlag === false) { if (inviteMsgFlag === false) {
notify.innerText = '🔔';
inviteMsgFlag = true; inviteMsgFlag = true;
} else { } else {
notify.innerText = '🔕';
inviteMsgFlag = false; inviteMsgFlag = false;
} }
break; break;
case '@profil': case '@profil':
if (msgCommand[1] === '') {break;};
getProfil(socket, msgCommand[1]); getProfil(socket, msgCommand[1]);
break; break;
case '@cls': case '@cls':
chatWindow.innerHTML = ''; chatWindow.innerHTML = '';
break; break;
case '@help':
addMessage('*');
addMessage('** ********** List of @cmds ********** **');
addMessage('\'@cls\' - clear chat screen conversations');
addMessage('\'@profil <name>\' - pulls ups user profil');
addMessage('\'@notify\' - toggles notifications on / off');
addMessage('\'@quit\' - disconnect user from the chat');
addMessage('** *********************************** **');
addMessage('*');
break;
case '@quit': case '@quit':
quitChat(socket); quitChat(socket);
break; break;

View file

@ -39,5 +39,24 @@ export async function makeProfil(fastify: FastifyInstance, user: string, socket:
innerHtml: '', 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; return clientProfil;
}; };