feat: Working ladder, updating tournamnet

This commit is contained in:
Arek 2022-06-19 22:40:31 +02:00
parent cf07de831e
commit 86556b76bb
12 changed files with 228 additions and 64 deletions

View File

@ -54,9 +54,7 @@ header {
.header-link {
text-align: center;
line-height: 2;
font-family: Montserrat, serif;
font-style: bold;
font-weight: bold;
font-size: 18px;
color: #828282;
@ -98,4 +96,56 @@ a:hover {
a:active {
text-decoration: none;
}
.ladderButtonFunctions {
/*Alignment*/
height: 50%;
float: right;
/*Button visual*/
background-color: #007C36;
border-radius: 15px;
border: 1px solid;
cursor: pointer;
/*Text visual*/
color: #ffffff;
font-family: Montserrat, serif;
font-size: 18px;
text-decoration: none;
}
.ladderButton {
/*Alignment*/
float: right;
/*Button visual*/
background-color: #007C36;
border-radius: 15px;
border: 1px solid;
cursor: pointer;
/*Text visual*/
color: #ffffff;
font-family: Montserrat, serif;
font-size: 13px;
text-decoration: none;
}
.players-on-ladder {
display: flex;
flex-direction: row;
font-size: 19px;
justify-content: space-around;
padding-bottom: 15px;
padding-right: 10px;
align-items: center;
}
.span-ladder {
display: flex;
justify-content: center;
height: auto;
}

View File

@ -14,7 +14,7 @@ for (i = 0; i < coll.length; i++) {
}
function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}

View File

@ -3,15 +3,9 @@ li.game {
margin-right: 20px;
}
li.game.winner {
font-weight: bold;
}
li.game.winner {}
/*Tekst wewnątrz boxa*/
li.game span {
float: right;
margin-right: 100px;
}
/*Górna linia drabinki*/
li.game-top {

View File

@ -11,7 +11,7 @@
</head>
<body onload="logoutVisibility(); loginVisibility();">
<body onload="logoutVisibility(); loginVisibility(); loadPlayers()">
<header>
<div class=" logoBox">
@ -302,25 +302,41 @@
<li class="spacer">&nbsp;</li>
<li class="game game-top teambox winner">
<input><br>
<input>
<span class="span-ladder" id="1">
<input id="1Input">
</span>
<span class="span-ladder" id="2">
<input id="2Input">
</span>
</li>
<li class="game game-spacer">&nbsp;</li>
<li class="game game-bottom teambox">
<input><br>
<input>
<span class="span-ladder" id="3">
<input id="3Input">
</span>
<span class="span-ladder" id="4">
<input id="4Input">
</span>
</li>
<li class="spacer">&nbsp;</li>
<li class="game game-top teambox">
<input><br>
<input>
<span class="span-ladder" id="5">
<input id="5Input">
</span>
<span class="span-ladder" id="6">
<input id="6Input">
</span>
</li>
<li class="game game-spacer">&nbsp;</li>
<li class="game game-bottom teambox winner">
<input><br>
<input>
<span class="span-ladder" id="7">
<input id="7Input">
</span>
<span class="span-ladder" id="8">
<input id="8Input">
</span>
</li>
<li class="spacer">&nbsp;</li>
@ -330,13 +346,21 @@
<li class="spacer">&nbsp;</li>
<li class="game game-top teambox winner">
<input><br>
<input>
<span class="span-ladder" id="9">
<input id="9Input">
</span>
<span class="span-ladder" id="10">
<input id="10Input">
</span>
</li>
<li class="game game-spacer">&nbsp;</li>
<li class="game game-bottom teambox">
<input><br>
<input>
<span class="span-ladder" id="11">
<input id="11Input">
</span>
<span class="span-ladder" id="12">
<input id="12Input">
</span>
</li>
<li class="spacer">&nbsp;</li>
@ -346,12 +370,17 @@
<li class="spacer">&nbsp;</li>
<li class="game game-top teambox winner">
<input><br>
<input>
<span class="span-ladder" id="13">
<input id="13Input">
</span>
<span class="span-ladder" id="14">
<input id="14Input">
</span>
</li>
<li class="spacer">&nbsp;</li>
</ul>
<button class="saver-button">zapisz</button>
<button class="ladderButtonFunctions" id="saver" onclick="getPlayers()">Zapisz</button>
<button class="ladderButtonFunctions" id="saver" onclick="usersRemover()">Usuń wszystkich</button>
</main>
</div>
@ -630,6 +659,7 @@
</div>
</div>
<script type="text/javascript" src="collapsible.js"></script>
<script type="text/javascript" src="ladder.js"></script>
</body>
</html>

View File

@ -0,0 +1,40 @@
function getPlayers() {
for (let i = 1; i < 15; i++) {
if (localStorage.getItem(i + "value") == null || localStorage.getItem(i + "value") == "") {
let input = document.getElementById(i + "Input");
localStorage.setItem(i + "value", input.value);
console.log(i + "getPlayersy")
}
}
location.reload()
}
function loadPlayers() {
for (let i = 0; i < 15; i++) {
if (localStorage.getItem(i + "value") == null || localStorage.getItem(i + "value") == "") {
console.log("Loading")
}
else {
document.getElementById(i).innerHTML = `<div class="players-on-ladder">` + localStorage.getItem(i + "value") + `<button class="ladderButton" onclick=playerDelete(id) id="` + i + `";>USUŃ</button></div>`;
}
}
}
function playerDelete(id) {
let i = id.toString()
console.log(i)
localStorage.setItem(i + "value", "")
location.reload()
}
function usersRemover() {
for (let i = 1; i < 15; i++) {
localStorage.removeItem(i + 'value');
}
location.reload()
}

View File

@ -14,7 +14,7 @@ for (i = 0; i < coll.length; i++) {
}
function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}

View File

@ -112,7 +112,7 @@ async function renderTournaments(organiserTournament) {
function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}

View File

@ -23,7 +23,7 @@
<a class="header_link" href="kontakt/index.html">Kontakt</a>
<a class="header_link" href="ranking/index.html">Ranking</a>
<a style="font-weight: bold" class="header_link" href="./index.html">Kalendarz turniejów</a>
<a class="header-link" href="./index.html">Kalendarz turniejów</a>
<a class="header_link" href="../panel_organizatora/dodawanie%20turnieju/index.html" id="creator">Tworzenie
turnieju</a>

View File

@ -7,7 +7,7 @@
<title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet">
<script>function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}
@ -31,10 +31,34 @@
document.getElementById("login").style.display = "";
}
}</script>
}
function checkRole() {
if (localStorage.getItem("token") !== null) {
fetch('https://dragonmaster.pl/inz/user', {
headers: {
Authorization: ("Bearer " + localStorage.getItem("token"))
}
})
.then(res => res.json())
.then(json => {
if (json['role'] == '1') {
document.getElementById("creator").style.display = "none";
}
else {
document.getElementById("creator").style.display = '';
}
})
}
else {
document.getElementById("creator").style.display = "none";
}
}
</script>
</head>
<body onload="logoutVisibility(); loginVisibility()">
<body onload="logoutVisibility(); loginVisibility(); checkRole();">
<header>
<div class="logoBox">
@ -49,6 +73,9 @@
<a class="header-link" href="#">Kontakt</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="../../panel_organizatora/dodawanie%20turnieju/index.html"
id="creator">Tworzenie
turnieju</a>
</div>
</header>

View File

@ -7,7 +7,7 @@
<title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet">
<script>function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}
@ -31,10 +31,34 @@
document.getElementById("login").style.display = "";
}
}
function checkRole() {
if (localStorage.getItem("token") !== null) {
fetch('https://dragonmaster.pl/inz/user', {
headers: {
Authorization: ("Bearer " + localStorage.getItem("token"))
}
})
.then(res => res.json())
.then(json => {
if (json['role'] == '1') {
document.getElementById("creator").style.display = "none";
}
else {
document.getElementById("creator").style.display = '';
}
})
}
else {
document.getElementById("creator").style.display = "none";
}
}</script>
</head>
<body onload="logoutVisibility(); loginVisibility()">
<body onload="logoutVisibility(); loginVisibility(); checkRole()">
<header>
<div class="logoBox">
<a class="header_link" href="../index.html"><img class="logo" src="../../_global/logo.svg"
@ -46,8 +70,11 @@
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</a>
<a class="header-link " href="#">Ranking</a>
<a class=" header_link" href="../index.html">Kalendarz turniejów</a>
<a class="header_link" href="../../panel_organizatora/dodawanie%20turnieju/index.html"
id="creator">Tworzenie
turnieju</a>
</div>
</header>

View File

@ -67,7 +67,7 @@ function createTournament() {
console.log(checker)
if (name == null || name == "", place == null || place == "", from == null || from == "", to == null || to == "", rang == null || rang == "", entryFee == null || entryFee == "", director == null || director == "", phone == null || phone == "", entriesTo == null || entriesTo == "", additionalInformations == null || additionalInformations == "", category == null || category == "") {
alert("Nie można utowrzyć turnieju! Proszę wypełnić wszystkie pola!")
alert("Nie można utworzyć turnieju! Proszę wypełnić wszystkie pola!")
}
else {
fetch('https://dragonmaster.pl/inz/tournament', {
@ -110,8 +110,8 @@ function createTournament() {
}
function logout() {
localStorage.clear();
location.reload();
localStorage.removeItem('token');
window.location.href = '../../normal_user/index.html'
}
function logoutVisibility() {

View File

@ -27,33 +27,29 @@
// '","category":"' + "cat1" +
// '","}');
// });
function checkCheckBox() {
let checkBox = document.getElementById("checkBox");
// function checkCheckBox() {
// let checkBox = document.getElementById("checkBox");
if (checkBox.checked == true) {
return ("TRUE")
}
else {
return ("FALSE")
}
}
// if (checkBox.checked == true) {
// return ("TRUE")
// }
// else {
// return ("FALSE")
// }
// }
function checkRankingBox() {
let checkBox = document.getElementById("checkBoxRanking");
// function checkRankingBox() {
// let checkBox = document.getElementById("checkBoxRanking");
if (checkBox.checked == true) {
return ("1")
}
else {
return ("0")
}
}
// if (checkBox.checked == true) {
// return ("1")
// }
// else {
// return ("0")
// }
// }
function createTournament() {
let rankingChecker = checkRankingBox();
console.log(rankingChecker)
let checker = checkCheckBox();
console.log(checker)
fetch('https://dragonmaster.pl/inz/tournament', {
method: "POST",
headers: {
@ -77,20 +73,20 @@ function createTournament() {
"entriesTo": document.getElementById("entries").value,
"additionalInformations": document.getElementById("add-info").value,
"categotry": document.getElementById("category").value,
"visibility": checker
"visibility": "TRUE"
}
)
}
)
.then(res => res.json())
.then(data => console.log(data))
.then(data => window.location.href = '../../index.html')
.catch(error => console.log(error))
}
function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}