@@ -54,13 +54,13 @@ App.Actions.WEB.update_ftp_username_hint = function (elm, hint) {
5454App . Listeners . WEB . keypress_ftp_username = function ( ) {
5555 var ftp_user_inputs = $ ( '.v-ftp-user' ) ;
5656 $ . each ( ftp_user_inputs , function ( i , ref ) {
57- var ref = $ ( ref ) ;
58- var current_val = ref . val ( ) ;
57+ var $ ref = $ ( ref ) ;
58+ var current_val = $ ref. val ( ) ;
5959 if ( current_val . trim ( ) != '' ) {
60- App . Actions . WEB . update_ftp_username_hint ( ref , current_val ) ;
60+ App . Actions . WEB . update_ftp_username_hint ( $ ref, current_val ) ;
6161 }
6262
63- ref . bind ( 'keypress input' , function ( evt ) {
63+ $ ref. bind ( 'keypress input' , function ( evt ) {
6464 clearTimeout ( window . frp_usr_tmt ) ;
6565 window . frp_usr_tmt = setTimeout ( function ( ) {
6666 var elm = $ ( evt . target ) ;
@@ -90,13 +90,13 @@ App.Actions.WEB.update_ftp_path_hint = function (elm, hint) {
9090App . Listeners . WEB . keypress_ftp_path = function ( ) {
9191 var ftp_path_inputs = $ ( '.js-ftp-path' ) ;
9292 $ . each ( ftp_path_inputs , function ( i , ref ) {
93- var ref = $ ( ref ) ;
94- var current_val = ref . val ( ) ;
93+ var $ ref = $ ( ref ) ;
94+ var current_val = $ ref. val ( ) ;
9595 if ( current_val . trim ( ) != '' ) {
96- App . Actions . WEB . update_ftp_path_hint ( ref , current_val ) ;
96+ App . Actions . WEB . update_ftp_path_hint ( $ ref, current_val ) ;
9797 }
9898
99- ref . bind ( 'keypress input' , function ( evt ) {
99+ $ ref. bind ( 'keypress input' , function ( evt ) {
100100 clearTimeout ( window . frp_usr_tmt ) ;
101101 window . frp_usr_tmt = setTimeout ( function ( ) {
102102 var elm = $ ( evt . target ) ;
@@ -109,34 +109,36 @@ App.Listeners.WEB.keypress_ftp_path = function () {
109109//
110110//
111111App . Actions . WEB . add_ftp_user_form = function ( ) {
112- var ref = $ ( '#templates' ) . find ( '.js-ftp-account-nrm' ) . clone ( true ) ;
113- var index = $ ( '.form-container .js-ftp-account' ) . length + 1 ;
114-
115- ref . find ( 'input' ) . each ( function ( i , elm ) {
116- var name = $ ( elm ) . attr ( 'name' ) ;
117- var id = $ ( elm ) . attr ( 'id' ) ;
118- $ ( elm ) . attr ( 'name' , name . replace ( '%INDEX%' , index ) ) ;
112+ const template = $ ( '#templates' ) . find ( '.js-ftp-account-nrm' ) . clone ( true ) ;
113+ const ftpAccounts = $ ( '.form-container .js-ftp-account' ) ;
114+ const newIndex = ftpAccounts . length + 1 ;
115+
116+ template . find ( 'input' ) . each ( ( _ , elm ) => {
117+ const $elm = $ ( elm ) ;
118+ const name = $elm . attr ( 'name' ) ;
119+ const id = $elm . attr ( 'id' ) ;
120+ $elm . attr ( 'name' , name . replace ( '%INDEX%' , newIndex ) ) ;
119121 if ( id ) {
120- $ ( elm ) . attr ( 'id' , id . replace ( '%INDEX%' , index ) ) ;
122+ $elm . attr ( 'id' , id . replace ( '%INDEX%' , newIndex ) ) ;
121123 }
122124 } ) ;
123125
124- ref
126+ template
125127 . find ( 'input' )
126128 . prev ( 'label' )
127- . each ( function ( i , elm ) {
128- var for_attr = $ ( elm ) . attr ( 'for' ) ;
129- $ ( elm ) . attr ( 'for' , for_attr . replace ( '%INDEX%' , index ) ) ;
129+ . each ( ( _ , elm ) => {
130+ const $elm = $ ( elm ) ;
131+ const forAttr = $elm . attr ( 'for' ) ;
132+ $elm . attr ( 'for' , forAttr . replace ( '%INDEX%' , newIndex ) ) ;
130133 } ) ;
131134
132- ref . find ( '.ftp-user-number' ) . text ( index ) ;
133-
134- $ ( '#ftp_users' ) . append ( ref ) ;
135+ template . find ( '.ftp-user-number' ) . text ( newIndex ) ;
136+ $ ( '#ftp_users' ) . append ( template ) ;
135137
136- var index = 1 ;
137- $ ( '.form-container .ftp-user-number:visible' ) . each ( function ( i , o ) {
138- $ ( o ) . text ( index ) ;
139- index += 1 ;
138+ let counter = 1 ;
139+ $ ( '.form-container .ftp-user-number:visible' ) . each ( ( _ , o ) => {
140+ $ ( o ) . text ( counter ) ;
141+ counter += 1 ;
140142 } ) ;
141143} ;
142144
0 commit comments