1
0

publicshareauth.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. function showEmailAddressPromptForm() {
  6. // Shows email prompt
  7. var emailInput = document.getElementById('email-input-form');
  8. emailInput.style.display="block";
  9. // Shows back button
  10. var backButton = document.getElementById('request-password-back-button');
  11. backButton.style.display="block";
  12. // Hides password prompt and 'request password' button
  13. var passwordRequestButton = document.getElementById('request-password-button-not-talk');
  14. var passwordInput = document.getElementById('password-input-form');
  15. passwordRequestButton.style.display="none";
  16. passwordInput.style.display="none";
  17. // Hides identification result messages, if any
  18. var identificationResultSuccess = document.getElementById('identification-success');
  19. var identificationResultFailure = document.getElementById('identification-failure');
  20. if (identificationResultSuccess) {
  21. identificationResultSuccess.style.display="none";
  22. }
  23. if (identificationResultFailure) {
  24. identificationResultFailure.style.display="none";
  25. }
  26. }
  27. document.addEventListener('DOMContentLoaded', function() {
  28. // Enables password submit button only when user has typed something in the password field
  29. var passwordInput = document.getElementById('password');
  30. var passwordButton = document.getElementById('password-submit');
  31. var eventListener = function() {
  32. passwordButton.disabled = passwordInput.value.length === 0;
  33. };
  34. passwordInput.addEventListener('click', eventListener);
  35. passwordInput.addEventListener('keyup', eventListener);
  36. passwordInput.addEventListener('change', eventListener);
  37. // Enables email request button only when user has typed something in the email field
  38. var emailInput = document.getElementById('email');
  39. var emailButton = document.getElementById('password-request');
  40. eventListener = function() {
  41. emailButton.disabled = emailInput.value.length === 0;
  42. };
  43. emailInput.addEventListener('click', eventListener);
  44. emailInput.addEventListener('keyup', eventListener);
  45. emailInput.addEventListener('change', eventListener);
  46. // Adds functionality to the request password button
  47. var passwordRequestButton = document.getElementById('request-password-button-not-talk');
  48. if (passwordRequestButton) {
  49. passwordRequestButton.addEventListener('click', showEmailAddressPromptForm);
  50. }
  51. });