diff options
| -rw-r--r-- | scripts/drag_n_drop.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/drag_n_drop.js b/scripts/drag_n_drop.js new file mode 100644 index 00000000..b5396447 --- /dev/null +++ b/scripts/drag_n_drop.js @@ -0,0 +1,25 @@ +$(function() { +$(document).on('drop', function(e) { + e.stopPropagation(); + e.preventDefault(); + console.log('document drop'); + var files = e.originalEvent.dataTransfer.files; + var file = files[files.length - 1]; + var fr = new FileReader(); + fr.onload = function() { + if (fr.readyState != 2) { + console.log('error reading from file'); + } else { + console.log(fr.result); + graph.load_from_json(fr.result); + } + } + fr.readAsText(file); +}); +$(document).on('dragover', function (e) +{ + e.stopPropagation(); + e.preventDefault(); +}); +document.bloated = true; +}); |
