diff --git a/bower.json b/bower.json index be3a06a..4af0234 100644 --- a/bower.json +++ b/bower.json @@ -19,6 +19,7 @@ "vis": "~3.11.0", "jquery": "~2.1.3", "moment": "~2.9.0", - "bootstrap": "~3.3.4" + "bootstrap": "~3.3.4", + "sweetalert": "~0.5.0" } } diff --git a/pert.html b/pert.html index 0ee2805..c79fca9 100644 --- a/pert.html +++ b/pert.html @@ -4,6 +4,7 @@ Pert + @@ -17,6 +18,7 @@ + diff --git a/src/pert-ui.coffee b/src/pert-ui.coffee index a9b7427..b15cc35 100644 --- a/src/pert-ui.coffee +++ b/src/pert-ui.coffee @@ -32,10 +32,16 @@ buildGraph = (data) -> style: 'arrow' network = new vis.Network (document.getElementById 'pert'), { nodes: nodes, edges: connections }, options -data = localStorage.getItem 'ganttpert' -if data - jdata = JSON.parse data - if jdata - buildGraph new Pert(jdata).calculate() - else console.log 'error parsing json:\n'+data -else console.log 'no data' +fromLocalStorage = -> + data = localStorage.getItem 'ganttpert' + if data + try + jdata = JSON.parse data + catch e + return swal 'JSON Error', e, 'error' + if jdata + buildGraph new Pert(jdata).calculate() + else return swal 'Error', 'no JSON?', 'error' + else swal 'Error', 'no data to parse', 'error' + +fromLocalStorage()