summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-09-29 20:39:18 +0300
committerAlon Levy <alon@pobox.com>2014-09-29 20:39:18 +0300
commitc46887f5fb8c1f367e1fc5c9f4badc8525bce0b3 (patch)
tree7c1d7c60a70028dbfc901ce279cdfe8bf61512dd
parented07d87f3d845b9cd0210fbb008ea9e6cfe95a76 (diff)
buttons: factor out really_load
-rw-r--r--scripts/buttons.js23
1 files changed, 12 insertions, 11 deletions
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(){