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() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
@ -20,6 +37,7 @@ function loginVisibility() {
}
}
async function renderTournaments() {
let tournaments = await showTournaments();
let html = '';

View File

@ -2,13 +2,40 @@ var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
coll[i].addEventListener("click", function () {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
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>
<body>
<body onload="logoutVisibility(); loginVisibility();">
<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>
</div>
<div class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit"
onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
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="../../../ranking/index.html">Ranking</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>
</head>
<body onload="renderTournaments();loginVisibility();">
<body onload="renderTournaments();logoutVisibility(); loginVisibility();">
<header>
<div class="logoBox">
<a class="header_link" href="../../index.html"><img class="logo" src="../../../_global/logo.svg"
@ -18,8 +18,9 @@
</div>
<div class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit"
onclick="window.location.href='../../logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
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="../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../index.html">Kalendarz turniejów</a>

View File

@ -13,6 +13,32 @@ 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) {

View File

@ -11,17 +11,18 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css" />
</head>
<body onload="registrationsGetId()">
<body onload="registrationsGetId(); logoutVisibility(); loginVisibility();">
<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>
</div>
<div class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit"
onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
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="../../../ranking/index.html">Ranking</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">
<title>Padel Tournaments System</title>
<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>
<body>
<header>
<body onload="logoutVisibility(); loginVisibility()">
<header>
<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"
alt="Logo error"></a>
</div>
<div class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<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>
</header>
<div class="container">
Kontakt
</div>
<div class="container">
<h1>Strona w budowie</h1>
</div>
</body>
</html>

View File

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

View File

@ -6,26 +6,55 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Padel Tournaments System</title>
<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>
<body>
<header>
<body onload="logoutVisibility(); loginVisibility()">
<header>
<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"
alt="Logo error"></a>
</div>
<div class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
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="/index.html">Ranking</a>
<a class="header_link" href="../index.html">Kalendarz turniejów</a>
</div>
</header>
</header>
<div class="container">
Ranking
</div>
<div class="container">
<h1>Strona w budowie</h1>
</div>
</body>
</html>

View File

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