2022-05-30 20:17:26 +02:00
|
|
|
//Password toggle
|
2022-05-30 19:05:46 +02:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
|
|
|
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");
|
2022-05-30 19:05:46 +02:00
|
|
|
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 + '"}');
|
|
|
|
});
|