2022-05-30 23:26:22 +02:00
|
|
|
var coll = document.getElementsByClassName("collapsible");
|
|
|
|
var i;
|
|
|
|
|
|
|
|
for (i = 0; i < coll.length; i++) {
|
2022-06-18 14:35:43 +02:00
|
|
|
coll[i].addEventListener("click", function () {
|
2022-05-30 23:26:22 +02:00
|
|
|
this.classList.toggle("active");
|
|
|
|
var content = this.nextElementSibling;
|
2022-06-18 14:35:43 +02:00
|
|
|
if (content.style.maxHeight) {
|
2022-05-30 23:26:22 +02:00
|
|
|
content.style.maxHeight = null;
|
|
|
|
} else {
|
|
|
|
content.style.maxHeight = content.scrollHeight + "px";
|
|
|
|
}
|
|
|
|
});
|
2022-06-18 14:35:43 +02:00
|
|
|
}
|
|
|
|
|
2022-06-19 10:11:28 +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-18 14:35:43 +02:00
|
|
|
|
|
|
|
function acceptPlayers(id) {
|
2022-06-19 10:11:28 +02:00
|
|
|
|
2022-06-19 09:34:23 +02:00
|
|
|
let idString = id.toString()
|
2022-06-19 10:11:28 +02:00
|
|
|
console.log(id)
|
2022-06-18 14:35:43 +02:00
|
|
|
const requestOptions = {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Authorization': ("Bearer " + localStorage.getItem("token"))
|
|
|
|
},
|
2022-06-19 09:34:23 +02:00
|
|
|
body: JSON.stringify({ title: idString })
|
2022-06-18 14:35:43 +02:00
|
|
|
};
|
|
|
|
fetch('https://dragonmaster.pl/inz_swag/registration/payedUsingCash', requestOptions)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => console.log("ok"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-19 09:34:23 +02:00
|
|
|
// // 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 =>
|
|
|
|
// `<div class="zapisani">${dataItem.userid} ${dataItem.paymenttype} ${dataItem.paymentstatus} ${dataItem.partner} <button id="paymentAccepted" onclick="acceptPlayers(${dataItem.id})">dopusc do turnieju</button> <span id="paymentCheck"><span> <br><div>`)
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
let fullUserName = null;
|
|
|
|
let fullPartnerName = null;
|
|
|
|
|
|
|
|
function testUser(userName, userSurname) {
|
|
|
|
fullUserName = userName + " " + userSurname
|
|
|
|
console.log(fullPartnerName)
|
|
|
|
const element = document.getElementById('a');
|
|
|
|
element.innerHTML = fullUserName + `<br>`
|
|
|
|
|
|
|
|
}
|
|
|
|
function testPartner(partnerName, partnerSurname) {
|
|
|
|
fullPartnerName = partnerName + " " + partnerSurname
|
|
|
|
console.log(fullUserName)
|
|
|
|
const element = document.getElementById('b');
|
|
|
|
element.innerHTML = fullPartnerName
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function registrationsGetSaverName(idUser) {
|
|
|
|
let userName = null;
|
|
|
|
let userSurname = null;
|
|
|
|
const element = document.getElementById('tournament8');
|
|
|
|
const headers = {
|
|
|
|
'Authorization': ("Bearer " + localStorage.getItem("token"))
|
|
|
|
};
|
|
|
|
fetch('https://dragonmaster.pl/inz/user/byId?id=' + idUser, { headers })
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
userName = data.name;
|
|
|
|
userSurname = data.surname;
|
|
|
|
testUser(userName, userSurname)
|
|
|
|
})
|
|
|
|
// .then(response => console.log({ userName, userSurname }))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function registrationsGetPartnerName(idPartner) {
|
|
|
|
let partnerName = null;
|
|
|
|
let partnerSurname = null;
|
|
|
|
const element = document.getElementById('tournament8');
|
|
|
|
const headers = {
|
|
|
|
'Authorization': ("Bearer " + localStorage.getItem("token"))
|
|
|
|
};
|
|
|
|
fetch('https://dragonmaster.pl/inz/user/byId?id=' + idPartner, { headers })
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
partnerName = data.name;
|
|
|
|
partnerSurname = data.surname;
|
|
|
|
testPartner(partnerName, partnerSurname)
|
|
|
|
})
|
|
|
|
// .then(response => ({ partnerName, partnerSurname }))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// // GET request using fetch with set headers
|
|
|
|
// function showNames(nameUser, surnameUser, namePartner, surnamePartner) {
|
|
|
|
// console.log(nameUser)
|
|
|
|
// console.log(nameUser)
|
|
|
|
// let id = localStorage.getItem('tournamentId');
|
|
|
|
// const element = document.getElementById('tournament8');
|
|
|
|
// element.innerHTML =
|
|
|
|
// `<div class="participant">
|
|
|
|
|
|
|
|
// <div class="partID">
|
|
|
|
// 1.
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
// <div class="partNames">
|
|
|
|
// ${nameUser} ${surnameUser} <br>
|
|
|
|
// ${namePartner} ${surnamePartner}
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
// <div class="partParameters">
|
|
|
|
// Dopuszczeni do turnieju
|
|
|
|
|
|
|
|
// <div class="pretty p-switch p-fill" style="margin-left: 5%">
|
|
|
|
// <input type="checkbox" />
|
|
|
|
// <div class="state p-success">
|
|
|
|
// <label></label>
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
// <br>
|
|
|
|
// Zapis opłacony
|
|
|
|
|
|
|
|
// <div class="pretty p-switch p-fill" style="margin-left: 5%">
|
|
|
|
// <input type="checkbox" />
|
|
|
|
// <div class="state p-success">
|
|
|
|
// <label></label>
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
// </div>
|
|
|
|
// </div>`
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
2022-06-18 14:35:43 +02:00
|
|
|
// GET request using fetch with set headers
|
2022-06-19 09:34:23 +02:00
|
|
|
function registrationsGetId() {
|
|
|
|
let idUser = null;
|
|
|
|
let idPartner = null;
|
|
|
|
let lala = null;
|
2022-06-18 14:35:43 +02:00
|
|
|
let id = localStorage.getItem('tournamentId');
|
|
|
|
const element = document.getElementById('tournament8');
|
|
|
|
const headers = {
|
|
|
|
'Authorization': ("Bearer " + localStorage.getItem("token"))
|
|
|
|
};
|
2022-06-19 09:34:23 +02:00
|
|
|
fetch('https://dragonmaster.pl/inz/registrations?id=' + id, { headers })
|
2022-06-18 14:35:43 +02:00
|
|
|
.then(response => response.json())
|
2022-06-19 09:34:23 +02:00
|
|
|
.then(data => data.map(dataItem => {
|
|
|
|
console.log(data)
|
|
|
|
idUser = `${dataItem.userid}`;
|
|
|
|
idPartner = `${dataItem.partner}`;
|
|
|
|
idSave = `${dataItem.id}`;
|
|
|
|
}))
|
|
|
|
.then(response => { registrationsGetSaverName(idUser); registrationsGetPartnerName(idPartner) })
|
2022-06-18 14:35:43 +02:00
|
|
|
}
|
|
|
|
|