Site/Django
- Moving forward on the settings
This commit is contained in:
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* Map.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
||||
/* Updated: 2024/09/25 18:28:18 by hubourge ### ########.fr */
|
||||
/* Updated: 2024/09/25 22:19:13 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -998,7 +998,7 @@ class Map
|
||||
|
||||
this.updateScore(name, this.score);
|
||||
player.reserCameraPlayer();
|
||||
ball.resetScaleBall();
|
||||
ball.resetPosBall();
|
||||
// player.resetPosPlayer();
|
||||
// opponent.resetPosOpponent();
|
||||
};
|
||||
|
@ -6,15 +6,58 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/25 17:00:35 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/25 17:01:06 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/26 01:02:31 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import { waitForPrivateInfo } from "/static/javascript/typeResponse/typePrivateInfo.js"
|
||||
import { sendRequest, status } from "/static/javascript/websocket.js";
|
||||
|
||||
class settingsPage
|
||||
{
|
||||
static create()
|
||||
{
|
||||
const emailInput = document.getElementById('email');
|
||||
const discordInput = document.getElementById('discord');
|
||||
const usernameInput = document.getElementById('username');
|
||||
const passwordInput = document.getElementById('password');
|
||||
const newPasswordInput = document.getElementById('new-password');
|
||||
const confirmOasswordInput = document.getElementById('confirm-password');
|
||||
|
||||
const usernameSaveButton = document.getElementById('usernameButtonSave');
|
||||
const discordSaveButton = document.getElementById('discordButtonSave');
|
||||
|
||||
let interval = null;
|
||||
|
||||
emailInput.disabled = true;
|
||||
emailInput.style.backgroundColor = "#bbbbbb";
|
||||
interval = setInterval(() => {
|
||||
if (status)
|
||||
{
|
||||
sendRequest("get_private_info", {});
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 200);
|
||||
waitForPrivateInfo().then(data => {
|
||||
console.log(data);
|
||||
emailInput.value = data.mail ? data.mail : "Disabled because you have a 42 account."
|
||||
passwordInput.value = newPasswordInput.value = confirmOasswordInput.value = data.is42Account ? "Disabled because you have a 42 account." : null;
|
||||
if (data.is42Account)
|
||||
{
|
||||
passwordInput.style.backgroundColor = newPasswordInput.style.backgroundColor = confirmOasswordInput.style.backgroundColor = "#bbbbbb";
|
||||
passwordInput.type = newPasswordInput.type = confirmOasswordInput.type = 'text';
|
||||
}
|
||||
discordInput.value = data.discord_username;
|
||||
usernameInput.value = data.username;
|
||||
|
||||
usernameSaveButton.addEventListener('click', () => {
|
||||
sendRequest("change_private_info", {username: usernameInput.value});
|
||||
});
|
||||
discordSaveButton.addEventListener('click', () => {
|
||||
sendRequest("change_private_info", {discord: discordInput.value});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static dispose()
|
||||
|
@ -0,0 +1,42 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* typePrivateInfo.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/25 22:34:46 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/25 23:07:41 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
let PrivateInfo = {};
|
||||
let PrivateInfoAvailable = false;
|
||||
let PrivateInfoResolve = null;
|
||||
|
||||
function waitForPrivateInfo()
|
||||
{
|
||||
return new Promise((resolve) => {
|
||||
if (PrivateInfoAvailable)
|
||||
{
|
||||
PrivateInfoAvailable = false;
|
||||
resolve(PrivateInfo);
|
||||
}
|
||||
else
|
||||
PrivateInfoResolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
function typePrivateInfo(data)
|
||||
{
|
||||
PrivateInfo = data;
|
||||
PrivateInfoAvailable = true;
|
||||
if (PrivateInfoResolve)
|
||||
{
|
||||
PrivateInfoResolve(PrivateInfo);
|
||||
PrivateInfoResolve = null;
|
||||
PrivateInfoAvailable = false;
|
||||
}
|
||||
}
|
||||
|
||||
export { typePrivateInfo, waitForPrivateInfo };
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/24 15:55:37 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/26 00:59:46 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -19,6 +19,7 @@ import { typeNewPrivateMessage } from "/static/javascript/typeResponse/typeNewPr
|
||||
import { typePrivateListUser } from "/static/javascript/typeResponse/typePrivateListUser.js";
|
||||
import { typeCreateAccount } from "/static/javascript/typeResponse/typeCreateAccount.js";
|
||||
import { typeAllListUser }from "/static/javascript/typeResponse/typeAllListUser.js";
|
||||
import { typePrivateInfo } from "/static/javascript/typeResponse/typePrivateInfo.js"
|
||||
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
||||
import { typeSearchUser } from "/static/javascript/typeResponse/typeSearchUser.js";
|
||||
import { typeChangePfp } from "/static/javascript/typeResponse/typeChangePfp.js";
|
||||
@ -36,8 +37,8 @@ function launchSocket()
|
||||
|
||||
socket = new WebSocket('/ws');
|
||||
|
||||
const typeResponse = ["logged_in", "login", "private_list_user", "private_list_message", "new_private_message", "all_list_user", "create_account", "game", "search_user", "user_info", "change_pfp"];
|
||||
const functionResponse = [typeLogin, typeLogin, typePrivateListUser, typePrivateListMessage, typeNewPrivateMessage, typeAllListUser, typeCreateAccount, typeGame, typeSearchUser, typeUserInfo, typeChangePfp];
|
||||
const typeResponse = ["logged_in", "login", "private_list_user", "private_list_message", "new_private_message", "all_list_user", "create_account", "game", "search_user", "user_info", "change_pfp", "private_info"];
|
||||
const functionResponse = [typeLogin, typeLogin, typePrivateListUser, typePrivateListMessage, typeNewPrivateMessage, typeAllListUser, typeCreateAccount, typeGame, typeSearchUser, typeUserInfo, typeChangePfp, typePrivateInfo];
|
||||
|
||||
const errorCode = [9007, 9010, 9011, 9013];
|
||||
const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeErrorUnknown42Account, typeErrorConnectedElsewhere];
|
||||
@ -116,4 +117,4 @@ function sendRequest(type, content) {
|
||||
}));
|
||||
}
|
||||
|
||||
export { socket, sendRequest, launchSocket };
|
||||
export { socket, sendRequest, launchSocket, status };
|
Reference in New Issue
Block a user