fix: 🚧 Logout in other pages

This commit is contained in:
Arek 2022-06-19 10:11:28 +02:00
parent fb6bb453c9
commit d095e80687
10 changed files with 184 additions and 50 deletions

View File

@ -10,6 +10,23 @@ async function showTournaments() {
} }
} }
function logout() {
localStorage.clear();
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
}
}
function loginVisibility() { function loginVisibility() {
if (localStorage.getItem("token") !== null) { if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none"; document.getElementById("login").style.display = "none";
@ -20,6 +37,7 @@ function loginVisibility() {
} }
} }
async function renderTournaments() { async function renderTournaments() {
let tournaments = await showTournaments(); let tournaments = await showTournaments();
let html = ''; let html = '';

View File

@ -2,13 +2,40 @@ var coll = document.getElementsByClassName("collapsible");
var i; var i;
for (i = 0; i < coll.length; i++) { for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() { coll[i].addEventListener("click", function () {
this.classList.toggle("active"); this.classList.toggle("active");
var content = this.nextElementSibling; var content = this.nextElementSibling;
if (content.style.maxHeight){ if (content.style.maxHeight) {
content.style.maxHeight = null; content.style.maxHeight = null;
} else { } else {
content.style.maxHeight = content.scrollHeight + "px"; content.style.maxHeight = content.scrollHeight + "px";
} }
}); });
}
function logout() {
localStorage.clear();
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
}
}
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
}
else {
document.getElementById("login").style.display = "";
}
} }

View File

@ -11,17 +11,18 @@
</head> </head>
<body> <body onload="logoutVisibility(); loginVisibility();">
<header> <header>
<div class="logoBox"> <div class=" logoBox">
<a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg" <a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg"
alt="Logo error"></a> alt="Logo error"></a>
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" <button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button> id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<a class="header_link" href="../../../kontakt/index.html">Kontakt</a> <a class="header_link" href="../../../kontakt/index.html">Kontakt</a>
<a class="header_link" href="../../../ranking/index.html">Ranking</a> <a class="header_link" href="../../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../../index.html">Kalendarz turniejów</a> <a class="header_link" href="../../../index.html">Kalendarz turniejów</a>

View File

@ -10,7 +10,7 @@
<script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app.js"></script>
</head> </head>
<body onload="renderTournaments();loginVisibility();"> <body onload="renderTournaments();logoutVisibility(); loginVisibility();">
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="../../index.html"><img class="logo" src="../../../_global/logo.svg" <a class="header_link" href="../../index.html"><img class="logo" src="../../../_global/logo.svg"
@ -18,8 +18,9 @@
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" <button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
onclick="window.location.href='../../logowanie/index.html'">LOGOWANIE</button> id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<a class="header_link" href="../../kontakt/index.html">Kontakt</a> <a class="header_link" href="../../kontakt/index.html">Kontakt</a>
<a class="header_link" href="../../ranking/index.html">Ranking</a> <a class="header_link" href="../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../index.html">Kalendarz turniejów</a> <a class="header_link" href="../../index.html">Kalendarz turniejów</a>

View File

@ -13,11 +13,37 @@ for (i = 0; i < coll.length; i++) {
}); });
} }
function logout() {
localStorage.clear();
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
}
}
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
}
else {
document.getElementById("login").style.display = "";
}
}
function acceptPlayers(id) { function acceptPlayers(id) {
let idString = id.toString() let idString = id.toString()
console.log(id) console.log(id)
const requestOptions = { const requestOptions = {
method: 'POST', method: 'POST',
headers: { headers: {

View File

@ -11,17 +11,18 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css" />
</head> </head>
<body onload="registrationsGetId()"> <body onload="registrationsGetId(); logoutVisibility(); loginVisibility();">
<header> <header>
<div class="logoBox"> <div class=" logoBox">
<a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg" <a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg"
alt="Logo error"></a> alt="Logo error"></a>
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" <button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button> id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<a class="header_link" href="../../../kontakt/index.html">Kontakt</a> <a class="header_link" href="../../../kontakt/index.html">Kontakt</a>
<a class="header_link" href="../../../ranking/index.html">Ranking</a> <a class="header_link" href="../../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../../index.html">Kalendarz turniejów</a> <a class="header_link" href="../../../index.html">Kalendarz turniejów</a>

View File

@ -6,26 +6,56 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Padel Tournaments System</title> <title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<script>function logout() {
localStorage.clear();
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
}
}
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
}
else {
document.getElementById("login").style.display = "";
}
}</script>
</head> </head>
<body> <body onload="logoutVisibility(); loginVisibility()">
<header>
<div class="logoBox"> <header>
<a class="header_link" href="../index.html"><img class="logo" src="../../_global/logo.svg" alt="Logo error"></a> <div class="logoBox">
</div> <a class="header_link" href="../index.html"><img class="logo" src="../../_global/logo.svg"
<div class="linkBox"> alt="Logo error"></a>
<!-- <span class="dot">JM</span>--> </div>
<button class="loginButton" type="submit" onclick="window.location.href='../logowanie/index.html'">LOGOWANIE</button> <div class="linkBox">
<a class="header_link" href="/index.html">Kontakt</a> <!-- <span class="dot">JM</span>-->
<a class="header_link" href="../ranking/index.html">Ranking</a> <button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
<a class="header_link" href="../index.html">Kalendarz turniejów</a> id="login">LOGOWANIE</button>
</div> <button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
</header> <a class="header_link" href="/index.html">Kontakt</a>
<a class="header_link" href="../ranking/index.html">Ranking</a>
<a class="header_link" href="../index.html">Kalendarz turniejów</a>
</div>
</header>
<div class="container"> <div class="container">
Kontakt <h1>Strona w budowie</h1>
</div> </div>
</body> </body>
</html> </html>

View File

@ -11,5 +11,5 @@ body {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center;
} }

View File

@ -6,26 +6,55 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Padel Tournaments System</title> <title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<script>function logout() {
localStorage.clear();
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
}
}
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
}
else {
document.getElementById("login").style.display = "";
}
}</script>
</head> </head>
<body> <body onload="logoutVisibility(); loginVisibility()">
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="../index.html"><img class="logo" src="../../_global/logo.svg" alt="Logo error"></a> <a class="header_link" href="../index.html"><img class="logo" src="../../_global/logo.svg"
</div> alt="Logo error"></a>
<div class="linkBox"> </div>
<!-- <span class="dot">JM</span>--> <div class="linkBox">
<button class="loginButton" type="submit" onclick="window.location.href='../logowanie/index.html'">LOGOWANIE</button> <!-- <span class="dot">JM</span>-->
<a class="header_link" href="../kontakt/index.html">Kontakt</a> <button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
<a class="header_link" href="/index.html">Ranking</a> id="login">LOGOWANIE</button>
<a class="header_link" href="../index.html">Kalendarz turniejów</a> <button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
</div> <a class="header_link" href="../kontakt/index.html">Kontakt</a>
</header> <a class="header_link" href="/index.html">Ranking</a>
<a class="header_link" href="../index.html">Kalendarz turniejów</a>
</div>
</header>
<div class="container"> <div class="container">
Ranking <h1>Strona w budowie</h1>
</div> </div>
</body> </body>
</html> </html>

View File

@ -11,5 +11,6 @@ body {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center;
} }