- change style button chat (absolute -> fixed)
    - Add script for chat
This commit is contained in:
Kum1ta
2024-08-25 18:22:49 +02:00
parent e316cadce4
commit f93fcbb28c
5 changed files with 50 additions and 28 deletions

View File

@ -6,13 +6,13 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */ /* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */
/* Updated: 2024/08/25 15:29:51 by edbernar ### ########.fr */ /* Updated: 2024/08/25 18:18:09 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
import { Home3D } from "/static/javascript/home3D/home3D.js" import { Home3D } from "/static/javascript/home3D/home3D.js"
import { Login } from "/static/javascript/login/main.js"; import { Login } from "/static/javascript/login/main.js";
// import { liveChat } from "/static/javascript/liveChat/main.js"; import { LiveChat } from "/static/javascript/liveChat/main.js";
class HomePage class HomePage
{ {
@ -20,6 +20,7 @@ class HomePage
{ {
Home3D.create(); Home3D.create();
Login.create(); Login.create();
LiveChat.create();
window.addEventListener('scroll', scrool); window.addEventListener('scroll', scrool);
} }
@ -27,7 +28,8 @@ class HomePage
{ {
Home3D.dispose(); Home3D.dispose();
Login.dispose(); Login.dispose();
window.addEventListener('scroll', scrool); LiveChat.dispose();
window.removeEventListener('scroll', scrool);
} }
}; };

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */ /* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */
/* Updated: 2024/08/24 23:22:20 by edbernar ### ########.fr */ /* Updated: 2024/08/25 18:17:13 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,32 @@ import { showListUser } from "/static/javascript/liveChat/showUserList.js";
- game message when game will be implemented - game message when game will be implemented
*/ */
let chatButton = null;
let topChatHomeCross = null;
class LiveChat
{
static create()
{
const chatDiv = document.getElementById("chatDiv");
chatButton = document.getElementById("chatButton");
topChatHomeCross = document.getElementById("topChatCross");
chatButton.addEventListener("click", showChatMenu);
topChatHomeCross.addEventListener("click", hideChatMenu);
}
static dispose()
{
chatButton.removeEventListener("click", showChatMenu);
topChatHomeCross.removeEventListener("click", hideChatMenu);
chatButton = null;
topChatHomeCross = null;
}
}
function addDefaultButton() function addDefaultButton()
{ {
const newDiv = document.createElement("div"); const newDiv = document.createElement("div");
@ -60,22 +86,18 @@ function removeButtonIfExist()
} }
} }
function liveChat() async function showChatMenu()
{ {
const chatButton = document.getElementById("chatButton");
const chatDiv = document.getElementById("chatDiv");
const topChatHomeCross = document.getElementById("topChatCross");
chatButton.addEventListener("click", async () => {
chatDiv.style.display = "flex"; chatDiv.style.display = "flex";
removeButtonIfExist(); removeButtonIfExist();
addDefaultButton(); addDefaultButton();
await showListUser(); await showListUser();
});
topChatHomeCross.addEventListener("click", () => {
chatDiv.style.display = "none";
infoPanel.isOpen = false;
});
} }
export { liveChat }; function hideChatMenu()
{
chatDiv.style.display = "none";
infoPanel.isOpen = false;
}
export { LiveChat };

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 00:39:53 by edbernar #+# #+# */ /* Created: 2024/08/02 00:39:53 by edbernar #+# #+# */
/* Updated: 2024/08/25 17:09:22 by edbernar ### ########.fr */ /* Updated: 2024/08/25 18:09:04 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -35,7 +35,6 @@ function typeLogin(content)
console.log("Welcome " + content.username + "\nYou're id is " + content.id); console.log("Welcome " + content.username + "\nYou're id is " + content.id);
userMeInfo.username = content.username; userMeInfo.username = content.username;
userMeInfo.id = content.id; userMeInfo.id = content.id;
console.warn("L'ID a été ajouté manuellement dans le serv: " + userMeInfo.id);
} }
loginAvailable = true; loginAvailable = true;
if (loginResolve) if (loginResolve)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */ /* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
/* Updated: 2024/08/25 17:17:57 by edbernar ### ########.fr */ /* Updated: 2024/08/25 18:09:25 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -67,7 +67,6 @@ socket.onmessage = (event) => {
} }
else else
{ {
console.log(response);
try { try {
functionResponse[typeResponse.indexOf(response.type)](response.content); functionResponse[typeResponse.indexOf(response.type)](response.content);
} catch { } catch {

View File

@ -3,16 +3,16 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* liveChat.css :+: :+: :+: */ /* liveChat.css :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 13:53:39 by edbernar #+# #+# */ /* Created: 2024/07/30 13:53:39 by edbernar #+# #+# */
/* Updated: 2024/08/10 16:47:10 by marvin ### ########.fr */ /* Updated: 2024/08/25 18:20:50 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#chatButton { #chatButton {
position: absolute; position: fixed;
bottom: 10px; bottom: 10px;
left: 30px; left: 30px;
background-color: white; background-color: white;
@ -36,7 +36,7 @@
width: 350px; width: 350px;
height: 400px; height: 400px;
background-color: #131313; background-color: #131313;
position: absolute; position: fixed;
left: 20px; left: 20px;
bottom: 0px; bottom: 0px;
z-index: 999; z-index: 999;