@@ -53,36 +53,12 @@ App.Listeners.MAIL_ACC.init = function () {
5353App . Listeners . MAIL_ACC . init ( ) ;
5454App . Listeners . MAIL_ACC . checkbox_unlimited_feature ( ) ;
5555
56- App . Actions . MAIL_ACC . update_password_meter = function ( ) {
57- var password = $ ( 'input[name="v_password"]' ) . val ( ) ;
58- var min_small = new RegExp ( / ^ (? = .* [ a - z ] ) .+ $ / ) ;
59- var min_cap = new RegExp ( / ^ (? = .* [ A - Z ] ) .+ $ / ) ;
60- var min_num = new RegExp ( / ^ (? = .* \d ) .+ $ / ) ;
61- var min_length = 8 ;
62- var score = 0 ;
63-
64- if ( password . length >= min_length ) {
65- score = score + 1 ;
66- }
67- if ( min_small . test ( password ) ) {
68- score = score + 1 ;
69- }
70- if ( min_cap . test ( password ) ) {
71- score = score + 1 ;
72- }
73- if ( min_num . test ( password ) ) {
74- score = score + 1 ;
75- }
76- $ ( '.js-password-meter' ) . val ( score ) ;
77- } ;
78-
7956App . Listeners . MAIL_ACC . keypress_v_password = function ( ) {
8057 var ref = $ ( 'input[name="v_password"]' ) ;
8158 ref . bind ( 'keypress input' , function ( evt ) {
8259 clearTimeout ( window . frp_usr_tmt ) ;
8360 window . frp_usr_tmt = setTimeout ( function ( ) {
84- var elm = $ ( evt . target ) ;
85- App . Actions . MAIL_ACC . update_password_meter ( elm , $ ( elm ) . val ( ) ) ;
61+ VE . helpers . recalculatePasswordStrength ( evt . target ) ;
8662 } , 100 ) ;
8763 } ) ;
8864} ;
@@ -101,13 +77,19 @@ $('#v_blackhole').on('click', function () {
10177App . Listeners . MAIL_ACC . keypress_v_password ( ) ;
10278
10379applyRandomPassword = function ( min_length = 16 ) {
104- var randomPassword = randomString ( min_length ) ;
105- $ ( 'input[name=v_password]' ) . val ( randomPassword ) ;
106- if ( $ ( 'input[name=v_password]' ) . attr ( 'type' ) == 'text' )
107- $ ( '.js-password-output' ) . text ( randomPassword ) ;
108- else $ ( '.js-password-output' ) . text ( Array ( randomPassword . length + 1 ) . join ( '*' ) ) ;
109- App . Actions . MAIL_ACC . update_password_meter ( ) ;
110- generate_mail_credentials ( ) ;
80+ const randomPassword = randomString ( min_length ) ;
81+ const passwordInput = document . querySelector ( 'input[name=v_password]' ) ;
82+ if ( passwordInput ) {
83+ passwordInput . value = randomPassword ;
84+ VE . helpers . recalculatePasswordStrength ( passwordInput ) ;
85+ const passwordOutput = document . querySelector ( '.js-password-output' ) ;
86+ if ( passwordInput . getAttribute ( 'type' ) === 'text' && passwordOutput ) {
87+ passwordOutput . textContent = randomPassword ;
88+ } else {
89+ passwordOutput . textContent = Array ( randomPassword . length + 1 ) . join ( '*' ) ;
90+ }
91+ generate_mail_credentials ( ) ;
92+ }
11193} ;
11294
11395generate_mail_credentials = function ( ) {
0 commit comments