@ -98,28 +98,40 @@ function init_crypto_form() {
}
// </crypto form (Web login)>
function showPW ( ev ) {
if ( ev . buttons || ev . key == ' ' || ev . key . toUpperCase ( ) == 'ENTER' ) {
const passwordField = document . getElementById ( this . getAttribute ( 'data-toggle' ) ) ;
passwordField . setAttribute ( 'type' , 'text' ) ;
this . classList . add ( 'active' ) ;
let timeoutHide ;
function showPW _this ( ev ) {
const id _passwordField = this . getAttribute ( 'data-toggle' ) ;
if ( this . classList . contains ( 'active' ) ) {
hidePW ( id _passwordField ) ;
} else {
if ( ev . type === 'click' || ev . buttons || ev . key === ' ' || ev . key . toUpperCase ( ) === 'ENTER' ) {
showPW ( id _passwordField ) ;
}
}
return false ;
}
function hidePW ( ) {
const passwordField = document . getElementById ( this . getAttribute ( 'data-toggle' ) ) ;
function showPW ( id _passwordField ) {
const passwordField = document . getElementById ( id _passwordField ) ;
passwordField . setAttribute ( 'type' , 'text' ) ;
passwordField . nextElementSibling . classList . add ( 'active' ) ;
clearTimeout ( timeoutHide ) ;
timeoutHide = setTimeout ( function ( ) { hidePW ( id _passwordField ) ; } , 5000 ) ;
return false ;
}
function hidePW ( id _passwordField ) {
clearTimeout ( timeoutHide ) ;
const passwordField = document . getElementById ( id _passwordField ) ;
passwordField . setAttribute ( 'type' , 'password' ) ;
this . classList . remove ( 'active' ) ;
passwordField . nextElementSibling . classList . remove ( 'active' ) ;
return false ;
}
function init _password _observers ( ) {
document . querySelectorAll ( '.toggle-password' ) . forEach ( function ( btn ) {
btn . addEventListener ( 'mousedown' , showPW ) ;
btn . addEventListener ( 'keydown' , showPW ) ;
btn . addEventListener ( 'mouseup' , hidePW ) ;
btn . addEventListener ( 'keyup' , hidePW ) ;
btn . addEventListener ( 'click' , showPW _this ) ;
} ) ;
}