Padel-Tournaments-System/frontend/rejestracja/myscript.js

81 lines
3.8 KiB
JavaScript
Raw Normal View History

2022-05-30 20:17:26 +02:00
//Password toggle
const togglePassword = document.querySelector("#togglePassword");
const password = document.querySelector("#regpassword");
togglePassword.addEventListener("click", function () {
// toggle the type attribute
const type = password.getAttribute("type") === "password" ? "text" : "password";
password.setAttribute("type", type);
// toggle the icon
this.classList.toggle("bi-eye");
});
// prevent form submit
const form = document.querySelector("form");
form.addEventListener('submit', function (e) {
e.preventDefault();
});
<<<<<<< HEAD
2022-05-30 20:18:04 +02:00
// var token = "";
// // document.getElementById("loginButton").addEventListener("click", function () {
// // document.getElementById("login").style.display = "block";
// // });
=======
2022-05-30 20:17:26 +02:00
//REST API
var token = "";
document.getElementById("loginButton").addEventListener("click", function () {
document.getElementById("login").style.display = "block";
});
>>>>>>> b44b5f1fc14af7c8da4ca602072af953974b49af
2022-05-30 20:18:04 +02:00
// // document.getElementById("regButton").addEventListener("click", function () {
// // document.getElementById("reg").style.display = "block";
// // });
// document.getElementById("registrationButton").addEventListener("click", function () {
// document.getElementById("registration").style.display = "block";
// });
// document.getElementById("checkPaymentButton").addEventListener("click", function () {
// document.getElementById("checkStatus").style.display = "block";
// });
// var registartions = [];
// document.getElementById("getRegistartionsButton").addEventListener("click", function () {
// document.getElementById("getRegistartions").style.display = "block";
// });
// document.getElementById("getUserDataButton").addEventListener("click", function () {
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function () {
// if (this.readyState == 4 && this.status == 200) {
// var json = JSON.parse(this.response);
// document.getElementById("getUserDataid").innerText = json.id;
// document.getElementById("getUserDataname").innerText = json.name;
// document.getElementById("getUserDatasurname").innerText = json.surname;
// document.getElementById("getUserDatarole").innerText = json.role;
// document.getElementById("getUserDatalogin").innerText = json.login;
// document.getElementById("getUserDataphone").innerText = json.phone;
// document.getElementById("getUserDatamail").innerText = json.mail;
// document.getElementById("getUserData").style.display = "block";
// } else if (this.readyState == 4) {
// alert("something not work :( " + this.status);
// }
// }
// xhttp.open("GET", "dragonmaster.pl/inz/user");
// xhttp.setRequestHeader("Authorization", "Bearer " + token);
// xhttp.send();
// });
// document.getElementById("updateUserDataButton").addEventListener("click", function () {
// document.getElementById("updateUserData").style.display = "block";
// });
document.getElementById("regsubmit").addEventListener("click", function () {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
alert("200 now you can login");
} else if (this.readyState == 4) {
alert("something not work :( " + this.status);
}
}
2022-05-30 20:18:04 +02:00
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 + '"}');
});