@@ -23,21 +23,21 @@ document.addEventListener('DOMContentLoaded', () => {
23
23
handlePasswordToggle ( ) ;
24
24
25
25
// Switch between database selection
26
- const setupType = document . getElementById ( 'sql_type' ) ;
26
+ const setupType : HTMLElement | null = document . getElementById ( 'sql_type' ) ;
27
27
if ( setupType ) {
28
28
setupType . addEventListener ( 'change' , selectDatabaseSetup ) ;
29
29
}
30
30
31
31
// Add more Elasticsearch server inputs
32
- const addElasticsearch = document . getElementById ( 'pmf-add-elasticsearch-host' ) ;
32
+ const addElasticsearch : HTMLElement | null = document . getElementById ( 'pmf-add-elasticsearch-host' ) ;
33
33
if ( addElasticsearch ) {
34
34
addElasticsearch . addEventListener ( 'click' , addElasticsearchServerInput ) ;
35
35
}
36
36
37
37
// Wizard
38
- let currentTab = 0 ;
39
- const nextButton = document . getElementById ( 'nextBtn' ) ;
40
- const prevButton = document . getElementById ( 'prevBtn' ) ;
38
+ let currentTab : number = 0 ;
39
+ const nextButton : HTMLElement | null = document . getElementById ( 'nextBtn' ) ;
40
+ const prevButton : HTMLElement | null = document . getElementById ( 'prevBtn' ) ;
41
41
if ( nextButton ) {
42
42
nextButton . addEventListener ( 'click' , ( event ) => {
43
43
event . preventDefault ( ) ;
@@ -52,15 +52,15 @@ document.addEventListener('DOMContentLoaded', () => {
52
52
}
53
53
showTab ( currentTab ) ;
54
54
55
- function showTab ( number ) {
56
- const currentStep = document . getElementsByClassName ( 'step' ) ;
55
+ function showTab ( number : number ) : void {
56
+ const currentStep : HTMLCollectionOf < Element > = document . getElementsByClassName ( 'step' ) ;
57
57
58
58
if ( currentStep . length > 0 ) {
59
- currentStep [ number ] . style . display = 'block' ;
59
+ ( currentStep [ number ] as HTMLElement ) . style . display = 'block' ;
60
60
}
61
61
62
- const prevButton = document . getElementById ( 'prevBtn' ) ;
63
- const nextButton = document . getElementById ( 'nextBtn' ) ;
62
+ const prevButton : HTMLElement | null = document . getElementById ( 'prevBtn' ) ;
63
+ const nextButton : HTMLElement | null = document . getElementById ( 'nextBtn' ) ;
64
64
65
65
if ( prevButton && nextButton ) {
66
66
if ( number === 0 ) {
@@ -77,39 +77,39 @@ document.addEventListener('DOMContentLoaded', () => {
77
77
}
78
78
}
79
79
80
- const nextPrev = ( n ) => {
81
- const currentStep = document . getElementsByClassName ( 'step' ) ;
82
- const prevButton = document . getElementById ( 'prevBtn' ) ;
83
- const nextButton = document . getElementById ( 'nextBtn' ) ;
84
- const installButton = document . getElementById ( 'installingBtn' ) ;
80
+ const nextPrev = ( n : number ) => {
81
+ const currentStep : HTMLCollectionOf < Element > = document . getElementsByClassName ( 'step' ) ;
82
+ const prevButton = document . getElementById ( 'prevBtn' ) as HTMLElement ;
83
+ const nextButton = document . getElementById ( 'nextBtn' ) as HTMLElement ;
84
+ const installButton = document . getElementById ( 'installingBtn' ) as HTMLElement ;
85
85
86
86
if ( n === 1 && ! validateForm ( ) ) {
87
87
return false ;
88
88
}
89
89
90
- currentStep [ currentTab ] . style . display = 'none' ;
90
+ ( currentStep [ currentTab ] as HTMLElement ) . style . display = 'none' ;
91
91
currentTab = currentTab + n ;
92
92
if ( currentTab >= currentStep . length ) {
93
93
prevButton . classList . add ( 'd-none' ) ;
94
94
nextButton . classList . add ( 'd-none' ) ;
95
95
installButton . classList . remove ( 'd-none' ) ;
96
- document . getElementById ( 'phpmyfaq-setup-form' ) . submit ( ) ;
96
+ ( document . getElementById ( 'phpmyfaq-setup-form' ) as HTMLFormElement ) . submit ( ) ;
97
97
return false ;
98
98
}
99
99
100
100
showTab ( currentTab ) ;
101
101
} ;
102
102
103
- const validateForm = ( ) => {
103
+ const validateForm = ( ) : boolean => {
104
104
let currentStep ,
105
105
y ,
106
106
i ,
107
107
valid = true ;
108
- currentStep = document . getElementsByClassName ( 'step' ) ;
108
+ currentStep = document . getElementsByClassName ( 'step' ) as HTMLCollectionOf < HTMLElement > ;
109
109
y = currentStep [ currentTab ] . querySelectorAll ( 'input,select' ) ;
110
110
111
111
for ( i = 0 ; i < y . length ; i ++ ) {
112
- if ( y [ i ] . value === '' && y [ i ] . hasAttribute ( 'required' ) ) {
112
+ if ( ( y [ i ] as HTMLInputElement ) . value === '' && y [ i ] . hasAttribute ( 'required' ) ) {
113
113
y [ i ] . className += ' is-invalid' ;
114
114
// and set the current valid status to false
115
115
valid = false ;
@@ -122,16 +122,4 @@ document.addEventListener('DOMContentLoaded', () => {
122
122
123
123
return valid ; // return the valid status
124
124
} ;
125
-
126
- const resetValidateForm = ( ) => {
127
- let currentStep , y , i ;
128
- currentStep = document . getElementsByClassName ( 'step' ) ;
129
- y = currentStep [ currentTab ] . getElementsByTagName ( 'input' ) ;
130
-
131
- for ( i = 0 ; i < y . length ; i ++ ) {
132
- if ( y [ i ] . value === '' && y [ i ] . hasAttribute ( 'required' ) ) {
133
- y [ i ] . className -= ' is-invalid' ;
134
- }
135
- }
136
- } ;
137
125
} ) ;
0 commit comments