@@ -130,7 +130,7 @@ function logout() {
130
130
/* Drag & drop */
131
131
132
132
function showDropZone ( ) {
133
- if ( allowSubmit ) {
133
+ if ( allowSubmit ( ) ) {
134
134
dropArea . style . visibility = "visible" ;
135
135
hideInfoArea ( )
136
136
}
@@ -141,7 +141,7 @@ function hideDropZone() {
141
141
}
142
142
143
143
function allowDrag ( e ) {
144
- if ( allowSubmit ) {
144
+ if ( allowSubmit ( ) ) {
145
145
e . dataTransfer . dropEffect = 'copy' ;
146
146
e . preventDefault ( ) ;
147
147
}
@@ -176,25 +176,33 @@ headerFileId.value = ''
176
176
177
177
/* File ID: input validation */
178
178
179
- let allowSubmit = true
180
179
headerFileId . addEventListener ( 'keyup' , fileIdChanged )
181
180
headerFileId . addEventListener ( 'paste' , fileIdChanged )
182
181
183
182
function fileIdChanged ( e ) {
184
- let textValid = headerFileId . value === "" || / ^ [ 0 - 9 a - z ] [ - _ . 0 - 9 a - z ] * $ / i. test ( headerFileId . value )
185
- if ( textValid ) {
186
- allowSubmit = true
183
+ if ( textValid ( ) ) {
187
184
headerFileId . classList . remove ( 'error' )
188
185
headerSaveButton . disabled = false
189
186
headerUploadButton . disabled = false
190
187
} else {
191
- allowSubmit = false
192
188
headerFileId . classList . add ( 'error' )
193
189
headerSaveButton . disabled = true
194
190
headerUploadButton . disabled = true
195
191
}
196
192
}
197
193
194
+ function textValid ( ) {
195
+ return headerFileId . value === "" || / ^ [ 0 - 9 a - z ] [ - _ . 0 - 9 a - z ] * $ / i. test ( headerFileId . value )
196
+ }
197
+
198
+ function allowSubmit ( ) {
199
+ if ( clientSideEnabled ( ) ) {
200
+ return false
201
+ } else {
202
+ return textValid ( )
203
+ }
204
+ }
205
+
198
206
/* File ID: random name checkbox */
199
207
200
208
headerRandomFileId . checked = randomFileNameEnabled ( )
@@ -241,7 +249,7 @@ function changeClientSideEnabled(enabled) {
241
249
headerStream . disabled = true
242
250
headerUploadButton . disabled = true
243
251
} else {
244
- changeRandomFileIdEnabled ( headerFileId . checked )
252
+ changeRandomFileIdEnabled ( randomFileNameEnabled ( ) )
245
253
headerRandomFileId . disabled = false
246
254
headerTTL . disabled = false
247
255
headerStream . disabled = false
@@ -384,7 +392,6 @@ async function saveClientSide() {
384
392
reader . onload = ( ) => {
385
393
const data = reader . result . substr ( reader . result . indexOf ( ',' ) + 1 )
386
394
const url = `${ location . protocol } //${ location . host } ${ location . pathname } #${ data } ` ;
387
- location . href = url // update #anchor
388
395
progressFinish ( 200 , "" , url , "" , 0 , false )
389
396
} ;
390
397
reader . readAsDataURL ( new Blob ( [ new Uint8Array ( compressed ) ] ) ) ;
@@ -396,7 +403,7 @@ async function saveClientSide() {
396
403
}
397
404
398
405
async function saveServerSide ( ) {
399
- if ( ! allowSubmit ) {
406
+ if ( ! allowSubmit ( ) ) {
400
407
return
401
408
}
402
409
@@ -632,7 +639,7 @@ async function reserveAndUpdateLinkFields(file, nameHint) {
632
639
}
633
640
634
641
async function uploadFile ( file ) {
635
- if ( ! allowSubmit ) {
642
+ if ( ! allowSubmit ( ) ) {
636
643
return
637
644
}
638
645
0 commit comments