Site
- fix bug with return and refresh on single page class
This commit is contained in:
@ -132,9 +132,19 @@ def err404(request):
|
|||||||
return(render(request, "err404.html"))
|
return(render(request, "err404.html"))
|
||||||
|
|
||||||
def pfp(request, str):
|
def pfp(request, str):
|
||||||
|
ret = None
|
||||||
|
try:
|
||||||
image_path = os.path.join('/var/www/djangoserver/pfp/', str)
|
image_path = os.path.join('/var/www/djangoserver/pfp/', str)
|
||||||
return FileResponse(open(image_path, 'rb'), content_type='image/png')
|
ret = FileResponse(open(image_path, 'rb'), content_type='image/png')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return ret
|
||||||
|
|
||||||
def banner(request, str):
|
def banner(request, str):
|
||||||
|
ret = None
|
||||||
|
try:
|
||||||
image_path = os.path.join('/var/www/djangoserver/banner/', str)
|
image_path = os.path.join('/var/www/djangoserver/banner/', str)
|
||||||
return FileResponse(open(image_path, 'rb'), content_type='image/png')
|
ret = FileResponse(open(image_path, 'rb'), content_type='image/png')
|
||||||
|
except Exception:
|
||||||
|
ret = FileResponse("banner not found", status=404)
|
||||||
|
return ret
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/23 00:59:54 by edbernar ### ########.fr */
|
/* Updated: 2024/09/25 15:47:22 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ import { HomePage } from "/static/javascript/homePage/main.js";
|
|||||||
class Page
|
class Page
|
||||||
{
|
{
|
||||||
actualPage = null;
|
actualPage = null;
|
||||||
|
wasRefresh = false;
|
||||||
availablePages = [
|
availablePages = [
|
||||||
{suffix: false, url:'/', servUrl: '/homePage', class: HomePage, name: 'homePage', title: 'METH - Home'},
|
{suffix: false, url:'/', servUrl: '/homePage', class: HomePage, name: 'homePage', title: 'METH - Home'},
|
||||||
{suffix: false, url:'/lobby', servUrl: '/lobbyPage', class: LobbyPage, name: 'lobbyPage', title: 'METH - Lobby'},
|
{suffix: false, url:'/lobby', servUrl: '/lobbyPage', class: LobbyPage, name: 'lobbyPage', title: 'METH - Lobby'},
|
||||||
@ -45,6 +46,7 @@ class Page
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.wasRefresh = (performance.getEntriesByType("navigation").length > 0 && performance.getEntriesByType("navigation")[0].type === "reload")
|
||||||
for (let i = 0; i < this.availablePages.length; i++)
|
for (let i = 0; i < this.availablePages.length; i++)
|
||||||
{
|
{
|
||||||
if (window.location.pathname == this.availablePages[i].url || (thisClass.availablePages[i].suffix && window.location.pathname.startsWith(thisClass.availablePages[i].url)))
|
if (window.location.pathname == this.availablePages[i].url || (thisClass.availablePages[i].suffix && window.location.pathname.startsWith(thisClass.availablePages[i].url)))
|
||||||
@ -80,13 +82,14 @@ class Page
|
|||||||
document.body.innerHTML = text;
|
document.body.innerHTML = text;
|
||||||
this.actualPage = this.availablePages[i].class;
|
this.actualPage = this.availablePages[i].class;
|
||||||
document.title = this.availablePages[i].title;
|
document.title = this.availablePages[i].title;
|
||||||
if (!isBack)
|
if (!isBack && !this.wasRefresh)
|
||||||
{
|
{
|
||||||
if (needToChangePath)
|
if (needToChangePath)
|
||||||
history.pushState({}, this.availablePages[i].title, this.availablePages[i].url);
|
history.pushState({}, this.availablePages[i].title, this.availablePages[i].url);
|
||||||
else
|
else
|
||||||
history.pushState({}, this.availablePages[i].title, window.location.pathname);
|
history.pushState({}, this.availablePages[i].title, window.location.pathname);
|
||||||
}
|
}
|
||||||
|
this.wasRefresh = false;
|
||||||
if (arg)
|
if (arg)
|
||||||
this.actualPage.create(arg);
|
this.actualPage.create(arg);
|
||||||
else
|
else
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/13 13:59:46 by edbernar #+# #+# */
|
/* Created: 2024/09/13 13:59:46 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/09/25 09:17:42 by edbernar ### ########.fr */
|
/* Updated: 2024/09/25 14:40:02 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -34,6 +34,8 @@ class barSelecter
|
|||||||
];
|
];
|
||||||
selected = lastSelected ? lastSelected : this.availableSkins[0];
|
selected = lastSelected ? lastSelected : this.availableSkins[0];
|
||||||
bar = this.createBarPlayer(this.selected.color ? this.selected.color : this.selected.texture);
|
bar = this.createBarPlayer(this.selected.color ? this.selected.color : this.selected.texture);
|
||||||
|
boundChangeSkin = this.changeSkin.bind(this);
|
||||||
|
|
||||||
|
|
||||||
constructor(div)
|
constructor(div)
|
||||||
{
|
{
|
||||||
@ -68,8 +70,8 @@ class barSelecter
|
|||||||
skins[i].style.backgroundColor = `#${this.availableSkins[i].color.toString(16)}`;
|
skins[i].style.backgroundColor = `#${this.availableSkins[i].color.toString(16)}`;
|
||||||
else
|
else
|
||||||
skins[i].style.backgroundImage = `url("${this.availableSkins[i].texture}")`
|
skins[i].style.backgroundImage = `url("${this.availableSkins[i].texture}")`
|
||||||
skins[i].removeEventListener('click', this.changeSkin.bind(this));
|
skins[i].removeEventListener('click', this.boundChangeSkin);
|
||||||
skins[i].addEventListener('click', this.changeSkin.bind(this));
|
skins[i].addEventListener('click', this.boundChangeSkin);
|
||||||
}
|
}
|
||||||
popup.removeEventListener('click', this.hideSkinSelector);
|
popup.removeEventListener('click', this.hideSkinSelector);
|
||||||
popup.addEventListener('click', this.hideSkinSelector);
|
popup.addEventListener('click', this.hideSkinSelector);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
|
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
|
||||||
/* Updated: 2024/09/25 09:05:07 by edbernar ### ########.fr */
|
/* Updated: 2024/09/25 15:37:29 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ class LobbyPage
|
|||||||
const usernameP = document.getElementById('loginButton').getElementsByTagName('p')[0];
|
const usernameP = document.getElementById('loginButton').getElementsByTagName('p')[0];
|
||||||
const loginButton = document.getElementById('loginButton');
|
const loginButton = document.getElementById('loginButton');
|
||||||
const inputUser = document.getElementById('searchInputUser');
|
const inputUser = document.getElementById('searchInputUser');
|
||||||
|
const func = [selectGameModeOne, selectGameModeTwo, selectGameModeThree, selectGameModeFour];
|
||||||
|
|
||||||
if (userMeInfo.id == -1)
|
if (userMeInfo.id == -1)
|
||||||
waitForLogin().then(() => usernameP.innerHTML = userMeInfo.username);
|
waitForLogin().then(() => usernameP.innerHTML = userMeInfo.username);
|
||||||
@ -59,6 +60,7 @@ class LobbyPage
|
|||||||
listSelectCard[1].addEventListener('click', selectGameModeTwo);
|
listSelectCard[1].addEventListener('click', selectGameModeTwo);
|
||||||
listSelectCard[2].addEventListener('click', selectGameModeThree);
|
listSelectCard[2].addEventListener('click', selectGameModeThree);
|
||||||
listSelectCard[3].addEventListener('click', selectGameModeFour);
|
listSelectCard[3].addEventListener('click', selectGameModeFour);
|
||||||
|
func[gameMode]();
|
||||||
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[gameMode].innerHTML;
|
document.getElementsByClassName('mode-card')[0].getElementsByTagName('p')[0].innerHTML = listSelectCard[gameMode].innerHTML;
|
||||||
for (let i = 0; i < document.body.children.length; i++)
|
for (let i = 0; i < document.body.children.length; i++)
|
||||||
{
|
{
|
||||||
@ -125,7 +127,7 @@ function ajustSearchUserList()
|
|||||||
|
|
||||||
function goBackHome()
|
function goBackHome()
|
||||||
{
|
{
|
||||||
pageRenderer.changePage('homePage');
|
pageRenderer.changePage('homePage', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startMode()
|
function startMode()
|
||||||
|
@ -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/09/21 22:59:04 by edbernar ### ########.fr */
|
/* Updated: 2024/09/25 15:22:28 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -101,7 +101,6 @@ class MultiOnlineGamePage
|
|||||||
scene.background = new THREE.Color(0x1a1a1a);
|
scene.background = new THREE.Color(0x1a1a1a);
|
||||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
document.body.appendChild(renderer.domElement);
|
document.body.appendChild(renderer.domElement);
|
||||||
ball.initMoveBallTmp();
|
|
||||||
map.ballObject = ball.object;
|
map.ballObject = ball.object;
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
Reference in New Issue
Block a user