From d42fe8552c83fe30e559358440c3fc0cfaf065ca Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 17 Aug 2014 13:33:14 +0300 Subject: load: bail early if no data stored --- scripts/buttons.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts/buttons.js') 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