- add status on profil page
This commit is contained in:
Kum1ta
2024-09-23 15:02:23 +02:00
parent b88488e941
commit cb2a67c40d
2 changed files with 9 additions and 4 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/20 00:16:57 by edbernar #+# #+# #
# Updated: 2024/09/23 00:47:12 by edbernar ### ########.fr #
# Updated: 2024/09/23 14:37:28 by edbernar ### ########.fr #
# #
# **************************************************************************** #
@ -26,6 +26,8 @@ def getUserInfo(socket, content):
if (not user):
socket.sync_send({"type":"user_info", "content": None})
return
socket.sync_send({"type":"user_info", "content":{'username': user['username'], 'pfp': user['pfp'], 'banner': user['banner'], 'id': user['id']}})
online = True if user['id'] in socket.onlinePlayers else False
print("User is online: ", online)
socket.sync_send({"type":"user_info", "content":{'username': user['username'], 'pfp': user['pfp'], 'banner': user['banner'], 'id': user['id'], 'online': online}})
except Exception as e:
socket.sendError("invalid request", 9005, e)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 23:08:31 by edbernar #+# #+# */
/* Updated: 2024/09/23 00:59:35 by edbernar ### ########.fr */
/* Updated: 2024/09/23 15:00:23 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,6 +35,7 @@ class ProfilPage
else
sendRequest("get_user_info", {id: user});
waitForUserInfo().then((userInfo) => {
console.log(userInfo);
if (userInfo == null)
{
pageRenderer.changePage('homePage');
@ -42,7 +43,9 @@ class ProfilPage
}
if (typeof(user) != 'string')
history.replaceState({}, document.title, window.location.pathname + '/' + userInfo.username);
username.innerText = userInfo.username + ' (status not implemented)';
username.innerHTML = userInfo.username + '<span class="online-status"></span>';
if (!userInfo.online)
document.getElementsByClassName('online-status')[0].style.backgroundColor = '#E74040';
pfp.style.backgroundImage = `url("${userInfo.pfp}")`
pfp.style.backgroundSize = "cover";
pfp.style.backgroundRepeat = "no-repeat";