From bc0e61b9721fd878734b382b775c78084f72c9e6 Mon Sep 17 00:00:00 2001 From: Simeon Keske Date: Thu, 4 Jun 2020 00:22:40 +0200 Subject: [PATCH] add content cor connect form --- matrix_synapse_saml_mozilla/res/index.html | 27 +++++++++++--- matrix_synapse_saml_mozilla/res/script.js | 43 +++++++++++++--------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/matrix_synapse_saml_mozilla/res/index.html b/matrix_synapse_saml_mozilla/res/index.html index 9e75475..0077cb8 100644 --- a/matrix_synapse_saml_mozilla/res/index.html +++ b/matrix_synapse_saml_mozilla/res/index.html @@ -8,22 +8,37 @@
- - + +
-
+
- +
-
- FOO +
+
+
+ + +
+
+
+ + +
+ +
diff --git a/matrix_synapse_saml_mozilla/res/script.js b/matrix_synapse_saml_mozilla/res/script.js index d4f4bfb..e01e6ed 100644 --- a/matrix_synapse_saml_mozilla/res/script.js +++ b/matrix_synapse_saml_mozilla/res/script.js @@ -1,5 +1,6 @@ -let inputField = document.getElementById("field-username"); -let inputForm = document.getElementById("form"); +let regiterFields = document.getElementById("field-username"); +let inputFields = document.getElementsByClassName("field"); +let registerForm = document.getElementById("form"); let submitButton = document.getElementById("button-submit"); let message = document.getElementById("message"); let tabLinkButtons = document.getElementsByClassName("tablinks"); @@ -23,12 +24,17 @@ let showMessage = function(messageText) { message.innerHTML = messageText; }; +let hideMessage = function() { + // Hide the message text + message.classList.add("hidden"); +}; + let onResponse = function(response, success) { // Display message showMessage(response); if(success) { - inputForm.submit(); + registerForm.submit(); return; } @@ -97,24 +103,26 @@ let clickSubmit = function() { // Submit username submitButton.value = "Checking..."; - submitUsername(inputField.value); + submitUsername(regiterFields.value); }; submitButton.onclick = clickSubmit; -// Listen for events on inputField -inputField.addEventListener('keypress', function(event) { - // Listen for Enter on input field - if(event.which === 13) { - event.preventDefault(); - clickSubmit(); - return true; - } - switchClass(inputField); -}); -inputField.addEventListener('change', function() { - switchClass(inputField); -}); +// Listen for events on inputFields +for (let i = 0; i < inputFields.length; i++) { + inputFields[i].addEventListener('keypress', function (event) { + // Listen for Enter on input field + if (event.which === 13) { + event.preventDefault(); + clickSubmit(); + return true; + } + switchClass(inputFields[i]); + }); + inputFields[i].addEventListener('change', function () { + switchClass(inputFields[i]); + }); +} for (let i = 0; i < tabLinkButtons.length; i++) { 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') event.target.classList.add("active") + hideMessage() }) } \ No newline at end of file