File tree 3 files changed +38
-17
lines changed
3 files changed +38
-17
lines changed Original file line number Diff line number Diff line change @@ -192,23 +192,26 @@ async function selectFolder() {
192
192
193
193
async function selectZip ( ) {
194
194
if ( interval ) clearInterval ( interval )
195
- selected = [ ]
196
195
197
196
const input = document . createElement ( "input" )
198
197
input . type = "file"
199
198
input . accept = ".zip"
200
- input . onchange = e => {
201
- new JSZip ( ) . loadAsync ( e . target . files [ 0 ] ) . then ( async zip => {
202
- console . log ( zip . files )
203
- for await ( const file of Object . values ( zip . files ) ) {
204
- selected . push ( {
205
- name : file . name ,
206
- content : await file . async ( "text" )
207
- } )
208
- }
209
- mainScan ( )
210
- } )
211
- }
199
+ input . onchange = e => handleZip ( e . target . files [ 0 ] )
200
+
212
201
if ( "showPicker" in HTMLInputElement . prototype ) input . showPicker ( )
213
202
else input . click ( )
214
203
}
204
+
205
+ function handleZip ( file ) {
206
+ selected = [ ]
207
+
208
+ new JSZip ( ) . loadAsync ( file ) . then ( async zip => {
209
+ for await ( const file of Object . values ( zip . files ) ) {
210
+ selected . push ( {
211
+ name : file . name ,
212
+ content : await file . async ( "text" )
213
+ } )
214
+ }
215
+ mainScan ( )
216
+ } )
217
+ }
Original file line number Diff line number Diff line change
1
+ User-agent: *
2
+ Allow: /
Original file line number Diff line number Diff line change @@ -44,18 +44,34 @@ window.addEventListener("dragover", event => {
44
44
event . preventDefault ( )
45
45
event . dataTransfer . dropEffect = "copy"
46
46
} )
47
-
48
- window . addEventListener ( "drop" , event => {
47
+ window . addEventListener ( "drop" , async event => {
49
48
event . stopPropagation ( )
50
49
event . preventDefault ( )
51
50
const fileList = event . dataTransfer . files
52
- console . log ( fileList )
51
+ if ( fileList [ 0 ] . name . endsWith ( ".zip" ) ) handleZip ( fileList [ 0 ] )
52
+ else {
53
+ selected = [ ]
54
+ for await ( const file of Object . values ( fileList ) ) {
55
+ selected . push ( {
56
+ name : file . name ,
57
+ content : await file . text ( )
58
+ } )
59
+ }
60
+ mainScan ( )
61
+ }
53
62
} )
54
63
window . addEventListener ( "paste" , async e => {
55
64
e . preventDefault ( )
56
65
if ( ! e . clipboardData . files . length ) return
57
66
const file = e . clipboardData . files [ 0 ]
58
- console . log ( await file . text ( ) )
67
+ if ( file . name . endsWith ( ".zip" ) ) handleZip ( file )
68
+ else {
69
+ selected = [ {
70
+ name : file . name ,
71
+ content : await file . text ( )
72
+ } ]
73
+ mainScan ( )
74
+ }
59
75
} )
60
76
61
77
const localize = string => string . toLocaleString ( getCookie ( "lang" ) || "en-US" )
You can’t perform that action at this time.
0 commit comments