From c46887f5fb8c1f367e1fc5c9f4badc8525bce0b3 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 29 Sep 2014 20:39:18 +0300 Subject: buttons: factor out really_load --- scripts/buttons.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/buttons.js b/scripts/buttons.js index 346e576b..957b1515 100644 --- a/scripts/buttons.js +++ b/scripts/buttons.js @@ -17,20 +17,21 @@ $('.saveToFile').click(function() { location.href = 'data:text/json;base64,' + window.btoa(json); }); -$('.load').click(function(){ - var acceptLoad=true; - - if (nodes.length>0){ - acceptLoad = confirm('All unsaved changes will be deleted, are you sure?'); +var really_load = function() { + if (nodes.length > 0){ + return confirm('All unsaved changes will be deleted, are you sure?'); } + return true; +} - if(acceptLoad){ - links=[]; // TODO - not global - nodes=[]; // TODO - not global - var json_blob = localStorage.getItem(key) - graph.load_from_json(json_blob); +$('.load').click(function(){ + if (!really_load()){ + return; } - + links=[]; // TODO - not global + nodes=[]; // TODO - not global + var json_blob = localStorage.getItem(key) + graph.load_from_json(json_blob); }); $('.deliverabletest').click(function(){ -- cgit v1.3.1