summaryrefslogtreecommitdiff
path: root/scripts/buttons.js
blob: 8af525c29bcb01adf830b076fc4c1ddac29f72e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict"

$('.tutorial').click(function(){});

var key="#47989379";


$('.save').click(function(){
    var json = graph.save_to_json();
    console.log(json);
    localStorage.setItem(key, json);
});

$('.saveToFile').click(function() {
    var json = graph.save_to_json();
    console.log(json);
    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?');
  }

  if(acceptLoad){
    links=[]; // TODO - not global
    nodes=[]; // TODO - not global
    var json_blob = localStorage.getItem(key)
    graph.load_from_json(json_blob);
  }

});

$('.deliverabletest').click(function(){
  deliverableTest();
});

$('.set-user').click(function() {
    $('.set-user').hide();
    $('.set-user-form').show();
    $('.set-user-form').submit(function() {
        var user = $('.set-user-input').val();
        graph.set_user(user);
        $('.set-user').html('user: ' + user);
        $('.set-user').show();
        $('.set-user-form').hide();
        $('.save-history').show();
    })
});