diff options
| author | Alon Levy <alon@pobox.com> | 2014-09-29 20:46:19 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-09-29 20:46:19 +0300 |
| commit | 3e3c130b3eede854db602259215866a409618967 (patch) | |
| tree | 4c3ff71bc41a7d7571bef35e0168b5b4b1ddebca /scripts/buttons.js | |
| parent | be7864b7a35f7dfaa825ae0a4c7cbce1c62e0368 (diff) | |
buttons/index: add file load button
Diffstat (limited to 'scripts/buttons.js')
| -rw-r--r-- | scripts/buttons.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/buttons.js b/scripts/buttons.js index 6ae25d1f..69f0a6c7 100644 --- a/scripts/buttons.js +++ b/scripts/buttons.js @@ -24,6 +24,31 @@ var really_load = function() { return true; } +$('.file-load').on('change', function(event) { + var file = event.target.files[0]; + var reader; + + if (!really_load()) { + return; + } + if (file === undefined) { + return; + } + console.log(file); + reader = new FileReader(); + reader.onload = (function(theFile) { + return function(e) { + var result = e.target.result; + if (e.target.readyState === FileReader.DONE) { + console.log('done reading ' + theFile.name); + console.log('got #' + result.length + ' bytes in ' + typeof(result)); + graph.load_from_json(result); + } + } + })(file); + reader.readAsText(file, "text/javascript"); +}); + $('.local-storage-load').click(function(){ if (!really_load()) { return; |
