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");
|
|
|
|
});
|
|
|
|
|
2022-06-09 01:54:13 +02:00
|
|
|
|
|
|
|
function register() {
|
|
|
|
fetch('https://dragonmaster.pl/inz/user/create', {
|
2022-06-10 00:56:06 +02:00
|
|
|
method: "PUT",
|
2022-06-09 01:54:13 +02:00
|
|
|
headers: {
|
|
|
|
'Content-type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.then(res => {
|
|
|
|
if (res.ok) {
|
|
|
|
alert("Teraz mozesz się zalogować!")
|
2022-06-10 00:56:06 +02:00
|
|
|
window.location.href = '../logowanie/index.html'
|
2022-06-09 01:54:13 +02:00
|
|
|
}
|
|
|
|
else { console.log("Coś poszło nie tak!") }
|
|
|
|
return res
|
|
|
|
})
|
|
|
|
.then(res => res.json())
|
|
|
|
.then(data => console.log(data))
|
|
|
|
.catch(error => console.log(error))
|
|
|
|
}
|