2022-06-08 22:33:19 +02:00
|
|
|
async function showTournaments() {
|
|
|
|
let url = 'https://dragonmaster.pl/inz/tournaments';
|
|
|
|
try {
|
|
|
|
let res = await fetch(url);
|
|
|
|
return await res.json();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function renderTournaments() {
|
|
|
|
let tournaments = await showTournaments();
|
|
|
|
let html = '';
|
2022-06-10 15:33:05 +02:00
|
|
|
console.log(tournaments[1])
|
2022-06-08 22:33:19 +02:00
|
|
|
tournaments.forEach(tournament => {
|
2022-06-10 12:23:44 +02:00
|
|
|
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html';loca">
|
2022-06-08 22:33:19 +02:00
|
|
|
<div class="tournamentIconBox">
|
|
|
|
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
|
|
|
|
</div>
|
|
|
|
<div class="tournamentDataBox">
|
|
|
|
<div class="tournamentData">
|
|
|
|
<h4>${tournament.name}</h4>
|
2022-06-10 12:23:44 +02:00
|
|
|
${tournament.place}
|
2022-06-08 22:33:19 +02:00
|
|
|
${tournament.from} do ${tournament.to}
|
|
|
|
<button class="tournamentOpen">OPEN</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
html += htmlSegment;
|
|
|
|
});
|
|
|
|
|
|
|
|
let container = document.querySelector('.tournament-list');
|
|
|
|
container.innerHTML = html;
|
|
|
|
}
|
2022-06-10 12:23:44 +02:00
|
|
|
|
|
|
|
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 = "";
|
|
|
|
|
2022-06-10 15:33:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createVisibility() {
|
|
|
|
if (localStorage.getItem("token") !== null) {
|
|
|
|
document.getElementById("creator").style.display = "none";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById("creator").style.display = "";
|
|
|
|
|
2022-06-10 12:23:44 +02:00
|
|
|
}
|
|
|
|
}
|