// jlogin.js

//! Afficher ou non le mot de passe
const togglePassword = document.querySelector('#togglePassword');
const password = document.querySelector('#bcpassword');
togglePassword.addEventListener('click', function (e) {
  // toggle the type attribute
  const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
  password.setAttribute('type', type);

  const btnText = password.getAttribute('type') === 'password' ? '<svg width="18px" height="18px" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">\n' +
          '                        <path d="M4 10C4 10 5.6 15 12 15M12 15C18.4 15 20 10 20 10M12 15V18M18 17L16 14.5M6 17L8 14.5" stroke="#464455" stroke-linecap="round" stroke-linejoin="round"/>\n' +
          '                      </svg>' : '<svg width="18px" height="18px" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">\n' +
          '<path d="M4 12C4 12 5.6 7 12 7M12 7C18.4 7 20 12 20 12M12 7V4M18 5L16 7.5M6 5L8 7.5M15 13C15 14.6569 13.6569 16 12 16C10.3431 16 9 14.6569 9 13C9 11.3431 10.3431 10 12 10C13.6569 10 15 11.3431 15 13Z" stroke="#464455" stroke-linecap="round" stroke-linejoin="round"/>\n' +
          '</svg>';

  this.innerHTML = btnText;
});

//! afficher l'email pour le mot de passe perdu
const divIdentifiant = document.getElementById('divUserName');
const divPass = document.getElementById('divPassWord');
const lnkPerdu = document.getElementById('lnPerdu');
const divMail = document.getElementById('divEmail');
const btnSub = document.getElementById('btnSubmit');
lnkPerdu.addEventListener('click', function (e) {
  divIdentifiant.style.display = 'none';
  divPass.style.display = 'none';
  divMail.style.display = 'block';
  btnSub.innerHTML = "Envoyer";
});
