summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-08-18 17:07:51 +0300
committerAlon Levy <alon@pobox.com>2014-08-18 17:07:51 +0300
commit341a67eb0b89a1be789f6a36d06f7db8c0ab523a (patch)
treeca8f68f9afcd4e272072067cab2ff76d2ff302d1 /scripts
parent65aa130540bf548d597daf9da2259e48d22a14b3 (diff)
oops, forgot drag and drop implementation
Diffstat (limited to 'scripts')
-rw-r--r--scripts/drag_n_drop.js25
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;
+});