File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 18
18
.json textarea ,
19
19
.json pre ,
20
20
.csv textarea ,
21
- .csv .table {
21
+ .csv .table ,
22
+ .json .drop {
22
23
width : 100% ; height : 100% ;
23
24
position : absolute;
24
25
}
25
26
.csv .table {overflow-x : scroll;}
26
27
.json pre {cursor : pointer;}
27
28
29
+ .json .drop {
30
+ opacity : 0.5 ; background-color : # 444 ;
31
+ vertical-align : middle; text-align : center;
32
+ color : # fff ; font-size : 40pt ;
33
+ padding-top : 75px ;
34
+ }
28
35
29
36
/* show empty textarea by default */
30
37
.json textarea {display : block;}
31
38
.json .rendered {display : none;}
39
+ .json .drop {display : none; z-index : 100 ;}
32
40
.csv textarea {}
33
41
.csv .rendered {display : none;}
34
42
Original file line number Diff line number Diff line change 43
43
// }
44
44
45
45
function doJSON ( ) {
46
+ // just in case
47
+ $ ( ".drop" ) . hide ( ) ;
48
+
46
49
// get input JSON, try to parse it
47
50
var newInput = $ ( ".json textarea" ) . val ( ) ;
48
51
if ( newInput == input ) return ;
275
278
} )
276
279
. keyup ( doJSON ) ; // harmless to repeat doJSON
277
280
278
- $ ( ".json" )
281
+ // go away
282
+ $ ( "body" ) . click ( function ( ) {
283
+ $ ( ".drop" ) . hide ( ) ;
284
+ } ) ;
285
+
286
+ $ ( document )
279
287
. on ( "dragenter" , function ( e ) {
280
288
e . preventDefault ( ) ;
281
289
e . stopPropagation ( ) ;
290
+ $ ( ".drop" ) . show ( ) ;
282
291
} )
283
292
. on ( "dragover" , function ( e ) {
284
293
e . preventDefault ( ) ;
285
294
e . stopPropagation ( ) ;
286
295
} )
296
+ . on ( "dragend" , function ( e ) {
297
+ e . preventDefault ( ) ;
298
+ e . stopPropagation ( ) ;
299
+ $ ( ".drop" ) . hide ( ) ;
300
+ } )
287
301
. on ( "drop" , function ( e ) {
302
+ $ ( ".drop" ) . hide ( ) ;
303
+
288
304
if ( e . originalEvent . dataTransfer ) {
289
305
if ( e . originalEvent . dataTransfer . files . length ) {
290
306
e . preventDefault ( ) ;
@@ -342,6 +358,7 @@ <h1>Convert JSON to CSV</h1>
342
358
< div class ="areas ">
343
359
< textarea class ="editing "> </ textarea >
344
360
< pre class ="rendered "> < code > </ code > </ pre >
361
+ < div class ="drop "> DROP JSON HERE</ div >
345
362
</ div >
346
363
347
364
< div class ="warning ">
You can’t perform that action at this time.
0 commit comments