Skip to content

Commit 0625041

Browse files
committed
add a drop indicator
1 parent 60e1a58 commit 0625041

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

assets/site.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ h1 {
1818
.json textarea,
1919
.json pre,
2020
.csv textarea,
21-
.csv .table {
21+
.csv .table,
22+
.json .drop {
2223
width: 100%; height: 100%;
2324
position: absolute;
2425
}
2526
.csv .table {overflow-x: scroll;}
2627
.json pre {cursor: pointer;}
2728

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+
}
2835

2936
/* show empty textarea by default */
3037
.json textarea {display: block;}
3138
.json .rendered {display: none;}
39+
.json .drop {display: none; z-index: 100;}
3240
.csv textarea {}
3341
.csv .rendered {display: none;}
3442

index.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
// }
4444

4545
function doJSON() {
46+
// just in case
47+
$(".drop").hide();
48+
4649
// get input JSON, try to parse it
4750
var newInput = $(".json textarea").val();
4851
if (newInput == input) return;
@@ -275,16 +278,29 @@
275278
})
276279
.keyup(doJSON); // harmless to repeat doJSON
277280

278-
$(".json")
281+
// go away
282+
$("body").click(function() {
283+
$(".drop").hide();
284+
});
285+
286+
$(document)
279287
.on("dragenter", function(e) {
280288
e.preventDefault();
281289
e.stopPropagation();
290+
$(".drop").show();
282291
})
283292
.on("dragover", function(e) {
284293
e.preventDefault();
285294
e.stopPropagation();
286295
})
296+
.on("dragend", function(e) {
297+
e.preventDefault();
298+
e.stopPropagation();
299+
$(".drop").hide();
300+
})
287301
.on("drop", function(e) {
302+
$(".drop").hide();
303+
288304
if (e.originalEvent.dataTransfer) {
289305
if (e.originalEvent.dataTransfer.files.length) {
290306
e.preventDefault();
@@ -342,6 +358,7 @@ <h1>Convert JSON to CSV</h1>
342358
<div class="areas">
343359
<textarea class="editing"></textarea>
344360
<pre class="rendered"><code></code></pre>
361+
<div class="drop">DROP JSON HERE</div>
345362
</div>
346363

347364
<div class="warning">

0 commit comments

Comments
 (0)