- quit vr when game finish
Site
    - fix xss on live chat
This commit is contained in:
Kum1ta
2024-10-08 03:20:26 +02:00
parent 44dcafcc2f
commit 5fb0870c95
4 changed files with 20 additions and 20 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */ /* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
/* Updated: 2024/10/06 16:04:20 by edbernar ### ########.fr */ /* Updated: 2024/10/08 03:10:55 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -185,6 +185,10 @@ class MultiOnlineGamePage
static dispose() static dispose()
{ {
const session = renderer.xr.getSession();
if (session)
session.end();
observer.disconnect(); observer.disconnect();
VrButton = null; VrButton = null;
window.removeEventListener('resize', windowUpdater); window.removeEventListener('resize', windowUpdater);
@ -253,6 +257,8 @@ class MultiOnlineGamePage
let intervalEnd = null; let intervalEnd = null;
let time = 4; let time = 4;
if (renderer && renderer.xr && renderer.xr.getSession())
renderer.xr.getSession().end();
if (!map) if (!map)
return ; return ;
if (map && map.score) if (map && map.score)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/15 12:00:01 by edbernar #+# #+# */ /* Created: 2024/09/15 12:00:01 by edbernar #+# #+# */
/* Updated: 2024/10/06 15:32:02 by edbernar ### ########.fr */ /* Updated: 2024/10/08 03:07:37 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,20 +14,10 @@ import { MultiOnlineGamePage, opponent, ball, player, map } from "/static/javasc
import { WaitingGamePage } from "/static/javascript/waitingGame/main.js" import { WaitingGamePage } from "/static/javascript/waitingGame/main.js"
import { pageRenderer } from '/static/javascript/main.js' import { pageRenderer } from '/static/javascript/main.js'
let stopSrvUpdate = false
document.addEventListener('keypress',(e)=>{
if(e.key == 'q')
{
console.log("stopped server updates")
stopSrvUpdate = true
}
});
function typeGame(content) function typeGame(content)
{ {
if(stopSrvUpdate) console.log(`New game ${content.action} content: `, content);
return
if (pageRenderer.actualPage == WaitingGamePage) if (pageRenderer.actualPage == WaitingGamePage)
{ {
if (content.action == 1) if (content.action == 1)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 15:15:49 by edbernar #+# #+# */ /* Created: 2024/08/04 15:15:49 by edbernar #+# #+# */
/* Updated: 2024/09/29 14:11:26 by edbernar ### ########.fr */ /* Updated: 2024/10/08 02:53:30 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,15 +24,18 @@ function typeNewPrivateMessage(content)
if (infoPanel.isOpen && infoPanel.id === content.channel) if (infoPanel.isOpen && infoPanel.id === content.channel)
{ {
const div = document.createElement('div');
if (content.from != userMeInfo.id) if (content.from != userMeInfo.id)
sendRequest("read_message", {id: content.from}); sendRequest("read_message", {id: content.from});
messageList.push(content); messageList.push(content);
infoPanel.divMessage.insertAdjacentHTML('beforeend', ` div.className = content.from === userMeInfo.id ? "meMessage" : "opponentMessage";
<div class="${content.from === userMeInfo.id ? "meMessage" : "opponentMessage"}"> div.innerHTML = `
<p class="content">${content.content}</p> <p class="content"></p>
<p class="time">${content.date}</p> <p class="time">${content.date}</p>
</div> `;
`); div.getElementsByClassName('content')[0].innerText = content.content;
infoPanel.divMessage.appendChild(div);
infoPanel.divMessage.scrollTop = infoPanel.divMessage.scrollHeight; infoPanel.divMessage.scrollTop = infoPanel.divMessage.scrollHeight;
} }
else if (content.from != userMeInfo.id) else if (content.from != userMeInfo.id)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */ /* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
/* Updated: 2024/10/01 13:30:48 by edbernar ### ########.fr */ /* Updated: 2024/10/08 03:12:29 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -110,6 +110,7 @@ function sendRequest(type, content) {
console.warn('Not connected'); console.warn('Not connected');
return ; return ;
} }
console.log(`Send request ${type} content: `, content);
if (content instanceof Object) if (content instanceof Object)
coc = JSON.stringify(content); coc = JSON.stringify(content);
else else