1- App . Actions . WEB . update_ftp_username_hint = function ( elm , hint ) {
2- if ( hint . trim ( ) == '' ) {
3- $ ( elm ) . parent ( ) . find ( '.hint' ) . html ( '' ) ;
4- }
5-
6- if ( hint . indexOf ( GLOBAL . FTP_USER_PREFIX ) == 0 ) {
7- hint = hint . slice ( GLOBAL . FTP_USER_PREFIX . length , hint . length ) ;
8- }
9- hint = hint . replace ( / [ ^ \w \d ] / gi, '' ) ;
10-
11- $ ( elm ) . parent ( ) . find ( '.v-ftp-user' ) . val ( hint ) ;
12- $ ( elm ) . parent ( ) . find ( '.hint' ) . text ( GLOBAL . FTP_USER_PREFIX + hint ) ;
13- }
14-
15- App . Listeners . WEB . keypress_ftp_username = function ( ) {
16- var ftp_user_inputs = $ ( '.v-ftp-user' ) ;
17- $ . each ( ftp_user_inputs , function ( i , ref ) {
18- var ref = $ ( ref ) ;
19- var current_val = ref . val ( ) ;
20- if ( current_val . trim ( ) != '' ) {
21- App . Actions . WEB . update_ftp_username_hint ( ref , current_val ) ;
22- }
23-
24- ref . bind ( 'keypress input' , function ( evt ) {
25- clearTimeout ( window . frp_usr_tmt ) ;
26- window . frp_usr_tmt = setTimeout ( function ( ) {
27- var elm = $ ( evt . target ) ;
28- App . Actions . WEB . update_ftp_username_hint ( elm , $ ( elm ) . val ( ) ) ;
29- } , 100 ) ;
30- } ) ;
31- } ) ;
32- }
33-
34- //
35- //
36-
37- App . Actions . WEB . update_ftp_path_hint = function ( elm , hint ) {
38- if ( hint . trim ( ) == '' ) {
39- $ ( elm ) . parent ( ) . find ( '.v-ftp-path-hint' ) . html ( '' ) ;
40- }
41-
42- if ( hint [ 0 ] != '/' ) {
43- hint = '/' + hint ;
44- }
45-
46- hint = hint . replace ( / \/ ( \/ + ) / g, '/' ) ;
47-
48- $ ( elm ) . parent ( ) . find ( '.v-ftp-path-hint' ) . text ( hint ) ;
49- }
50-
51- App . Listeners . WEB . keypress_ftp_path = function ( ) {
52- var ftp_path_inputs = $ ( '.v-ftp-path' ) ;
53- $ . each ( ftp_path_inputs , function ( i , ref ) {
54- var ref = $ ( ref ) ;
55- var current_val = ref . val ( ) ;
56- if ( current_val . trim ( ) != '' ) {
57- App . Actions . WEB . update_ftp_path_hint ( ref , current_val ) ;
58- }
59-
60- ref . bind ( 'keypress input' , function ( evt ) {
61- clearTimeout ( window . frp_usr_tmt ) ;
62- window . frp_usr_tmt = setTimeout ( function ( ) {
63- var elm = $ ( evt . target ) ;
64- App . Actions . WEB . update_ftp_path_hint ( elm , $ ( elm ) . val ( ) ) ;
65- } , 100 ) ;
66- } ) ;
67- } ) ;
68- }
69-
70- //
71- //
72- App . Actions . WEB . add_ftp_user_form = function ( ) {
73- var ref = $ ( '#templates' ) . find ( '.ftptable' ) . clone ( true ) ;
74- var index = $ ( '.data-col2 .ftptable' ) . length + 1 ;
75-
76- ref . find ( 'input' ) . each ( function ( i , elm ) {
77- var attr_value = $ ( elm ) . prop ( 'name' ) . replace ( '%INDEX%' , index ) ;
78- $ ( elm ) . prop ( 'name' , attr_value ) ;
79- } ) ;
80-
81- ref . find ( '.ftp-user-number' ) . text ( index ) ;
82-
83- $ ( '.data-col2 .ftptable:last' ) . after ( ref ) ;
84-
85- var index = 1 ;
86- $ ( '.data-col2 .ftp-user-number:visible' ) . each ( function ( i , o ) {
87- $ ( o ) . text ( index ) ;
88- index += 1 ;
89- } ) ;
90- }
91-
92- App . Actions . WEB . remove_ftp_user = function ( elm ) {
93- var ref = $ ( elm ) . parents ( '.ftptable' ) ;
94- ref . find ( '.v-ftp-user-deleted' ) . val ( '1' ) ;
95- if ( ref . find ( '.v-ftp-user-is-new' ) . val ( ) == 1 ) {
96- ref . remove ( ) ;
97- return true ;
98- }
99- ref . removeClass ( 'ftptable-nrm' ) ;
100- ref . hide ( ) ;
101-
102- var index = 1 ;
103- $ ( '.data-col2 .ftp-user-number:visible' ) . each ( function ( i , o ) {
104- $ ( o ) . text ( index ) ;
105- index += 1 ;
106- } ) ;
107-
108- if ( $ ( '.ftptable-nrm:visible' ) . length == 0 ) {
109- $ ( '.add-new-ftp-user-button' ) . hide ( ) ;
110- $ ( 'input[name="v_ftp"]' ) . attr ( 'checked' , false ) ;
111- }
112- }
113-
114- App . Actions . WEB . toggle_additional_ftp_accounts = function ( elm ) {
115- if ( $ ( elm ) . attr ( 'checked' ) ) {
116- $ ( '.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button' ) . show ( ) ;
117- $ ( '.ftptable-nrm' ) . each ( function ( i , elm ) {
118- var login = $ ( elm ) . find ( '.v-ftp-user' ) ;
119- if ( login . val ( ) . trim ( ) != '' ) {
120- $ ( elm ) . find ( '.v-ftp-user-deleted' ) . val ( 0 ) ;
121- }
122- } ) ;
123- }
124- else {
125- $ ( '.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button' ) . hide ( ) ;
126- $ ( '.ftptable-nrm' ) . each ( function ( i , elm ) {
127- var login = $ ( elm ) . find ( '.v-ftp-user' ) ;
128- if ( login . val ( ) . trim ( ) != '' ) {
129- $ ( elm ) . find ( '.v-ftp-user-deleted' ) . val ( 1 ) ;
130- }
131- } ) ;
132- }
133- }
134-
135- App . Actions . WEB . toggle_letsencrypt = function ( elm ) {
1+ App . Actions . MAIL . toggle_letsencrypt = function ( elm ) {
1362 if ( $ ( elm ) . attr ( 'checked' ) ) {
1373 $ ( '#ssltable textarea[name=v_ssl_crt],#ssltable textarea[name=v_ssl_key], #ssltable textarea[name=v_ssl_ca]' ) . attr ( 'disabled' , 'disabled' ) ;
1384 $ ( '#generate-csr' ) . hide ( ) ;
@@ -147,76 +13,14 @@ App.Actions.WEB.toggle_letsencrypt = function(elm) {
14713 }
14814}
14915
150- App . Actions . WEB . randomPasswordGenerated = function ( elm ) {
151- return App . Actions . WEB . passwordChanged ( elm ) ;
152- }
153-
154- App . Actions . WEB . passwordChanged = function ( elm ) {
155- var ref = $ ( elm ) . parents ( '.ftptable' ) ;
156- if ( ref . find ( '.vst-email-alert-on-psw' ) . length == 0 ) {
157- var inp_name = ref . find ( '.v-ftp-user-is-new' ) . prop ( 'name' ) ;
158- inp_name = inp_name . replace ( 'is_new' , 'v_ftp_email' ) ;
159- ref . find ( 'tr:last' ) . after ( '<tr>\
160- <td class="vst-text step-left input-label">\
161- Send FTP credentials to email\
162- </td>\
163- </tr>\
164- <tr>\
165- <td class="step-left">\
166- <input type="text" value="" name="' + inp_name + '" class="vst-input vst-email-alert-on-psw">\
167- </td>\
168- </tr>' ) ;
169- }
170- }
171-
17216//
17317// Page entry point
174- App . Listeners . WEB . keypress_ftp_username ( ) ;
175- App . Listeners . WEB . keypress_ftp_path ( ) ;
176-
177-
17818$ ( function ( ) {
179- $ ( '.v-ftp-user-psw' ) . on ( 'keypress' , function ( evt ) {
180- var elm = $ ( evt . target ) ;
181- App . Actions . WEB . passwordChanged ( elm ) ;
182- } ) ;
183- App . Actions . WEB . toggle_letsencrypt ( $ ( 'input[name=v_letsencrypt]' ) ) ;
18419
185- $ ( 'select[name="v_stats"]' ) . change ( function ( evt ) {
186- var select = $ ( evt . target ) ;
20+ App . Actions . MAIL . toggle_letsencrypt ( $ ( 'input[name=v_letsencrypt]' ) ) ;
18721
188- if ( select . val ( ) == 'none' ) {
189- $ ( '.stats-auth' ) . hide ( ) ;
190- } else {
191- $ ( '.stats-auth' ) . show ( ) ;
192- }
193- } ) ;
19422} ) ;
19523
196- function WEBrandom ( ) {
197- var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz' ;
198- var string_length = 16 ;
199- var webrandom = '' ;
200- for ( var i = 0 ; i < string_length ; i ++ ) {
201- var rnum = Math . floor ( Math . random ( ) * chars . length ) ;
202- webrandom += chars . substr ( rnum , 1 ) ;
203- }
204- document . v_edit_web . v_stats_password . value = webrandom ;
205- }
206-
207- function FTPrandom ( elm ) {
208- var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz' ;
209- var string_length = 16 ;
210- var ftprandomstring = '' ;
211- for ( var i = 0 ; i < string_length ; i ++ ) {
212- var rnum = Math . floor ( Math . random ( ) * chars . length ) ;
213- ftprandomstring += chars . substr ( rnum , 1 ) ;
214- }
215-
216- $ ( elm ) . parents ( '.ftptable' ) . find ( '.v-ftp-user-psw' ) . val ( ftprandomstring ) ;
217- App . Actions . WEB . randomPasswordGenerated && App . Actions . WEB . randomPasswordGenerated ( elm ) ;
218- }
219-
22024function elementHideShow ( elementToHideOrShow ) {
22125 var el = document . getElementById ( elementToHideOrShow ) ;
22226 el . style . display = el . style . display === 'none' ? 'block' : 'none' ;
0 commit comments