Site
- New way to manage profiles with url -> /profil/username Django - modification of the user info query
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/19 23:08:31 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/22 23:47:16 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/09/23 00:59:35 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,10 +16,11 @@ import { showPrivateChat } from "/static/javascript/liveChat/showPrivateChat.js"
|
||||
import { LiveChat, showChatMenu } from "/static/javascript/liveChat/main.js";
|
||||
import { userMeInfo } from "/static/javascript/typeResponse/typeLogin.js";
|
||||
import { sendRequest } from "/static/javascript/websocket.js";
|
||||
import { pageRenderer } from '/static/javascript/main.js'
|
||||
|
||||
class ProfilPage
|
||||
{
|
||||
static create(userId)
|
||||
static create(user)
|
||||
{
|
||||
const username = document.getElementsByTagName('h2')[0];
|
||||
const pfp = document.getElementsByClassName('profile-image')[0];
|
||||
@ -27,13 +28,20 @@ class ProfilPage
|
||||
const githubButton = document.getElementById('github');
|
||||
const discordButton = document.getElementById('discord');
|
||||
const convButton = document.getElementById('newConv');
|
||||
let usernameText = null;
|
||||
|
||||
LiveChat.create();
|
||||
|
||||
sendRequest("get_user_info", {id: userId});
|
||||
if (typeof(user) == 'string')
|
||||
sendRequest("get_user_info", {username: user});
|
||||
else
|
||||
sendRequest("get_user_info", {id: user});
|
||||
waitForUserInfo().then((userInfo) => {
|
||||
usernameText = userInfo.username;
|
||||
if (userInfo == null)
|
||||
{
|
||||
pageRenderer.changePage('homePage');
|
||||
return ;
|
||||
}
|
||||
if (typeof(user) != 'string')
|
||||
history.replaceState({}, document.title, window.location.pathname + '/' + userInfo.username);
|
||||
username.innerText = userInfo.username + ' (status not implemented)';
|
||||
pfp.style.backgroundImage = `url("${userInfo.pfp}")`
|
||||
pfp.style.backgroundSize = "cover";
|
||||
@ -41,21 +49,21 @@ class ProfilPage
|
||||
banner.style.backgroundImage = `url("${userInfo.banner}")`
|
||||
banner.style.backgroundSize = "cover";
|
||||
banner.style.backgroundRepeat = "no-repeat";
|
||||
if (userId == userMeInfo.id)
|
||||
if (userInfo.id == userMeInfo.id)
|
||||
{
|
||||
pfp.innerHTML = `<div id='editPenPfpBg'><img class='editPenPfp' src='/static/img/profilPage/editPen.png'/></div>`
|
||||
banner.innerHTML = `<img class='editPen' src='/static/img/profilPage/editPen.png'/>`
|
||||
}
|
||||
}
|
||||
if (userInfo.id != userMeInfo.id)
|
||||
{
|
||||
convButton.addEventListener('click', () => {
|
||||
showChatMenu();
|
||||
showPrivateChat({id: userInfo.id, name: userInfo.username});
|
||||
});
|
||||
}
|
||||
else
|
||||
convButton.remove();
|
||||
});
|
||||
if (userId != userMeInfo.id)
|
||||
{
|
||||
convButton.addEventListener('click', () => {
|
||||
showChatMenu();
|
||||
showPrivateChat({id: userId, name: usernameText});
|
||||
});
|
||||
}
|
||||
else
|
||||
convButton.remove();
|
||||
}
|
||||
|
||||
static dispose()
|
||||
|
Reference in New Issue
Block a user