summaryrefslogtreecommitdiff
path: root/scripts/buttons.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-08-17 13:33:14 +0300
committerAlon Levy <alon@pobox.com>2014-08-17 13:52:10 +0300
commitd42fe8552c83fe30e559358440c3fc0cfaf065ca (patch)
treeecd5ecfb4541195070d20fc483dd8b259de0a19b /scripts/buttons.js
parentddb56d7c7c01244f043a3eadab01c6d2dfefb3a0 (diff)
load: bail early if no data stored
Diffstat (limited to 'scripts/buttons.js')
-rw-r--r--scripts/buttons.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/buttons.js b/scripts/buttons.js
index 65536f35..79a961ff 100644
--- a/scripts/buttons.js
+++ b/scripts/buttons.js
@@ -34,6 +34,7 @@ $('.save').click(function(){
$('.load').click(function(){
var acceptLoad=true;
+
if (nodes.length>0){
acceptLoad = confirm('All unsaved changes will be deleted, are you sure?');
}
@@ -42,6 +43,10 @@ $('.load').click(function(){
links=[];
nodes=[];
var data = JSON.parse(localStorage.getItem(key));
+ if (data == null) {
+ console.log('load callback: no data to load');
+ return;
+ }
console.log(data);
for(var i=0; i<data["nodes"].length; i++){
var node=data.nodes[i];