mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
110 lines
3.8 KiB
JavaScript
110 lines
3.8 KiB
JavaScript
function setUserCallback() {
|
|
userFormEMailElement.value = user["e-mail"];
|
|
userFormFirstNameElement.value = user["firstName"];
|
|
userFormLastNameElement.value = user["lastName"];
|
|
userFormNotificationsElement.checked = user["notifications"];
|
|
userFormPhoneElement.value = user["phone"];
|
|
M.updateTextFields();
|
|
|
|
userFormEMailElement.addEventListener("input", event => {
|
|
eMailChanged = (user["e-mail"] != userFormEMailElement.value) ? true : false;
|
|
evaluateUserForm();
|
|
});
|
|
userFormFirstNameElement.addEventListener("input", event => {
|
|
firstNameChanged = (user["firstName"] != userFormFirstNameElement.value) ? true : false;
|
|
evaluateUserForm();
|
|
});
|
|
userFormLastNameElement.addEventListener("input", event => {
|
|
lastNameChanged = (user["lastName"] != userFormLastNameElement.value) ? true : false;
|
|
evaluateUserForm();
|
|
});
|
|
userFormNotificationsElement.addEventListener("change", event => {
|
|
notificationsChanged = (user["notifications"] != userFormNotificationsElement.checked) ? true : false;
|
|
evaluateUserForm();
|
|
});
|
|
userFormPhoneElement.addEventListener("input", event => {
|
|
phoneChanged = (user["phone"] != userFormPhoneElement.value) ? true : false;
|
|
evaluateUserForm();
|
|
});
|
|
userFormResetElement.addEventListener("click", event => {
|
|
eMailChanged = false;
|
|
firstNameChanged = false;
|
|
lastNameChanged = false;
|
|
notificationsChanged = false;
|
|
phoneChanged = false;
|
|
userFormEMailElement.value = user["e-mail"];
|
|
userFormFirstNameElement.value = user["firstName"];
|
|
userFormLastNameElement.value = user["lastName"];
|
|
userFormNotificationsElement.checked = user["notifications"];
|
|
userFormPhoneElement.value = user["phone"];
|
|
evaluateUserForm();
|
|
});
|
|
userFormSubmitElement.addEventListener("click", event => {
|
|
if (eMailChanged) {
|
|
user["e-mail"] = userFormEMailElement.value;
|
|
eMailChanged = false;
|
|
}
|
|
if (firstNameChanged) {
|
|
user["firstName"] = userFormFirstNameElement.value;
|
|
firstNameChanged = false;
|
|
}
|
|
if (lastNameChanged) {
|
|
user["lastName"] = userFormLastNameElement.value;
|
|
lastNameChanged = false;
|
|
}
|
|
if (notificationsChanged) {
|
|
user["notifications"] = userFormNotificationsElement.checked;
|
|
notificationsChanged = false;
|
|
}
|
|
if (phoneChanged) {
|
|
user["phone"] = userFormPhoneElement.value;
|
|
phoneChanged = false;
|
|
}
|
|
localStorage.setItem("user", JSON.stringify(user));
|
|
M.toast({html: "Benutzerdaten wurden aktualisiert."});
|
|
evaluateUserForm();
|
|
});
|
|
}
|
|
|
|
|
|
function evaluateUserForm() {
|
|
var somethingChanged;
|
|
|
|
somethingChanged = eMailChanged || firstNameChanged || lastNameChanged || notificationsChanged || phoneChanged;
|
|
|
|
if (somethingChanged) {
|
|
userFormResetElement.classList.remove("disabled");
|
|
userFormSubmitElement.classList.remove("disabled");
|
|
} else {
|
|
userFormResetElement.classList.add("disabled");
|
|
userFormSubmitElement.classList.add("disabled");
|
|
}
|
|
}
|
|
|
|
|
|
var eMailChanged;
|
|
var firstNameChanged;
|
|
var lastNameChanged;
|
|
var notificationsChanged;
|
|
var phoneChanged;
|
|
var userFormEMailElement;
|
|
var userFormFirstNameElement;
|
|
var userFormLastNameElement;
|
|
var userFormNotificationsElement;
|
|
var userFormPhoneElement;
|
|
var userFormResetElement;
|
|
var userFormSubmitElement;
|
|
|
|
|
|
eMailChanged = false;
|
|
firstNameChanged = false;
|
|
lastNameChanged = false;
|
|
notificationsChanged = false;
|
|
phoneChanged = false;
|
|
userFormFirstNameElement = document.getElementById("user-form-first-name");
|
|
userFormLastNameElement = document.getElementById("user-form-last-name");
|
|
userFormEMailElement = document.getElementById("user-form-e-mail");
|
|
userFormNotificationsElement = document.getElementById("user-form-notifications");
|
|
userFormPhoneElement = document.getElementById("user-form-phone");
|
|
userFormResetElement = document.getElementById("user-form-reset");
|
|
userFormSubmitElement = document.getElementById("user-form-submit"); |