Files
METH_Transcendence/docker-compose/requirements/nginx/static/javascript/liveChat/main.js
Kum1ta 24fe748130 Site
- on popup chat, point on end line for see if you have seen the last message
    - on chat buttton, red point for know if you have a new message
    - fix image in live chat
2024-09-29 03:52:10 +02:00

63 lines
2.2 KiB
JavaScript

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */
/* Updated: 2024/09/29 03:43:31 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { userListUnread } from "/static/javascript/typeResponse/typePrivateListUser.js";
import { infoPanel } from "/static/javascript/typeResponse/typePrivateListMessage.js";
import { showListUser } from "/static/javascript/liveChat/showUserList.js";
import { userMeInfo } from "/static/javascript/typeResponse/typeLogin.js";
let chatButton = null;
let topChatHomeCross = null;
class LiveChat
{
static create()
{
chatButton = document.getElementById("chatButton");
topChatHomeCross = document.getElementById("topChatCross");
chatButton.addEventListener("click", showChatMenu);
topChatHomeCross.addEventListener("click", hideChatMenu);
}
static dispose()
{
chatButton.removeEventListener("click", showChatMenu);
topChatHomeCross.removeEventListener("click", hideChatMenu);
chatButton = null;
topChatHomeCross = null;
}
}
function showChatMenu()
{
const infoChat = document.getElementById("infoChat");
chatDiv.style.display = "flex";
if (userMeInfo.id !== -1)
showListUser();
}
function hideChatMenu()
{
const notifBadgeChat = document.getElementsByClassName('notification-badge')[0];
chatDiv.style.display = "none";
infoPanel.isOpen = false;
if (!userListUnread.length)
notifBadgeChat.style.display = 'none';
else
notifBadgeChat.style.display = 'flex';
}
export { LiveChat, showChatMenu };