- remove time and from in message request
    - add page lobby when click on tv (only when we are connected)
This commit is contained in:
Kum1ta
2024-08-25 21:27:29 +02:00
parent f93fcbb28c
commit 6bf18ad227
15 changed files with 212 additions and 139 deletions

View File

@ -6,17 +6,19 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
/* Updated: 2024/08/25 15:22:15 by edbernar ### ########.fr */
/* Updated: 2024/08/25 21:09:33 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { HomePage } from "/static/javascript/homePage/main.js";
import { LobbyPage } from "/static/javascript/lobbyPage/main.js";
class Page
{
actualPage = null;
availablePages = [
{url:'/', servUrl: '/homePage', class: HomePage, name: 'homePage', title: 'PTME - Home'},
{url:'/lobby', servUrl: '/lobbyPage', class: LobbyPage, name: 'lobbyPage', title: 'PTME - Lobby'},
]
constructor()
@ -48,12 +50,13 @@ class Page
})
.then(data => {
data.text().then(text => {
console.log("Page updated !");
document.body.innerHTML = text;
this.availablePages[i].class.create();
this.actualPage = this.availablePages[i].class;
document.title = this.availablePages[i].title;
this.actualPage = this.availablePages[i].name;
history.pushState({}, this.availablePages[i].title, this.availablePages[i].url);
});
this.actualPage.create();
})
})
.catch(error => {
throw Error(error);

View File

@ -6,15 +6,17 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
/* Updated: 2024/08/25 15:03:42 by edbernar ### ########.fr */
/* Updated: 2024/08/25 21:10:59 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { EffectComposer } from '/static/javascript/three/examples/jsm/postprocessing/EffectComposer.js';
import { RenderPass } from '/static/javascript/three/examples/jsm/postprocessing/RenderPass.js';
import { BokehPass } from '/static/javascript/three/examples/jsm/postprocessing/BokehPass.js';
import { userMeInfo } from "/static/javascript/typeResponse/typeLogin.js";
import * as THREE from '/static/javascript/three/build/three.module.js'
import { Screen, light } from '/static/javascript/home3D/Screen.js'
import { pageRenderer } from '/static/javascript/main.js'
let scene = null;
let renderer = null;
@ -40,6 +42,7 @@ class Home3D
{
document.removeEventListener('resize', windowUpdater);
document.removeEventListener('mousemove', mouseTracker);
document.removeEventListener('click', redirection);
if (interval)
clearInterval(interval);
@ -190,6 +193,8 @@ function home3D()
actualVideo = 0;
}, 100);
let clickDetect = false;
function loop()
{
raycaster.setFromCamera( mouse, camera );
@ -208,18 +213,37 @@ function home3D()
actualVideo = 0;
}
}
else if (intersects[0].object == screen.screen)
else
{
if (actualVideo != 1)
if (clickDetect)
{
screen.changeVideo(video.login);
actualVideo = 1;
document.removeEventListener('click', redirection);
clickDetect = false;
}
if (intersects[0].object == screen.screen)
{
if (userMeInfo.id == -1)
{
if (actualVideo != 1)
{
screen.changeVideo(video.login);
actualVideo = 1;
}
}
else
{
if (!clickDetect)
{
document.addEventListener('click', redirection);
clickDetect = true;
}
}
}
else if (actualVideo != 0)
{
screen.changeVideo(video.pong);
actualVideo = 0;
}
}
else if (actualVideo != 0)
{
screen.changeVideo(video.pong);
actualVideo = 0;
}
composer.render();
}
@ -316,4 +340,9 @@ function mouseTracker (event)
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
};
function redirection()
{
pageRenderer.changePage('lobbyPage');
}
export { Home3D };

View File

@ -6,13 +6,13 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */
/* Updated: 2024/08/25 18:18:09 by edbernar ### ########.fr */
/* Updated: 2024/08/25 18:26:17 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { LiveChat } from "/static/javascript/liveChat/main.js";
import { Home3D } from "/static/javascript/home3D/home3D.js"
import { Login } from "/static/javascript/login/main.js";
import { LiveChat } from "/static/javascript/liveChat/main.js";
class HomePage
{

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */
/* Updated: 2024/08/25 18:17:13 by edbernar ### ########.fr */
/* Updated: 2024/08/25 18:26:52 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,8 +27,6 @@ class LiveChat
{
static create()
{
const chatDiv = document.getElementById("chatDiv");
chatButton = document.getElementById("chatButton");
topChatHomeCross = document.getElementById("topChatCross");

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:17:54 by edbernar #+# #+# */
/* Updated: 2024/08/24 23:49:04 by edbernar ### ########.fr */
/* Updated: 2024/08/25 21:24:06 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -142,10 +142,8 @@ function sendMessage(user)
let message;
message = {
from: userMeInfo.id,
to: user.id,
content: inputMessage.value,
time: new Date()
};
sendRequest("send_private_message", message);
}

View File

@ -0,0 +1,103 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
/* Updated: 2024/08/25 21:20:17 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
/*
Information :
- 0: Multiplayer local
- 1: Matchmaking
- 2: Ranked
- 3: Tournament
*/
let listSelectCard = null;
let gameMode = 0;
class LobbyPage
{
static create()
{
console.log("Lobby created");
listSelectCard = document.getElementsByClassName('select-card');
gameMode = 0;
document.getElementsByClassName('game-mode')[0].addEventListener('click', showGameMode);
document.getElementById('closePopupBtn').addEventListener('click', hideGameMode);
window.addEventListener('click', closeClickOutsiteGameMode);
listSelectCard[0].addEventListener('click', selectGameModeOne);
listSelectCard[1].addEventListener('click', selectGameModeTwo);
listSelectCard[2].addEventListener('click', selectGameModeThree);
listSelectCard[3].addEventListener('click', selectGameModeFour);
}
static dispose()
{
gameMode = 0;
document.getElementsByClassName('game-mode')[0].removeEventListener('click', showGameMode);
document.getElementById('closePopupBtn').removeEventListener('click', hideGameMode);
window.removeEventListener('click', closeClickOutsiteGameMode);
listSelectCard[0].removeEventListener('click', selectGameModeOne);
listSelectCard[1].removeEventListener('click', selectGameModeTwo);
listSelectCard[2].removeEventListener('click', selectGameModeThree);
listSelectCard[3].removeEventListener('click', selectGameModeFour);
listSelectCard = null;
}
}
function showGameMode()
{
document.getElementById('loginPopup').style.display = 'flex';
}
function hideGameMode()
{
document.getElementById('loginPopup').style.display = 'none';
}
function closeClickOutsiteGameMode(event)
{
if (event.target == document.getElementById('loginPopup')) {
document.getElementById('loginPopup').style.display = 'none';
}
}
function selectGameModeOne()
{
document.getElementById('loginPopup').style.display = 'none';
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[0].innerHTML;
gameMode = 0;
}
function selectGameModeTwo()
{
document.getElementById('loginPopup').style.display = 'none';
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[1].innerHTML;
gameMode = 1;
}
function selectGameModeThree()
{
document.getElementById('loginPopup').style.display = 'none';
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[2].innerHTML;
gameMode = 2;
}
function selectGameModeFour()
{
document.getElementById('loginPopup').style.display = 'none';
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[3].innerHTML;
gameMode = 3;
}
export { LobbyPage };

View File

@ -6,13 +6,14 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 17:40:15 by edbernar #+# #+# */
/* Updated: 2024/08/25 17:14:01 by edbernar ### ########.fr */
/* Updated: 2024/08/25 18:54:51 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { createNotification as CN } from "/static/javascript/notification/main.js";
import { userMeInfo, waitForLogin } from "/static/javascript/typeResponse/typeLogin.js";
import { sendRequest } from "/static/javascript/websocket.js";
class Login
{
static create()

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 13:50:35 by edbernar #+# #+# */
/* Updated: 2024/08/25 15:52:57 by edbernar ### ########.fr */
/* Updated: 2024/08/25 19:09:02 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,3 +18,5 @@ let pageRenderer = null;
document.addEventListener('DOMContentLoaded', () => {
pageRenderer = new Page();
});
export { pageRenderer };

View File

@ -0,0 +1,238 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* style.css :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/17 22:12:26 by marvin #+# #+# */
/* Updated: 2024/08/17 22:12:26 by marvin ### ########.fr */
/* */
/* ************************************************************************** */
@keyframes anim1 {
0% {
transform: translate(0, -150%);
}
100% {
transform: translateY(0, 0);
}
}
@keyframes anim2 {
0% {
backdrop-filter: blur(0px);
background-color: rgba(0, 0, 0, 0);
}
100% {
backdrop-filter: blur(5px);
background-color: rgba(0, 0, 0, 0.8);
}
}
* {
margin: 0;
padding: 0;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-style: normal;
}
body {
border: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #020202;
user-select: none;
}
.main{
padding-top: 80px;
padding-inline: 150px;
display: flex;
flex-direction: row;
gap: 2.6rem;
}
.skin-select{
/* padding-block: 25px; */
width: 40%;
}
.popup {
display: none; /* La popup est masquée par défaut */
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(5px);
justify-content: center;
align-items: center;
z-index: 1000;
}
.popup-content {
background-color: white;
padding: 20px;
text-align: center;
width: 40%;
position: relative;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}
.popup-content form {
display: flex;
flex-direction: column;
}
.choose{
display: flex;
justify-content: center;
gap: 20px;
}
.select-card{
margin: 30px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
background-color: #d3d3d3;
color: #000;
height: 90px;
font-size: 1.2em;
transition: transform 0.3s ease;
}
.select-card:hover {
transform: scale(1.05);
}
.switch {
position: relative;
}
.switch p{
color: white;
font-size: 1.2em;
}
.switch label {
width: 59px;
height: 28px;
background-color: #999;
position: absolute;
top: 0;
left: 0;
border-radius: 50px;
}
.switch input[type="checkbox"] {
visibility: hidden;
}
.switch label:after {
content: '';
margin-top: 2px;
margin-left: 2px;
width: 22px;
height: 22px;
border-radius: 50px;
position: absolute;
top: 1px;
left: 1px;
transition: 200ms;
background-color: white;
}
.switch .look:checked + label:after {
left: 32px;
}
.switch .look:checked + label {
background-color: rgb(18, 223, 96);
}
#bar{
margin: 15px;
width: 250px;
height: 250px;
border: 5px solid white;
}
#goal{
margin: 15px;
width: 250px;
height: 250px;
border: 5px solid white;
}
#topBar {
margin-block: 25px;
padding: 0;
padding-inline: 50px;
display: flex;
background-color: #020202;
gap: 2rem;
align-items: center;
justify-content: center;
inset-inline: 0;
top: 0;
}
.game-mode {
display: flex;
justify-content: flex-start;
}
.mode-card {
background-color: #d3d3d3;
color: #000;
padding: 20px;
width: 300px;
height: 550px;
display: flex;
justify-content: center;
font-size: 1.2em;
transition: transform 0.3s ease;
}
.mode-card:hover {
transform: scale(1.05);
}
.search-container {
display: flex;
align-items: center;
width: 40%;
}
.search-input {
width: 100%;
padding: 10px;
border: 2px solid #ccc;
font-size: 16px;
outline: none;
}
.search-input:focus {
border-color: white;
}
.search-button {
padding: 10px 20px;
border: 2px solid white;
background-color: #272727;
color: white;
cursor: pointer;
font-size: 16px;
}
.search-button:hover {
background-color: #202020;
border-color: #c4c4c4;
}