Site
- login now working (but not if refresh page - Starting singlepage Django - Added path
This commit is contained in:
BIN
docker-compose/.DS_Store
vendored
BIN
docker-compose/.DS_Store
vendored
Binary file not shown.
BIN
docker-compose/requirements/.DS_Store
vendored
BIN
docker-compose/requirements/.DS_Store
vendored
Binary file not shown.
@ -5,7 +5,7 @@ class User(models.Model):
|
|||||||
username = models.CharField(max_length=20, unique=True)
|
username = models.CharField(max_length=20, unique=True)
|
||||||
mail = models.EmailField(unique=True)
|
mail = models.EmailField(unique=True)
|
||||||
password = models.CharField(max_length=100)
|
password = models.CharField(max_length=100)
|
||||||
id42 = models.DecimalField(decimal_places=0, unique=True, default=0)
|
id42 = models.DecimalField(max_digits=15, decimal_places=0, default=0)
|
||||||
|
|
||||||
class Message(models.Model):
|
class Message(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
<div id="divNotification">
|
||||||
|
</div>
|
||||||
|
<div id="topBar">
|
||||||
|
<h1>PTME</h1>
|
||||||
|
<div id="topButton">
|
||||||
|
<p>HOME</p>
|
||||||
|
<p>PROJECT</p>
|
||||||
|
<p>NEWS</p>
|
||||||
|
</div>
|
||||||
|
<div id="loginButton">
|
||||||
|
<p>LOGIN</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="loginPopup" class="popup">
|
||||||
|
<div class="container">
|
||||||
|
<div class="left-side"></div>
|
||||||
|
<div class="right-side">
|
||||||
|
<h1>Access to a new WORLD</h1>
|
||||||
|
<form id="loginForm">
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" id="email" name="email" placeholder="Email">
|
||||||
|
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" id="password" name="password" placeholder="Password">
|
||||||
|
|
||||||
|
<button type="submit" class="login-btn">Login</button>
|
||||||
|
|
||||||
|
<div class="new-player">
|
||||||
|
New player? <a href="#">Create an account</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="divider">
|
||||||
|
<span></span>
|
||||||
|
<p>Or</p>
|
||||||
|
<span></span>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="login-42-btn">Log with <span>42</span></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="chatButton">
|
||||||
|
<p>CHAT</p>
|
||||||
|
</div>
|
||||||
|
<div id="chatDiv">
|
||||||
|
<div id="topChatHome">
|
||||||
|
<h1>Chat</h1>
|
||||||
|
<div id="topChatCross">
|
||||||
|
<h2>X</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<section class="homeSection">
|
||||||
|
</section>
|
||||||
|
<section class="homeSection relative">
|
||||||
|
<img id="firstBall" src="/static/img/homePage/ball3D2.png">
|
||||||
|
<img id="secondBall" src="/static/img/homePage/ball3D3.png">
|
||||||
|
<div class="relative">
|
||||||
|
<p id="firstText">Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia totam cupiditate magni unde expedita molestiae eum aliquam fugit voluptatibus omnis! Dolores, ipsa inventore necessitatibus numquam aspernatur in perferendis id voluptas?</p>
|
||||||
|
<p id="secondText">Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia totam cupiditate magni unde expedita molestiae eum aliquam fugit voluptatibus omnis! Dolores, ipsa inventore necessitatibus numquam aspernatur in perferendis id voluptas?</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="homeSection">
|
||||||
|
<div class="team">
|
||||||
|
<div class="team-member">
|
||||||
|
<img src="/static/img/homePage/tomoron.png" alt="Tom" class="team-photo">
|
||||||
|
<h2>Tom, tomoron</h2>
|
||||||
|
<p>Partie Backend</p>
|
||||||
|
<div class="info">
|
||||||
|
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="team-member">
|
||||||
|
<img src="/static/img/homePage/madegryc.png" alt="Mathis" class="team-photo">
|
||||||
|
<h2>Mathis, madegryc</h2>
|
||||||
|
<p>Partie Frontend / Design</p>
|
||||||
|
<div class="info">
|
||||||
|
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="team-member">
|
||||||
|
<img src="/static/img/homePage/edbernard.png" alt="Eddy" class="team-photo">
|
||||||
|
<h2>Eddy, edbernar</h2>
|
||||||
|
<p>Partie Midend</p>
|
||||||
|
<div class="info">
|
||||||
|
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="team-member">
|
||||||
|
<img src="/static/img/homePage/hubourge.png" alt="Hugo" class="team-photo">
|
||||||
|
<h2>Hugo, hubourge</h2>
|
||||||
|
<p>Partie jeu</p>
|
||||||
|
<div class="info">
|
||||||
|
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<footer>
|
||||||
|
<div class="footer-content">
|
||||||
|
<div class="footer-left">
|
||||||
|
<h1>PTME</h1>
|
||||||
|
<p>ft_transcendance project<br>for 42 shcool</p>
|
||||||
|
</div>
|
||||||
|
<div class="footer-right">
|
||||||
|
<p>2024</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
@ -15,113 +15,6 @@
|
|||||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="divNotification">
|
|
||||||
</div>
|
|
||||||
<div id="topBar">
|
|
||||||
<h1>PTME</h1>
|
|
||||||
<div id="topButton">
|
|
||||||
<p>HOME</p>
|
|
||||||
<p>PROJECT</p>
|
|
||||||
<p>NEWS</p>
|
|
||||||
</div>
|
|
||||||
<div id="loginButton">
|
|
||||||
<p>LOGIN</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="loginPopup" class="popup">
|
|
||||||
<div class="container">
|
|
||||||
<div class="left-side"></div>
|
|
||||||
<div class="right-side">
|
|
||||||
<h1>Access to a new WORLD</h1>
|
|
||||||
<form>
|
|
||||||
<label for="email">Email</label>
|
|
||||||
<input type="email" id="email" name="email" placeholder="Email">
|
|
||||||
|
|
||||||
<label for="password">Password</label>
|
|
||||||
<input type="password" id="password" name="password" placeholder="Password">
|
|
||||||
|
|
||||||
<button type="submit" class="login-btn">Login</button>
|
|
||||||
|
|
||||||
<div class="new-player">
|
|
||||||
New player? <a href="#">Create an account</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="divider">
|
|
||||||
<span></span>
|
|
||||||
<p>Or</p>
|
|
||||||
<span></span>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="login-42-btn">Log with <span>42</span></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="chatButton">
|
|
||||||
<p>CHAT</p>
|
|
||||||
</div>
|
|
||||||
<div id="chatDiv">
|
|
||||||
<div id="topChatHome">
|
|
||||||
<h1>Chat</h1>
|
|
||||||
<div id="topChatCross">
|
|
||||||
<h2>X</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<section class="homeSection">
|
|
||||||
</section>
|
|
||||||
<section class="homeSection relative">
|
|
||||||
<img id="firstBall" src="/static/img/homePage/ball3D2.png">
|
|
||||||
<img id="secondBall" src="/static/img/homePage/ball3D3.png">
|
|
||||||
<div class="relative">
|
|
||||||
<p id="firstText">Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia totam cupiditate magni unde expedita molestiae eum aliquam fugit voluptatibus omnis! Dolores, ipsa inventore necessitatibus numquam aspernatur in perferendis id voluptas?</p>
|
|
||||||
<p id="secondText">Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia totam cupiditate magni unde expedita molestiae eum aliquam fugit voluptatibus omnis! Dolores, ipsa inventore necessitatibus numquam aspernatur in perferendis id voluptas?</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section class="homeSection">
|
|
||||||
<div class="team">
|
|
||||||
<div class="team-member">
|
|
||||||
<img src="/static/img/homePage/tomoron.png" alt="Tom" class="team-photo">
|
|
||||||
<h2>Tom, tomoron</h2>
|
|
||||||
<p>Partie Backend</p>
|
|
||||||
<div class="info">
|
|
||||||
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="team-member">
|
|
||||||
<img src="/static/img/homePage/madegryc.png" alt="Mathis" class="team-photo">
|
|
||||||
<h2>Mathis, madegryc</h2>
|
|
||||||
<p>Partie Frontend / Design</p>
|
|
||||||
<div class="info">
|
|
||||||
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="team-member">
|
|
||||||
<img src="/static/img/homePage/edbernard.png" alt="Eddy" class="team-photo">
|
|
||||||
<h2>Eddy, edbernar</h2>
|
|
||||||
<p>Partie Midend</p>
|
|
||||||
<div class="info">
|
|
||||||
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="team-member">
|
|
||||||
<img src="/static/img/homePage/hubourge.png" alt="Hugo" class="team-photo">
|
|
||||||
<h2>Hugo, hubourge</h2>
|
|
||||||
<p>Partie jeu</p>
|
|
||||||
<div class="info">
|
|
||||||
<p>Tom est spécialisé en développement backend et travaille principalement avec Node.js et MongoDB.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<footer>
|
|
||||||
<div class="footer-content">
|
|
||||||
<div class="footer-left">
|
|
||||||
<h1>PTME</h1>
|
|
||||||
<p>ft_transcendance project<br>for 42 shcool</p>
|
|
||||||
</div>
|
|
||||||
<div class="footer-right">
|
|
||||||
<p>2024</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/08/03 08:10:38 by edbernar #+# #+# #
|
# Created: 2024/08/03 08:10:38 by edbernar #+# #+# #
|
||||||
# Updated: 2024/08/25 15:20:21 by tomoron ### ########.fr #
|
# Updated: 2024/08/25 17:06:42 by edbernar ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -66,7 +66,11 @@ def loginByPass(socket, content):
|
|||||||
socket.scope["session"]["logged_in"] = True
|
socket.scope["session"]["logged_in"] = True
|
||||||
socket.scope["session"]["username"] = jsonVar["content"]["username"]
|
socket.scope["session"]["username"] = jsonVar["content"]["username"]
|
||||||
socket.scope["session"].save()
|
socket.scope["session"].save()
|
||||||
socket.send(text_data=json.dumps(jsonVar))
|
socket.send(text_data=json.dumps({"type":"logged_in", "content":{
|
||||||
|
"status":True,
|
||||||
|
"username":jsonVar["content"]["username"],
|
||||||
|
"id": 9999999,
|
||||||
|
}}))
|
||||||
return
|
return
|
||||||
socket.send(text_data=json.dumps({"type": "error", "content": "Invalid email or password", "code": 9007}))
|
socket.send(text_data=json.dumps({"type": "error", "content": "Invalid email or password", "code": 9007}))
|
||||||
|
|
||||||
|
@ -18,5 +18,6 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("",views.index, name='patate')
|
path("",views.index, name='patate'),
|
||||||
|
path("homePage",views.homePage, name='homePage'),
|
||||||
]
|
]
|
||||||
|
@ -4,3 +4,6 @@ from .models import User
|
|||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return render(request, "index.html", {})
|
return render(request, "index.html", {})
|
||||||
|
|
||||||
|
def homePage(request):
|
||||||
|
return render(request, "homePage.html", {})
|
||||||
|
BIN
docker-compose/requirements/nginx/.DS_Store
vendored
BIN
docker-compose/requirements/nginx/.DS_Store
vendored
Binary file not shown.
BIN
docker-compose/requirements/nginx/static/.DS_Store
vendored
BIN
docker-compose/requirements/nginx/static/.DS_Store
vendored
Binary file not shown.
@ -6,19 +6,69 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/25 00:27:21 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 15:22:15 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
import { HomePage } from "/static/javascript/homePage/main.js";
|
||||||
|
|
||||||
class Page
|
class Page
|
||||||
{
|
{
|
||||||
actualPage = null;
|
actualPage = null;
|
||||||
|
availablePages = [
|
||||||
|
{url:'/', servUrl: '/homePage', class: HomePage, name: 'homePage', title: 'PTME - Home'},
|
||||||
|
]
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
|
for (let i = 0; i < this.availablePages.length; i++)
|
||||||
|
{
|
||||||
|
if (window.location.pathname == this.availablePages[i].url)
|
||||||
|
{
|
||||||
|
this.changePage(this.availablePages[i].name);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.#showUnknownPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changePage(name)
|
||||||
|
{
|
||||||
|
if (this.actualPage != null)
|
||||||
|
this.actualPage.dispose();
|
||||||
|
for (let i = 0; i < this.availablePages.length; i++)
|
||||||
|
{
|
||||||
|
if (name === this.availablePages[i].name)
|
||||||
|
{
|
||||||
|
fetch(this.availablePages[i].servUrl)
|
||||||
|
.then(response => {
|
||||||
|
if (response.status != 200)
|
||||||
|
throw Error("Page '" + name + "' can't be loaded")
|
||||||
|
return (response);
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
data.text().then(text => {
|
||||||
|
document.body.innerHTML = text;
|
||||||
|
this.availablePages[i].class.create();
|
||||||
|
document.title = this.availablePages[i].title;
|
||||||
|
this.actualPage = this.availablePages[i].name;
|
||||||
|
history.pushState({}, this.availablePages[i].title, this.availablePages[i].url);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
throw Error(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw Error("Page '" + page + "' not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
#showUnknownPage()
|
||||||
|
{
|
||||||
|
document.body.innerHTML = "404 - Page not found";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { Page }
|
export { Page }
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
|
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/25 02:19:56 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 15:03:42 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -246,53 +246,59 @@ function home3D()
|
|||||||
scene.add(mesh);
|
scene.add(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fadeInOut()
|
function fadeInOut() {
|
||||||
{
|
|
||||||
if (isInFade)
|
if (isInFade)
|
||||||
return;
|
return;
|
||||||
|
if (intervalFade)
|
||||||
|
clearInterval(intervalFade);
|
||||||
intervalFade = null;
|
intervalFade = null;
|
||||||
isInFade = true;
|
isInFade = true;
|
||||||
intervalFade = setInterval(() => {
|
|
||||||
|
const fadeOut = setInterval(() => {
|
||||||
if (screen == null)
|
if (screen == null)
|
||||||
{
|
{
|
||||||
clearInterval(intervalFade);
|
clearInterval(fadeOut);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
light.point -= 0.2;
|
light.point -= 0.2;
|
||||||
screen.screen.material.opacity -= 0.05;
|
screen.screen.material.opacity -= 0.05;
|
||||||
if (screen.screen.material.opacity <= 0)
|
if (screen.screen.material.opacity <= 0)
|
||||||
{
|
{
|
||||||
clearInterval(intervalFade);
|
clearInterval(fadeOut);
|
||||||
setTimeout(() => {
|
setTimeout(fadeIn, 500);
|
||||||
if (screen == null)
|
|
||||||
{
|
|
||||||
clearInterval(intervalFade);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
interval = setInterval(() => {
|
|
||||||
light.point += 0.2;
|
|
||||||
screen.screen.material.opacity += 0.05;
|
|
||||||
if (screen.screen.material.opacity >= 1)
|
|
||||||
{
|
|
||||||
if (screen == null)
|
|
||||||
{
|
|
||||||
clearInterval(intervalFade);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
clearInterval(intervalFade);
|
|
||||||
intervalFade = setInterval(() => {
|
|
||||||
light.point += 0.2;
|
|
||||||
if (light.point >= 1)
|
|
||||||
clearInterval(intervalFade);
|
|
||||||
}, 10);
|
|
||||||
isInFade = false;
|
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
}, 500);
|
|
||||||
|
function fadeIn()
|
||||||
|
{
|
||||||
|
const fadeInInterval = setInterval(() => {
|
||||||
|
if (screen == null)
|
||||||
|
{
|
||||||
|
clearInterval(fadeInInterval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
light.point += 0.2;
|
||||||
|
screen.screen.material.opacity += 0.05;
|
||||||
|
|
||||||
|
if (screen.screen.material.opacity >= 1)
|
||||||
|
{
|
||||||
|
clearInterval(fadeInInterval);
|
||||||
|
completeFade();
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function completeFade() {
|
||||||
|
intervalFade = setInterval(() => {
|
||||||
|
light.point += 0.2;
|
||||||
|
if (light.point >= 1)
|
||||||
|
{
|
||||||
|
clearInterval(intervalFade);
|
||||||
|
isInFade = false;
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
renderer.setAnimationLoop(loop)
|
renderer.setAnimationLoop(loop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,23 +6,27 @@
|
|||||||
/* 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 02:06:24 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 15:29:51 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 { liveChat } from "/static/javascript/liveChat/main.js";
|
||||||
|
|
||||||
class HomePage
|
class HomePage
|
||||||
{
|
{
|
||||||
static create()
|
static create()
|
||||||
{
|
{
|
||||||
Home3D.create();
|
Home3D.create();
|
||||||
|
Login.create();
|
||||||
window.addEventListener('scroll', scrool);
|
window.addEventListener('scroll', scrool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static dispose()
|
static dispose()
|
||||||
{
|
{
|
||||||
Home3D.dispose();
|
Home3D.dispose();
|
||||||
|
Login.dispose();
|
||||||
window.addEventListener('scroll', scrool);
|
window.addEventListener('scroll', scrool);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,29 +6,46 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 17:40:15 by edbernar #+# #+# */
|
/* Created: 2024/08/07 17:40:15 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/24 23:42:45 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 17:14:01 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
||||||
import { userMeInfo, waitForLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
import { userMeInfo, waitForLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
||||||
|
import { sendRequest } from "/static/javascript/websocket.js";
|
||||||
function login()
|
class Login
|
||||||
|
{
|
||||||
|
static create()
|
||||||
{
|
{
|
||||||
const loginButton = document.getElementById('loginButton');
|
const loginButton = document.getElementById('loginButton');
|
||||||
const pLoginButton = loginButton.getElementsByTagName('p')[0];
|
const pLoginButton = loginButton.getElementsByTagName('p')[0];
|
||||||
|
const form = document.getElementById('loginForm');
|
||||||
let nodeText = null;
|
let nodeText = null;
|
||||||
|
|
||||||
// waitForLogin().then((token) => {
|
waitForLogin().then(() => {
|
||||||
// nodeText = document.createTextNode(userMeInfo.username);
|
if (userMeInfo.id !== -1)
|
||||||
// if (userMeInfo.id !== -1)
|
{
|
||||||
// {
|
nodeText = document.createTextNode(userMeInfo.username);
|
||||||
// loginButton.replaceChild(nodeText, pLoginButton);
|
loginButton.replaceChild(nodeText, pLoginButton);
|
||||||
// loginButton.addEventListener('click', showMenu);
|
// loginButton.addEventListener('click', showMenu);
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
|
{
|
||||||
loginButton.addEventListener('click', showLoginDiv);
|
loginButton.addEventListener('click', showLoginDiv);
|
||||||
// });
|
}
|
||||||
|
});
|
||||||
|
form.addEventListener('submit', connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
static dispose()
|
||||||
|
{
|
||||||
|
const loginButton = document.getElementById('loginButton');
|
||||||
|
const form = document.getElementById('loginForm');
|
||||||
|
|
||||||
|
loginButton.removeEventListener('click', showLoginDiv);
|
||||||
|
form.removeEventListener('submit', connect);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoginDiv()
|
function showLoginDiv()
|
||||||
@ -41,47 +58,28 @@ function showLoginDiv()
|
|||||||
popout.style.display = 'flex';
|
popout.style.display = 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMenu()
|
function connect(e)
|
||||||
{
|
{
|
||||||
const loginButton = document.getElementById('loginButton');
|
const loginButton = document.getElementById('loginButton');
|
||||||
const divMenu = document.createElement("div");
|
const pLoginButton = loginButton.getElementsByTagName('p')[0];
|
||||||
const ul = document.createElement("ul");
|
const popout = document.getElementById('loginPopup');
|
||||||
const li1 = document.createElement("li");
|
const mail = document.getElementById('email').value;
|
||||||
const li2 = document.createElement("li");
|
let usernameNode = null;
|
||||||
let already_activated = false;
|
|
||||||
|
|
||||||
divMenu.setAttribute("id", "menuDiv");
|
e.preventDefault();
|
||||||
li1.innerHTML = "Profile";
|
sendRequest("login", {type: "byPass", mail: mail, password: e.target.password.value});
|
||||||
li2.innerHTML = "Logout";
|
waitForLogin().then((isConnected) => {
|
||||||
li1.addEventListener('click', (e) => {
|
if (isConnected)
|
||||||
console.log("profile");
|
|
||||||
});
|
|
||||||
li2.addEventListener('click', (e) => {
|
|
||||||
document.cookie = "token=; path=/; Secure; SameSite=Strict; max-age=0";
|
|
||||||
window.location.href = "/";
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
ul.appendChild(li1);
|
|
||||||
ul.appendChild(li2);
|
|
||||||
divMenu.appendChild(ul);
|
|
||||||
divMenu.style.position = "absolute";
|
|
||||||
divMenu.style.width = loginButton.offsetWidth + "px";
|
|
||||||
divMenu.style.top = loginButton.offsetTop + loginButton.offsetHeight + "px";
|
|
||||||
divMenu.style.left = loginButton.offsetLeft + "px";
|
|
||||||
document.body.appendChild(divMenu);
|
|
||||||
loginButton.removeEventListener('click', showMenu);
|
|
||||||
loginButton.addEventListener('click', () => {
|
|
||||||
if (!already_activated)
|
|
||||||
{
|
{
|
||||||
setTimeout(() => {
|
usernameNode = document.createTextNode(userMeInfo.username);
|
||||||
document.getElementById("menuDiv").remove();
|
loginButton.replaceChild(usernameNode, pLoginButton);
|
||||||
loginButton.addEventListener('click', showMenu);
|
CN.new("Connected successfully", "Welcome " + userMeInfo.username, CN.defaultIcon.success);
|
||||||
already_activated = true;
|
popout.style.display = 'none';
|
||||||
}, 199);
|
|
||||||
document.getElementById("menuDiv").style.animation = "animHideMenuDiv 0.21s";
|
|
||||||
}
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
CN.new("Error", "An error occured while trying to connect", CN.defaultIcon.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { Login };
|
||||||
export { login, showLoginDiv, showMenu };
|
|
@ -6,19 +6,15 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/30 13:50:35 by edbernar #+# #+# */
|
/* Created: 2024/07/30 13:50:35 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/25 02:21:47 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 15:52:57 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
import { liveChat } from "/static/javascript/liveChat/main.js";
|
import * as Socket from '/static/javascript/websocket.js';
|
||||||
import { login } from "/static/javascript/login/main.js";
|
import { Page } from '/static/javascript/Page.js';
|
||||||
import { HomePage } from "/static/javascript/homePage/main.js"
|
|
||||||
|
let pageRenderer = null;
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
liveChat();
|
pageRenderer = new Page();
|
||||||
login();
|
|
||||||
HomePage.create();
|
|
||||||
setTimeout(() => {
|
|
||||||
HomePage.dispose();
|
|
||||||
}, 3000);
|
|
||||||
});
|
});
|
||||||
|
@ -6,15 +6,18 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 21:16:09 by edbernar #+# #+# */
|
/* Created: 2024/08/07 21:16:09 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/24 23:43:40 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 16:15:05 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
import { createNotification as NC } from "/static/javascript/notification/main.js";
|
import { createNotification as NC } from "/static/javascript/notification/main.js";
|
||||||
|
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
||||||
|
|
||||||
function typeErrorInvalidPassword()
|
function typeErrorInvalidPassword()
|
||||||
{
|
{
|
||||||
NC.new("Connection error", "Invalid mail or password", NC.defaultIcon.error);
|
NC.new("Connection error", "Invalid mail or password", NC.defaultIcon.error);
|
||||||
|
typeLogin(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { typeErrorInvalidPassword };
|
export { typeErrorInvalidPassword };
|
@ -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/07 22:14:49 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 17:09:22 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -30,19 +30,17 @@ function waitForLogin() {
|
|||||||
|
|
||||||
function typeLogin(content)
|
function typeLogin(content)
|
||||||
{
|
{
|
||||||
if (content != null)
|
if (content && typeof(content) != 'boolean' && content.status == true)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (content != null)
|
loginResolve(content);
|
||||||
loginResolve(content.token);
|
|
||||||
else
|
|
||||||
loginResolve();
|
|
||||||
loginResolve = null;
|
loginResolve = null;
|
||||||
loginAvailable = false;
|
loginAvailable = false;
|
||||||
}
|
}
|
||||||
|
@ -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/24 23:45:49 by edbernar ### ########.fr */
|
/* Updated: 2024/08/25 17:17:57 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,17 +18,10 @@ import { typeNewPrivateMessage } from "/static/javascript/typeResponse/typeNewPr
|
|||||||
import { typePrivateListUser } from "/static/javascript/typeResponse/typePrivateListUser.js";
|
import { typePrivateListUser } from "/static/javascript/typeResponse/typePrivateListUser.js";
|
||||||
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
||||||
|
|
||||||
/*
|
const socket = new WebSocket('/ws');
|
||||||
Todo (Eddy) :
|
|
||||||
- Request to connect by email and password. Waiting for the front to do it (already functional on the back side)
|
|
||||||
sendRequest("login", {type: "byPass", mail: "aa@aa.fr", password: "ABC123"});
|
|
||||||
- Information: the 'token' variable is only used until the connection is fully implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
const socket = new WebSocket('ws://localhost:8000/');
|
const typeResponse = ["logged_in", "login", "private_list_user", "private_list_message", "new_private_message"];
|
||||||
|
const functionResponse = [typeLogin, typeLogin, typePrivateListUser, typePrivateListMessage, typeNewPrivateMessage];
|
||||||
const typeResponse = ["login", "private_list_user", "private_list_message", "new_private_message"];
|
|
||||||
const functionResponse = [typeLogin, typePrivateListUser, typePrivateListMessage, typeNewPrivateMessage];
|
|
||||||
|
|
||||||
const errorCode = [9007, 9010, 9011];
|
const errorCode = [9007, 9010, 9011];
|
||||||
const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeErrorUnknown42Account];
|
const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeErrorUnknown42Account];
|
||||||
@ -54,10 +47,6 @@ socket.onopen = () => {
|
|||||||
|
|
||||||
status = 1;
|
status = 1;
|
||||||
console.log('Connected');
|
console.log('Connected');
|
||||||
if (token)
|
|
||||||
sendRequest("login", {type: "byToken", token: token});
|
|
||||||
else
|
|
||||||
typeLogin(null);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = (event) => {
|
socket.onmessage = (event) => {
|
||||||
@ -78,6 +67,7 @@ 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 {
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* home.css :+: :+: :+: */
|
/* home.css :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 12:00:55 by edbernar #+# #+# */
|
/* Created: 2024/08/07 12:00:55 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/24 11:26:27 by marvin ### ########.fr */
|
/* Updated: 2024/08/25 16:31:32 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ body {
|
|||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur(5px);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 1000;
|
z-index: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user