|
|
@ -1,5 +1,6 @@
|
|
|
|
let inputField = document.getElementById("field-username");
|
|
|
|
let regiterFields = document.getElementById("field-username");
|
|
|
|
let inputForm = document.getElementById("form");
|
|
|
|
let inputFields = document.getElementsByClassName("field");
|
|
|
|
|
|
|
|
let registerForm = document.getElementById("form");
|
|
|
|
let submitButton = document.getElementById("button-submit");
|
|
|
|
let submitButton = document.getElementById("button-submit");
|
|
|
|
let message = document.getElementById("message");
|
|
|
|
let message = document.getElementById("message");
|
|
|
|
let tabLinkButtons = document.getElementsByClassName("tablinks");
|
|
|
|
let tabLinkButtons = document.getElementsByClassName("tablinks");
|
|
|
@ -23,12 +24,17 @@ let showMessage = function(messageText) {
|
|
|
|
message.innerHTML = messageText;
|
|
|
|
message.innerHTML = messageText;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let hideMessage = function() {
|
|
|
|
|
|
|
|
// Hide the message text
|
|
|
|
|
|
|
|
message.classList.add("hidden");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let onResponse = function(response, success) {
|
|
|
|
let onResponse = function(response, success) {
|
|
|
|
// Display message
|
|
|
|
// Display message
|
|
|
|
showMessage(response);
|
|
|
|
showMessage(response);
|
|
|
|
|
|
|
|
|
|
|
|
if(success) {
|
|
|
|
if(success) {
|
|
|
|
inputForm.submit();
|
|
|
|
registerForm.submit();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -97,24 +103,26 @@ let clickSubmit = function() {
|
|
|
|
|
|
|
|
|
|
|
|
// Submit username
|
|
|
|
// Submit username
|
|
|
|
submitButton.value = "Checking...";
|
|
|
|
submitButton.value = "Checking...";
|
|
|
|
submitUsername(inputField.value);
|
|
|
|
submitUsername(regiterFields.value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
submitButton.onclick = clickSubmit;
|
|
|
|
submitButton.onclick = clickSubmit;
|
|
|
|
|
|
|
|
|
|
|
|
// Listen for events on inputField
|
|
|
|
// Listen for events on inputFields
|
|
|
|
inputField.addEventListener('keypress', function(event) {
|
|
|
|
for (let i = 0; i < inputFields.length; i++) {
|
|
|
|
// Listen for Enter on input field
|
|
|
|
inputFields[i].addEventListener('keypress', function (event) {
|
|
|
|
if(event.which === 13) {
|
|
|
|
// Listen for Enter on input field
|
|
|
|
event.preventDefault();
|
|
|
|
if (event.which === 13) {
|
|
|
|
clickSubmit();
|
|
|
|
event.preventDefault();
|
|
|
|
return true;
|
|
|
|
clickSubmit();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
switchClass(inputField);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
switchClass(inputFields[i]);
|
|
|
|
inputField.addEventListener('change', function() {
|
|
|
|
});
|
|
|
|
switchClass(inputField);
|
|
|
|
inputFields[i].addEventListener('change', function () {
|
|
|
|
});
|
|
|
|
switchClass(inputFields[i]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < tabLinkButtons.length; i++) {
|
|
|
|
for (let i = 0; i < tabLinkButtons.length; i++) {
|
|
|
|
tabLinkButtons[i].addEventListener('click', function(event) {
|
|
|
|
tabLinkButtons[i].addEventListener('click', function(event) {
|
|
|
@ -128,5 +136,6 @@ for (let i = 0; i < tabLinkButtons.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById(event.target.dataset.tabid).classList.add('active')
|
|
|
|
document.getElementById(event.target.dataset.tabid).classList.add('active')
|
|
|
|
event.target.classList.add("active")
|
|
|
|
event.target.classList.add("active")
|
|
|
|
|
|
|
|
hideMessage()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|