<commit_before>"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();
        return false;
    })
});

$('.save-history').click(function() {
    if (graph.history === undefined) {
        throw "History is undefined";
    }
    graph.history.save_to_file();
});
<commit_msg>buttons: factor out really_load<commit_after>"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);
});

var really_load = function() {
  if (nodes.length > 0){
    return confirm('All unsaved changes will be deleted, are you sure?');
  }
  return true;
}

$('.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(){
  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();
        return false;
    })
});

$('.save-history').click(function() {
    if (graph.history === undefined) {
        throw "History is undefined";
    }
    graph.history.save_to_file();
});

{'fraction_non_alphanumeric': 0.227994227994228, 'fraction_numerical': 0.007936507936507936, 'mean_word_length': 3.169924812030075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312730', 'n_tokens_mistral': 947, 'n_tokens_neox': 928, 'n_words': 157}