1
1
// Reveal controller for handling password and username reveal/hide functionality
2
2
document . addEventListener ( "DOMContentLoaded" , function ( ) {
3
3
// Get CSRF token for API requests
4
- const csrfToken =
5
- document . querySelector ( 'meta[name="csrf-token"]' ) &&
6
- document . querySelector ( 'meta[name="csrf-token"]' ) . content ;
4
+ const csrfToken = document . querySelector ( 'meta[name="csrf-token"]' ) ?. content ;
7
5
if ( ! csrfToken ) return ;
8
6
9
7
// Get entry ID from the page
@@ -40,7 +38,7 @@ function setupRevealHide(type, entryId, csrfToken) {
40
38
} )
41
39
. then ( ( response ) => response . json ( ) )
42
40
. then ( ( data ) => {
43
- const valueElement = container . querySelector ( "p" ) ;
41
+ const valueElement = document . getElementById ( ` ${ type } -value` ) ;
44
42
if ( valueElement ) {
45
43
valueElement . textContent = data . value ;
46
44
}
@@ -57,7 +55,8 @@ function setupRevealHide(type, entryId, csrfToken) {
57
55
} , 5000 ) ;
58
56
} )
59
57
. catch ( ( error ) => {
60
- console . error ( `Error revealing ${ type } :` , error ) ;
58
+ // Error handling for reveal operation
59
+ // console.error(`Error revealing ${type}:`, error);
61
60
} ) ;
62
61
} ) ;
63
62
@@ -79,15 +78,16 @@ function setupRevealHide(type, entryId, csrfToken) {
79
78
} )
80
79
. then ( ( response ) => response . json ( ) )
81
80
. then ( ( data ) => {
82
- const valueElement = container . querySelector ( "p" ) ;
81
+ const valueElement = document . getElementById ( ` ${ type } -value` ) ;
83
82
if ( valueElement ) {
84
83
valueElement . textContent = "••••••••" ;
85
84
}
86
85
revealBtn . style . display = "inline-block" ;
87
86
hideBtn . style . display = "none" ;
88
87
} )
89
88
. catch ( ( error ) => {
90
- console . error ( `Error masking ${ type } :` , error ) ;
89
+ // Error handling for mask operation
90
+ // console.error(`Error masking ${type}:`, error);
91
91
} ) ;
92
92
} ) ;
93
93
}
0 commit comments