File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -322,13 +322,32 @@ windowLoaded
322322 } ) ;
323323
324324 fwHex . addEventListener ( "drop" , ( event ) => {
325- if ( event . dataTransfer . types . includes ( "Files" ) && event . dataTransfer . files . length > 0 ) {
326- // Assign the dropped file(s) to file input and manually trigger
327- // its change event.
328- fwTabFile . checked = true ;
329- fwFile . files = event . dataTransfer . files ;
330- fwFile . dispatchEvent ( new Event ( "change" ) ) ;
325+ for ( const item of event . dataTransfer . items ) {
326+ if ( item . kind === "string" && item . type === "text/uri-list" ) {
327+ // Set the dropped URI as URL input value and trigger its
328+ // input event.
329+ // Why can't getAsString() just return the damned string!?
330+ item . getAsString ( ( uri ) => {
331+ fwTabUrl . checked = true ;
332+ fwUrl . value = uri ;
333+ fwUrl . dispatchEvent ( new Event ( "input" ) ) ;
334+ fwUrlLoad . dispatchEvent ( new Event ( "click" ) ) ;
335+ } ) ;
336+
337+ // Don't continue to look at any other items.
338+ break ;
339+ } else if ( item . kind === "file" ) {
340+ // Assign the dropped file(s) to file input and manually
341+ // trigger its change event.
342+ fwTabFile . checked = true ;
343+ fwFile . files = event . dataTransfer . files ;
344+ fwFile . dispatchEvent ( new Event ( "change" ) ) ;
345+
346+ // Don't continue to look at any other items.
347+ break ;
348+ }
331349 }
350+
332351 event . preventDefault ( ) ;
333352 } ) ;
334353
You can’t perform that action at this time.
0 commit comments