<commit_before>"use strict"

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

var key="#47989379";


$('.save').click(function(){

  var d = {"nodes":[], "links":[]};
  console.log(nodes);
  for(var i = 0 ; i < nodes.length ; i++){
    var node = nodes[i];
    d['nodes'].push({
      "id":node.id,
      "type":node.type,
      "state":"perm",
      "start":node.start,
      "end":node.end,
      "status": node.status
    });
  }
  for(var j=0 ; j < links.length ; j++){
    var link = links[j];
    d['links'].push({
      "source":link.source.id,
      "target":link.target.id,
      "name":link.name
    });
  }
  console.log(JSON.stringify(d));
  localStorage.setItem(key, JSON.stringify(d));
});

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

  if(acceptLoad){
    links=[];
    nodes=[];
    var data = JSON.parse(localStorage.getItem(key));
    console.log(data);
    for(var i=0; i<data["nodes"].length; i++){
      var node=data.nodes[i];
      graph.addNodeComplete(node.id,node.type,"perm",new Date(node.start),new Date(node.end),node.status);
    }
<commit_msg>load: bail early if no data stored<commit_after>"use strict"

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

var key="#47989379";


$('.save').click(function(){

  var d = {"nodes":[], "links":[]};
  console.log(nodes);
  for(var i = 0 ; i < nodes.length ; i++){
    var node = nodes[i];
    d['nodes'].push({
      "id":node.id,
      "type":node.type,
      "state":"perm",
      "start":node.start,
      "end":node.end,
      "status": node.status
    });
  }
  for(var j=0 ; j < links.length ; j++){
    var link = links[j];
    d['links'].push({
      "source":link.source.id,
      "target":link.target.id,
      "name":link.name
    });
  }
  console.log(JSON.stringify(d));
  localStorage.setItem(key, JSON.stringify(d));
});

$('.load').click(function(){
  var acceptLoad=true;

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

  if(acceptLoad){
    links=[];
    nodes=[];
    var data = JSON.parse(localStorage.getItem(key));
    if (data == null) {
        console.log('load callback: no data to load');
        return;
    }
    console.log(data);
    for(var i=0; i<data["nodes"].length; i++){
      var node=data.nodes[i];
      graph.addNodeComplete(node.id,node.type,"perm",new Date(node.start),new Date(node.end),node.status);
    }

{'fraction_non_alphanumeric': 0.21419927390076643, 'fraction_numerical': 0.009681323114158934, 'mean_word_length': 3.1059602649006623, 'pattern_counts': {'":': 22, '<': 9, '<?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': '1732351', 'n_tokens_mistral': 893, 'n_tokens_neox': 873, 'n_words': 164}