@@ -9,15 +9,15 @@ import { syncToLocal } from '../scripts/global';
9
9
10
10
const itSupportsDragging = ( ) => {
11
11
const div = document . createElement ( 'div' ) ;
12
- return ( 'draggable' in div ) || ( 'ondragstart' in div && 'ondrop' in div ) ;
12
+ return 'draggable' in div || ( 'ondragstart' in div && 'ondrop' in div ) ;
13
13
} ;
14
14
15
15
const itSupportsFileReader = ( ) => 'FileReader' in window ;
16
16
17
17
const itSupportsFormData = ( ) => 'FormData' in window ;
18
18
19
- const itSupportsDragDropUpload = ( ) => itSupportsDragging ( ) && itSupportsFileReader ( )
20
- && itSupportsFormData ( ) ;
19
+ const itSupportsDragDropUpload = ( ) =>
20
+ itSupportsDragging ( ) && itSupportsFileReader ( ) && itSupportsFormData ( ) ;
21
21
const currentCodeSet = { } ;
22
22
const $synonym = { include : { } , exclude : { } } ;
23
23
const $terminologyRadio = { } ;
@@ -145,26 +145,33 @@ const wireup = () => {
145
145
const files = droppedFiles ;
146
146
const reader = new FileReader ( ) ;
147
147
reader . onload = function readerOnLoad ( ) {
148
- $form . removeClass ( 'is-uploading' ) ; // .removeClass('is-error');
148
+ $form . removeClass ( 'is-uploading' ) ; // .removeClass('is-error');
149
149
const newZip = new JSZip ( ) ;
150
150
// more files !
151
151
newZip
152
152
. loadAsync ( reader . result )
153
153
. then ( ( zip ) => {
154
154
// you now have every files contained in the loaded zip
155
155
if ( ! zip ) displayError ( null , 'No zip file found.' ) ;
156
- else if ( ! zip . files || Object . keys ( zip . files ) . length !== 2 ) displayError ( null , 'Zip file should contain two files.' ) ;
157
- else if ( Object . keys ( zip . files ) . filter ( v => v . toLowerCase ( ) . indexOf ( 'metadata' ) > - 1 ) . length !== 1 ) {
156
+ else if ( ! zip . files || Object . keys ( zip . files ) . length !== 2 )
157
+ displayError ( null , 'Zip file should contain two files.' ) ;
158
+ else if (
159
+ Object . keys ( zip . files ) . filter ( ( v ) => v . toLowerCase ( ) . indexOf ( 'metadata' ) > - 1 )
160
+ . length !== 1
161
+ ) {
158
162
displayError ( null , "Need precisely one file with 'metadata' in it's name." ) ;
159
163
} else {
160
- const metadataFilename = Object . keys ( zip . files ) . filter ( v => v . toLowerCase ( ) . indexOf ( 'metadata' ) > - 1 ) [ 0 ] ;
161
- const codesetFilename = Object . keys ( zip . files ) . filter ( v => v . toLowerCase ( ) . indexOf ( 'metadata' ) === - 1 ) [ 0 ] ;
164
+ const metadataFilename = Object . keys ( zip . files ) . filter (
165
+ ( v ) => v . toLowerCase ( ) . indexOf ( 'metadata' ) > - 1
166
+ ) [ 0 ] ;
167
+ const codesetFilename = Object . keys ( zip . files ) . filter (
168
+ ( v ) => v . toLowerCase ( ) . indexOf ( 'metadata' ) === - 1
169
+ ) [ 0 ] ;
162
170
163
171
const metaDataPromise = zip . file ( metadataFilename ) . async ( 'string' ) ;
164
172
const codeSetPromise = zip . file ( codesetFilename ) . async ( 'string' ) ;
165
173
166
- Promise
167
- . all ( [ metaDataPromise , codeSetPromise ] )
174
+ Promise . all ( [ metaDataPromise , codeSetPromise ] )
168
175
. then ( ( fileContents ) => {
169
176
readMetaDataFile ( fileContents [ 0 ] ) ;
170
177
readCodeSetFile ( fileContents [ 1 ] ) ;
@@ -184,7 +191,6 @@ const wireup = () => {
184
191
return reader . readAsArrayBuffer ( files [ 0 ] ) ;
185
192
} ) ;
186
193
187
-
188
194
// restart the form if has a state of error/success
189
195
190
196
$restart . on ( 'click' , ( evt ) => {
@@ -204,8 +210,12 @@ const wireup = () => {
204
210
205
211
// Firefox focus bug fix for file input
206
212
$input
207
- . on ( 'focus' , ( ) => { $input . addClass ( 'has-focus' ) ; } )
208
- . on ( 'blur' , ( ) => { $input . removeClass ( 'has-focus' ) ; } ) ;
213
+ . on ( 'focus' , ( ) => {
214
+ $input . addClass ( 'has-focus' ) ;
215
+ } )
216
+ . on ( 'blur' , ( ) => {
217
+ $input . removeClass ( 'has-focus' ) ;
218
+ } ) ;
209
219
} ) ;
210
220
} ;
211
221
@@ -215,4 +225,3 @@ const show = () => {
215
225
} ;
216
226
// params, state, url
217
227
export { show as default } ;
218
-
0 commit comments