var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function () { this.classList.toggle("active"); var content = this.nextElementSibling; 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 = ""; } } function acceptPlayers(id) { let idString = id.toString() console.log(id) const requestOptions = { method: 'POST', headers: { 'Authorization': ("Bearer " + localStorage.getItem("token")) }, body: JSON.stringify({ title: idString }) }; fetch('https://dragonmaster.pl/inz_swag/registration/payedUsingCash', requestOptions) .then(response => response.json()) .then(data => console.log("ok")); } // // GET request using fetch with set headers // function registrationsGet() { // let id = localStorage.getItem('tournamentId'); // const element = document.getElementById('tournament8'); // const headers = { // 'Authorization': ("Bearer " + localStorage.getItem("token")) // }; // fetch('https://dragonmaster.pl/inz/registrations' + '?id=' + id, { headers }) // .then(response => response.json()) // .then(data => element.innerHTML = data.map(dataItem => // `