history games now in chat and profil

This commit is contained in:
NigeParis 2026-01-13 15:19:00 +01:00 committed by Maix0
parent 9e431e9c6c
commit 2e87cb12c1
11 changed files with 121 additions and 13 deletions

View file

@ -36,6 +36,24 @@
active:shadow-[0_2px_0_0_black]; active:shadow-[0_2px_0_0_black];
} }
.btn-style-games {
@apply
w-35
h-8
border
border-gray-500
rounded-3xl
bg-gray-500
text-white
cursor-pointer
shadow-[0_2px_0_0_black]
transition-all
hover:bg-blue-200
active:bg-gray-400
active:translate-y-px
active:shadow-[0_2px_0_0_black];
}
.send-btn-style { .send-btn-style {
@apply @apply
w-12.5 w-12.5
@ -106,6 +124,19 @@
} }
.b-game {
@apply
absolute
top-4
left-6
}
.b-TTTgame {
@apply
absolute
left-6
top-14
}
.text-info { .text-info {
@apply @apply
@ -259,6 +290,20 @@ div-private {
right-12 right-12
} }
.popup-b-game {
@apply
absolute
bottom-52
left-12
}
.popup-b-TTTgame {
@apply
absolute
bottom-42
left-12
}
.popUpMessage { .popUpMessage {
@apply @apply
bg-white bg-white

View file

@ -5,6 +5,8 @@
</h1><br> </h1><br>
<button id="b-clear" class="btn-style absolute top-4 right-6">Clear Text</button> <button id="b-clear" class="btn-style absolute top-4 right-6">Clear Text</button>
<button id="b-quit" class="btn-style absolute top-14 right-6">Quit Chat</button> <button id="b-quit" class="btn-style absolute top-14 right-6">Quit Chat</button>
<button id="b-hGame" class="btn-style-games b-game">My Pong Games</button>
<button id="b-hTGame" class="btn-style-games b-TTTgame">My TTT Games</button>
<!-- Horizontal Message Box --> <!-- Horizontal Message Box -->
<div id="chat-system-box" class="system-info">System: connecting ... </div> <div id="chat-system-box" class="system-info">System: connecting ... </div>
<div class="flex justify-center mt-2"> <div class="flex justify-center mt-2">

View file

@ -21,6 +21,7 @@ import { addInviteMessage, addMessage } from "./chatHelperFunctions/addMessage";
import { broadcastMsg } from "./chatHelperFunctions/broadcastMsg"; import { broadcastMsg } from "./chatHelperFunctions/broadcastMsg";
import { openProfilePopup } from "./chatHelperFunctions/openProfilePopup"; import { openProfilePopup } from "./chatHelperFunctions/openProfilePopup";
import { actionBtnPopUpBlock } from "./chatHelperFunctions/actionBtnPopUpBlock"; import { actionBtnPopUpBlock } from "./chatHelperFunctions/actionBtnPopUpBlock";
import { actionBtnPongGames } from "./chatHelperFunctions/actionBtnPongGames";
import { windowStateHidden } from "./chatHelperFunctions/windowStateHidden"; import { windowStateHidden } from "./chatHelperFunctions/windowStateHidden";
import { blockUser } from "./chatHelperFunctions/blockUser"; import { blockUser } from "./chatHelperFunctions/blockUser";
import { parseCmdMsg } from "./chatHelperFunctions/parseCmdMsg"; import { parseCmdMsg } from "./chatHelperFunctions/parseCmdMsg";
@ -32,6 +33,7 @@ import { openMessagePopup } from "./chatHelperFunctions/openMessagePopup";
import { windowStateVisable } from "./chatHelperFunctions/windowStateVisable"; import { windowStateVisable } from "./chatHelperFunctions/windowStateVisable";
import { cmdList } from "./chatHelperFunctions/cmdList"; import { cmdList } from "./chatHelperFunctions/cmdList";
import { showInfo } from "../toast"; import { showInfo } from "../toast";
import { actionBtnTTTGames } from "./chatHelperFunctions/actionBtnTTTGames";
const MAX_SYSTEM_MESSAGES = 10; const MAX_SYSTEM_MESSAGES = 10;
let inviteMsgFlag: boolean = false; let inviteMsgFlag: boolean = false;
@ -71,6 +73,8 @@ const chatButton = document.querySelector("#chatButton");
const chatWindow = document.querySelector("#t-chatbox")!; const chatWindow = document.querySelector("#t-chatbox")!;
const clearText = document.getElementById("b-clear") as HTMLButtonElement; const clearText = document.getElementById("b-clear") as HTMLButtonElement;
const gameMessage = document.getElementById("game-modal") ?? null; const gameMessage = document.getElementById("game-modal") ?? null;
const myGames = document.getElementById("b-hGame") ?? null;
const myTTTGames = document.getElementById("b-hTGame") ?? null;
const modalmessage = document.getElementById("modal-message") ?? null; const modalmessage = document.getElementById("modal-message") ?? null;
const noGuest = document.getElementById("noGuest") ?? null; const noGuest = document.getElementById("noGuest") ?? null;
const notify = document.getElementById("notify") ?? null; const notify = document.getElementById("notify") ?? null;
@ -176,6 +180,8 @@ function initChatSocket() {
socket.emit("check_Block_button", profil); socket.emit("check_Block_button", profil);
actionBtnPopUpInvite(profil, socket); actionBtnPopUpInvite(profil, socket);
actionBtnPopUpBlock(profil, socket); actionBtnPopUpBlock(profil, socket);
actionBtnPongGames(profil, socket);
actionBtnTTTGames(profil, socket);
}); });
socket.on("blockUser", (blocked: ClientProfil) => { socket.on("blockUser", (blocked: ClientProfil) => {
@ -304,6 +310,20 @@ sendButton?.addEventListener("click", () => {
} }
break; break;
case "@pong":
if (msgCommand[1] === "") {
window.location.href = "/app/pong/games";
quitChat();
}
break;
case "@ttt":
if (msgCommand[1] === "") {
window.location.href = "/app/ttt/games";
quitChat();
}
break;
case "@guest": case "@guest":
if (!userId) { if (!userId) {
return; return;
@ -384,9 +404,6 @@ sendButton?.addEventListener("click", () => {
let toggle = false; let toggle = false;
window.addEventListener("focus", async () => { window.addEventListener("focus", async () => {
console.log('--------------------------')
console.log('Window focus called Called');
console.log('--------------------------')
setTimeout(() => { setTimeout(() => {
if (window.__state.chatSock) connected(window.__state.chatSock); if (window.__state.chatSock) connected(window.__state.chatSock);
}, 16); }, 16);
@ -411,8 +428,21 @@ clearText?.addEventListener("click", () => {
bquit?.addEventListener("click", () => { bquit?.addEventListener("click", () => {
quitChat(); quitChat();
}); });
myGames?.addEventListener("click", () => {
window.location.href = "/app/pong/games";
quitChat();
});
myTTTGames?.addEventListener("click", () => {
window.location.href = "/app/ttt/games";
quitChat();
});
// Enter key to send message // Enter key to send message
sendtextbox.addEventListener("keydown", (event) => { sendtextbox.addEventListener("keydown", (event) => {
if (!sendtextbox) return; if (!sendtextbox) return;

View file

@ -0,0 +1,17 @@
import type { ClientProfil } from "../types_front";
import { Socket } from "socket.io-client";
/**
* function listens for a click on the Pong Games history button
* @param profile - Clients target profil
* @param senderSocket - socket from the sender
**/
export function actionBtnPongGames(profile: ClientProfil, senderSocket: Socket) {
setTimeout(() => {
const userGames = document.querySelector("#popup-b-hGame");
userGames?.addEventListener("click", () => {
window.location.href = `/app/pong/games/${profile.userID}`;
});
}, 0)
};

View file

@ -0,0 +1,17 @@
import type { ClientProfil } from "../types_front";
import { Socket } from "socket.io-client";
/**
* function listens for a click on the TTT game History button
* @param profile - Clients target profil
* @param senderSocket - socket from the sender
**/
export function actionBtnTTTGames(profile: ClientProfil, senderSocket: Socket) {
setTimeout(() => {
const userGames = document.querySelector("#popup-b-hTGame");
userGames?.addEventListener("click", () => {
window.location.href = `/app/ttt/games/${profile.userID}`;
});
}, 0)
};

View file

@ -14,6 +14,7 @@ export function cmdList() {
} }
addMessage('\'@notify\' - toggles notifications on / off'); addMessage('\'@notify\' - toggles notifications on / off');
addMessage('\'@quit\' - disconnect user from the chat'); addMessage('\'@quit\' - disconnect user from the chat');
addMessage('\'@pong\' - displays your pong match results');
addMessage('** *********************************** **'); addMessage('** *********************************** **');
addMessage('*'); addMessage('*');
} }

View file

@ -17,7 +17,6 @@ export async function openMessagePopup(message: any) {
`; `;
modalmessage.appendChild(messageElement); modalmessage.appendChild(messageElement);
modalmessage.scrollTop = modalmessage.scrollHeight; modalmessage.scrollTop = modalmessage.scrollHeight;
} }
const gameMessage = document.getElementById("game-modal") ?? null; const gameMessage = document.getElementById("game-modal") ?? null;
if (gameMessage) { if (gameMessage) {

View file

@ -13,7 +13,10 @@ export async function openProfilePopup(profil: ClientProfil) {
</br> </br>
<button id="popup-b-invite" class="btn-style popup-b-invite">U Game ?</button> <button id="popup-b-invite" class="btn-style popup-b-invite">U Game ?</button>
<button id="popup-b-block" class="btn-style popup-b-block">Block User</button> <button id="popup-b-block" class="btn-style popup-b-block">Block User</button>
<div id="profile-about" class="text-2xl">About: <span class="recessed text-amber-500">${profil.text}</span> </div> <div id="profile-about" class="text-2xl">About: <span class="recessed">${profil.text}</span> </div>
<button id="popup-b-hGame" class="btn-style-games popup-b-game">My Pong Games</button>
<button id="popup-b-hTGame" class="btn-style-games popup-b-TTTgame">My TTT Games</button>
</div> </div>
`; `;
const profilList = document.getElementById("profile-modal") ?? null; const profilList = document.getElementById("profile-modal") ?? null;

View file

@ -17,7 +17,7 @@ export function parseCmdMsg(msgText: string): string[] | undefined {
command[1] = msgText; command[1] = msgText;
return command; return command;
} }
const noArgCommands = ['@quit', '@help', '@cls']; const noArgCommands = ['@quit', '@help', '@cls', '@pong', '@ttt'];
if (noArgCommands.includes(msgText)) { if (noArgCommands.includes(msgText)) {
command[0] = msgText; command[0] = msgText;
command[1] = ''; command[1] = '';

View file

@ -1,9 +1,6 @@
import { updateUser } from "@app/auth"; import { updateUser } from "@app/auth";
export async function windowStateHidden() { export async function windowStateHidden() {
console.log('--------------------------')
console.log('WindowState Hidden Called');
console.log('--------------------------')
const socketId = window.__state.chatSock || undefined; const socketId = window.__state.chatSock || undefined;
// let oldName = localStorage.getItem("oldName") ?? undefined; // let oldName = localStorage.getItem("oldName") ?? undefined;
let oldName: string; let oldName: string;

View file

@ -9,9 +9,6 @@ import { updateUser } from "@app/auth";
export async function windowStateVisable() { export async function windowStateVisable() {
console.log('--------------------------')
console.log('WindowState Visable Called');
console.log('--------------------------')
const buddies = document.getElementById('div-buddies') as HTMLDivElement; const buddies = document.getElementById('div-buddies') as HTMLDivElement;
const socketId = window.__state.chatSock || undefined; const socketId = window.__state.chatSock || undefined;
let oldName = localStorage.getItem("oldName") || undefined; let oldName = localStorage.getItem("oldName") || undefined;