1
- import $ from 'jquery' ;
2
1
import { hideElem , showElem } from '../utils/dom.js' ;
3
2
import { GET } from '../modules/fetch.js' ;
4
3
5
4
export function initInstall ( ) {
6
- const $ page = $ ( '.page-content.install' ) ;
7
- if ( $ page. length === 0 ) {
5
+ const page = document . querySelector ( '.page-content.install' ) ;
6
+ if ( ! page ) {
8
7
return ;
9
8
}
10
- if ( $ page. is ( '. post-install') ) {
9
+ if ( page . classList . contains ( ' post-install') ) {
11
10
initPostInstall ( ) ;
12
11
} else {
13
12
initPreInstall ( ) ;
14
13
}
15
14
}
16
-
17
15
function initPreInstall ( ) {
18
16
const defaultDbUser = 'gitea' ;
19
17
const defaultDbName = 'gitea' ;
@@ -24,83 +22,82 @@ function initPreInstall() {
24
22
mssql : '127.0.0.1:1433'
25
23
} ;
26
24
27
- const $ dbHost = $ ( '# db_host') ;
28
- const $ dbUser = $ ( '# db_user') ;
29
- const $ dbName = $ ( '# db_name') ;
25
+ const dbHost = document . getElementById ( ' db_host') ;
26
+ const dbUser = document . getElementById ( ' db_user') ;
27
+ const dbName = document . getElementById ( ' db_name') ;
30
28
31
29
// Database type change detection.
32
- $ ( '# db_type') . on ( 'change' , function ( ) {
33
- const dbType = $ ( this ) . val ( ) ;
34
- hideElem ( $ ( 'div[data-db-setting-for]' ) ) ;
35
- showElem ( $ ( `div[data-db-setting-for=${ dbType } ]` ) ) ;
30
+ document . getElementById ( ' db_type') . addEventListener ( 'change' , function ( ) {
31
+ const dbType = this . value ;
32
+ hideElem ( 'div[data-db-setting-for]' ) ;
33
+ showElem ( `div[data-db-setting-for=${ dbType } ]` ) ;
36
34
37
35
if ( dbType !== 'sqlite3' ) {
38
36
// for most remote database servers
39
- showElem ( $ ( ` div[data-db-setting-for=common-host]` ) ) ;
40
- const lastDbHost = $ dbHost. val ( ) ;
37
+ showElem ( ' div[data-db-setting-for=common-host]' ) ;
38
+ const lastDbHost = dbHost . value ;
41
39
const isDbHostDefault = ! lastDbHost || Object . values ( defaultDbHosts ) . includes ( lastDbHost ) ;
42
40
if ( isDbHostDefault ) {
43
- $ dbHost. val ( defaultDbHosts [ dbType ] ?? '' ) ;
41
+ dbHost . value = defaultDbHosts [ dbType ] ?? '' ;
44
42
}
45
- if ( ! $ dbUser. val ( ) && ! $ dbName. val ( ) ) {
46
- $ dbUser. val ( defaultDbUser ) ;
47
- $ dbName. val ( defaultDbName ) ;
43
+ if ( ! dbUser . value && ! dbName . value ) {
44
+ dbUser . value = defaultDbUser ;
45
+ dbName . value = defaultDbName ;
48
46
}
49
47
} // else: for SQLite3, the default path is always prepared by backend code (setting)
50
- } ) . trigger ( 'change' ) ;
48
+ } ) ;
49
+ document . getElementById ( 'db_type' ) . dispatchEvent ( new Event ( 'change' ) ) ;
51
50
52
- const $appUrl = $ ( '#app_url' ) ;
53
- const configAppUrl = $appUrl . val ( ) ;
54
- if ( configAppUrl . includes ( '://localhost' ) ) {
55
- $appUrl . val ( window . location . href ) ;
51
+ const appUrl = document . getElementById ( 'app_url' ) ;
52
+ if ( appUrl . value . includes ( '://localhost' ) ) {
53
+ appUrl . value = window . location . href ;
56
54
}
57
55
58
- const $domain = $ ( '#domain' ) ;
59
- const configDomain = $domain . val ( ) . trim ( ) ;
60
- if ( configDomain === 'localhost' ) {
61
- $domain . val ( window . location . hostname ) ;
56
+ const domain = document . getElementById ( 'domain' ) ;
57
+ if ( domain . value . trim ( ) === 'localhost' ) {
58
+ domain . value = window . location . hostname ;
62
59
}
63
60
64
61
// TODO: better handling of exclusive relations.
65
- $ ( '#offline-mode input' ) . on ( 'change' , function ( ) {
66
- if ( $ ( this ) . is ( ': checked' ) ) {
67
- $ ( '#disable-gravatar' ) . checkbox ( 'check' ) ;
68
- $ ( '#federated-avatar-lookup' ) . checkbox ( 'uncheck' ) ;
62
+ document . querySelector ( '#offline-mode input' ) . addEventListener ( 'change' , function ( ) {
63
+ if ( this . checked ) {
64
+ document . querySelector ( '#disable-gravatar input ' ) . checked = true ;
65
+ document . querySelector ( '#federated-avatar-lookup input ' ) . checked = false ;
69
66
}
70
67
} ) ;
71
- $ ( '#disable-gravatar input' ) . on ( 'change' , function ( ) {
72
- if ( $ ( this ) . is ( ': checked' ) ) {
73
- $ ( '#federated-avatar-lookup' ) . checkbox ( 'uncheck' ) ;
68
+ document . querySelector ( '#disable-gravatar input' ) . addEventListener ( 'change' , function ( ) {
69
+ if ( this . checked ) {
70
+ document . querySelector ( '#federated-avatar-lookup input ' ) . checked = false ;
74
71
} else {
75
- $ ( '#offline-mode' ) . checkbox ( 'uncheck' ) ;
72
+ document . querySelector ( '#offline-mode input ' ) . checked = false ;
76
73
}
77
74
} ) ;
78
- $ ( '#federated-avatar-lookup input' ) . on ( 'change' , function ( ) {
79
- if ( $ ( this ) . is ( ': checked' ) ) {
80
- $ ( '#disable-gravatar' ) . checkbox ( 'uncheck' ) ;
81
- $ ( '#offline-mode' ) . checkbox ( 'uncheck' ) ;
75
+ document . querySelector ( '#federated-avatar-lookup input' ) . addEventListener ( 'change' , function ( ) {
76
+ if ( this . checked ) {
77
+ document . querySelector ( '#disable-gravatar input ' ) . checked = false ;
78
+ document . querySelector ( '#offline-mode input ' ) . checked = false ;
82
79
}
83
80
} ) ;
84
- $ ( '#enable-openid-signin input' ) . on ( 'change' , function ( ) {
85
- if ( $ ( this ) . is ( ': checked' ) ) {
86
- if ( ! $ ( '#disable-registration input' ) . is ( ': checked' ) ) {
87
- $ ( '#enable-openid-signup' ) . checkbox ( 'check' ) ;
81
+ document . querySelector ( '#enable-openid-signin input' ) . addEventListener ( 'change' , function ( ) {
82
+ if ( this . checked ) {
83
+ if ( ! document . querySelector ( '#disable-registration input' ) . checked ) {
84
+ document . querySelector ( '#enable-openid-signup input ' ) . checked = true ;
88
85
}
89
86
} else {
90
- $ ( '#enable-openid-signup' ) . checkbox ( 'uncheck' ) ;
87
+ document . querySelector ( '#enable-openid-signup input ' ) . checked = false ;
91
88
}
92
89
} ) ;
93
- $ ( '#disable-registration input' ) . on ( 'change' , function ( ) {
94
- if ( $ ( this ) . is ( ': checked' ) ) {
95
- $ ( '#enable-captcha' ) . checkbox ( 'uncheck' ) ;
96
- $ ( '#enable-openid-signup' ) . checkbox ( 'uncheck' ) ;
90
+ document . querySelector ( '#disable-registration input' ) . addEventListener ( 'change' , function ( ) {
91
+ if ( this . checked ) {
92
+ document . querySelector ( '#enable-captcha input ' ) . checked = false ;
93
+ document . querySelector ( '#enable-openid-signup input ' ) . checked = false ;
97
94
} else {
98
- $ ( '#enable-openid-signup' ) . checkbox ( 'check' ) ;
95
+ document . querySelector ( '#enable-openid-signup input ' ) . checked = true ;
99
96
}
100
97
} ) ;
101
- $ ( '#enable-captcha input' ) . on ( 'change' , function ( ) {
102
- if ( $ ( this ) . is ( ': checked' ) ) {
103
- $ ( '#disable-registration' ) . checkbox ( 'uncheck' ) ;
98
+ document . querySelector ( '#enable-captcha input' ) . addEventListener ( 'change' , function ( ) {
99
+ if ( this . checked ) {
100
+ document . querySelector ( '#disable-registration input ' ) . checked = false ;
104
101
}
105
102
} ) ;
106
103
}
0 commit comments