fix: 🚧 próba naprawa api

This commit is contained in:
Arek 2022-05-30 20:18:04 +02:00
parent 54b4b03d89
commit d1e589520d
2 changed files with 42 additions and 43 deletions

View File

@ -8,7 +8,6 @@
<title>Paddle tournament system</title> <title>Paddle tournament system</title>
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" />
<link rel="stylesheet" href="css/style.css" />
</head> </head>

View File

@ -16,48 +16,48 @@ form.addEventListener('submit', function (e) {
e.preventDefault(); e.preventDefault();
}); });
var token = ""; // var token = "";
document.getElementById("loginButton").addEventListener("click", function () { // // document.getElementById("loginButton").addEventListener("click", function () {
document.getElementById("login").style.display = "block"; // // document.getElementById("login").style.display = "block";
}); // // });
document.getElementById("regButton").addEventListener("click", function () { // // document.getElementById("regButton").addEventListener("click", function () {
document.getElementById("reg").style.display = "block"; // // document.getElementById("reg").style.display = "block";
}); // // });
document.getElementById("registrationButton").addEventListener("click", function () { // document.getElementById("registrationButton").addEventListener("click", function () {
document.getElementById("registration").style.display = "block"; // document.getElementById("registration").style.display = "block";
}); // });
document.getElementById("checkPaymentButton").addEventListener("click", function () { // document.getElementById("checkPaymentButton").addEventListener("click", function () {
document.getElementById("checkStatus").style.display = "block"; // document.getElementById("checkStatus").style.display = "block";
}); // });
var registartions = []; // var registartions = [];
document.getElementById("getRegistartionsButton").addEventListener("click", function () { // document.getElementById("getRegistartionsButton").addEventListener("click", function () {
document.getElementById("getRegistartions").style.display = "block"; // document.getElementById("getRegistartions").style.display = "block";
}); // });
document.getElementById("getUserDataButton").addEventListener("click", function () { // document.getElementById("getUserDataButton").addEventListener("click", function () {
var xhttp = new XMLHttpRequest(); // var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () { // xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) { // if (this.readyState == 4 && this.status == 200) {
var json = JSON.parse(this.response); // var json = JSON.parse(this.response);
document.getElementById("getUserDataid").innerText = json.id; // document.getElementById("getUserDataid").innerText = json.id;
document.getElementById("getUserDataname").innerText = json.name; // document.getElementById("getUserDataname").innerText = json.name;
document.getElementById("getUserDatasurname").innerText = json.surname; // document.getElementById("getUserDatasurname").innerText = json.surname;
document.getElementById("getUserDatarole").innerText = json.role; // document.getElementById("getUserDatarole").innerText = json.role;
document.getElementById("getUserDatalogin").innerText = json.login; // document.getElementById("getUserDatalogin").innerText = json.login;
document.getElementById("getUserDataphone").innerText = json.phone; // document.getElementById("getUserDataphone").innerText = json.phone;
document.getElementById("getUserDatamail").innerText = json.mail; // document.getElementById("getUserDatamail").innerText = json.mail;
document.getElementById("getUserData").style.display = "block"; // document.getElementById("getUserData").style.display = "block";
} else if (this.readyState == 4) { // } else if (this.readyState == 4) {
alert("something not work :( " + this.status); // alert("something not work :( " + this.status);
} // }
} // }
xhttp.open("GET", "dragonmaster.pl//inz/user"); // xhttp.open("GET", "dragonmaster.pl/inz/user");
xhttp.setRequestHeader("Authorization", "Bearer " + token); // xhttp.setRequestHeader("Authorization", "Bearer " + token);
xhttp.send(); // xhttp.send();
}); // });
document.getElementById("updateUserDataButton").addEventListener("click", function () { // document.getElementById("updateUserDataButton").addEventListener("click", function () {
document.getElementById("updateUserData").style.display = "block"; // document.getElementById("updateUserData").style.display = "block";
}); // });
document.getElementById("regsubmit").addEventListener("click", function () { document.getElementById("regsubmit").addEventListener("click", function () {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () { xhttp.onreadystatechange = function () {
@ -67,6 +67,6 @@ document.getElementById("regsubmit").addEventListener("click", function () {
alert("something not work :( " + this.status); alert("something not work :( " + this.status);
} }
} }
xhttp.open("PUT", "dragonmaster.pl//inz/user/create"); xhttp.open("PUT", "https://dragonmaster.pl/inz/user/create");
xhttp.send('{"username":"' + document.getElementById("regusername").value + '","name":"' + document.getElementById("regname").value + '","surname":"' + document.getElementById("regsurname").value + '","password":"' + document.getElementById("regpassword").value + '","mail":"' + document.getElementById("regmail").value + '","phone":"' + document.getElementById("regphone").value + '"}'); xhttp.send('{"username":"' + document.getElementById("regusername").value + '","name":"' + document.getElementById("regname").value + '","surname":"' + document.getElementById("regsurname").value + '","password":"' + document.getElementById("regpassword").value + '","mail":"' + document.getElementById("regmail").value + '","phone":"' + document.getElementById("regphone").value + '"}');
}); });