Site
- add function for open profil in home page - remove button newConv if own profile page - add message in page if we try to access to METH when we are already connected
This commit is contained in:
@ -12,7 +12,6 @@ class User(models.Model):
|
||||
github_link = models.CharField(max_length=1024, null=True, blank=True, default=None)
|
||||
discord_username = models.CharField(max_length=1024, null=True, blank=True, default=None)
|
||||
|
||||
|
||||
class Message(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
|
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* main.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
|
||||
/* Updated: 2024/09/22 18:58:55 by marvin ### ########.fr */
|
||||
/* Updated: 2024/09/22 23:43:07 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -243,7 +243,7 @@ function initButtonPopMenuLogin()
|
||||
|
||||
buttons[0].addEventListener('click', () => {
|
||||
pageRenderer.changePage('profilPage', false, userMeInfo.id);
|
||||
})
|
||||
});
|
||||
buttons[2].addEventListener('click', () => {
|
||||
window.location.replace('/logout');
|
||||
});
|
||||
|
@ -6,13 +6,14 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 17:40:15 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/18 21:51:14 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/22 23:44:49 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
||||
import { userMeInfo, waitForLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
||||
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
||||
import { sendRequest } from "/static/javascript/websocket.js";
|
||||
import { pageRenderer } from '/static/javascript/main.js'
|
||||
|
||||
class Login
|
||||
{
|
||||
@ -121,6 +122,9 @@ function initButtonPopMenuLogin()
|
||||
{
|
||||
const buttons = document.getElementById('popMenuLoginButton').getElementsByTagName('p');
|
||||
|
||||
buttons[0].addEventListener('click', () => {
|
||||
pageRenderer.changePage('profilPage', false, userMeInfo.id);
|
||||
});
|
||||
buttons[2].addEventListener('click', () => {
|
||||
window.location.replace('/logout');
|
||||
})
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/19 23:08:31 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/21 21:51:43 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/22 23:47:16 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -30,6 +30,7 @@ class ProfilPage
|
||||
let usernameText = null;
|
||||
|
||||
LiveChat.create();
|
||||
|
||||
sendRequest("get_user_info", {id: userId});
|
||||
waitForUserInfo().then((userInfo) => {
|
||||
usernameText = userInfo.username;
|
||||
@ -46,11 +47,16 @@ class ProfilPage
|
||||
banner.innerHTML = `<img class='editPen' src='/static/img/profilPage/editPen.png'/>`
|
||||
}
|
||||
});
|
||||
if (userId != userMeInfo.id)
|
||||
{
|
||||
convButton.addEventListener('click', () => {
|
||||
showChatMenu();
|
||||
showPrivateChat({id: userId, name: usernameText});
|
||||
});
|
||||
}
|
||||
else
|
||||
convButton.remove();
|
||||
}
|
||||
|
||||
static dispose()
|
||||
{
|
||||
|
@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* typeErrorConnectedElsewhere.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/22 23:33:18 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/22 23:42:49 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
function typeErrorConnectedElsewhere()
|
||||
{
|
||||
setTimeout(() => {
|
||||
document.body.style.color = 'white';
|
||||
document.body.style.textAlign = 'center';
|
||||
document.body.style.paddingTop = '10%';
|
||||
document.body.innerHTML = 'You are already connected somewhere...';
|
||||
}, 500);
|
||||
}
|
||||
|
||||
export { typeErrorConnectedElsewhere };
|
@ -6,10 +6,11 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/20 13:04:33 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/22 23:36:55 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import { typeErrorConnectedElsewhere } from "/static/javascript/typeErrorResponse/typeErrorConnectedElsewhere.js";
|
||||
import { typeErrorUnknown42Account } from "/static/javascript/typeErrorResponse/typeErrorUnknown42Account.js";
|
||||
import { typeErrorInvalidPassword } from "/static/javascript/typeErrorResponse/typeErrorInvalidPassword.js";
|
||||
import { typeErrorInvalidToken42 } from "/static/javascript/typeErrorResponse/typeErrorInvalidToken42.js";
|
||||
@ -30,13 +31,15 @@ let status = 0;
|
||||
|
||||
function launchSocket()
|
||||
{
|
||||
let lastError = 0;
|
||||
|
||||
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"];
|
||||
const functionResponse = [typeLogin, typeLogin, typePrivateListUser, typePrivateListMessage, typeNewPrivateMessage, typeAllListUser, typeCreateAccount, typeGame, typeSearchUser, typeUserInfo];
|
||||
|
||||
const errorCode = [9007, 9010, 9011];
|
||||
const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeErrorUnknown42Account];
|
||||
const errorCode = [9007, 9010, 9011, 9013];
|
||||
const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeErrorUnknown42Account, typeErrorConnectedElsewhere];
|
||||
|
||||
|
||||
socket.onopen = () => {
|
||||
@ -54,6 +57,7 @@ function launchSocket()
|
||||
}
|
||||
if (response.code >= 9000 && response.code <= 9999)
|
||||
{
|
||||
lastError = response.code;
|
||||
if (response.code >= 9014 && response.code <= 9025)
|
||||
{
|
||||
console.log(response);
|
||||
@ -84,9 +88,12 @@ function launchSocket()
|
||||
socket.onclose = () => {
|
||||
status = 0;
|
||||
console.log('Disconnected');
|
||||
if (lastError != 9013)
|
||||
{
|
||||
setTimeout(() => {
|
||||
launchSocket();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user