<commit_before>// vim ts=2 expandtab:

bb = { version: "0.0.1" };

bb.browser = function() {
  var data,
      mainURL = "/bedserver/api/v1.0";

  function loadData(callback) {
    d3.json(mainURL + "/projects")
      .get(function (error, data) {
        if (error) console.log("Error loading data: " + error);
        else callback(data);
      });
  }

  function dataReady(data) {
    d3.select("#main").append("pre").text(JSON.stringify(data));
  }

  loadData(dataReady);
};<commit_msg>Basic logic for browsing. Not finished.<commit_after>// vim ts=2 expandtab:

bb = { version: "0.0.1" };

bb.browser = function() {
  var list,
      mainURL = "/bedserver/api/v1.0",
      main = d3.select("#main");

  list = (function() {
    var o = {},
        ds = {};

    o.addPrj = function(p) {
      ds[p] = {};
    };

    o.addSample = function(p, s) {
      ds[p][s] = 0;
    };

    o.print = function() {
      console.log(ds);
    };

    return o;
  })();

  function prjClick(name) {
    console.log("prj: " + name + " ");
  }

  function sampleClick(name) {
    console.log("sample" + " " + name);
  }

  function createEl(elText, _class) {
    main.append("input")
        .attr("type", "checkbox")
        .on("click", function() {
          if (_class == "project") prjClick(elText);
          if (_class == "sample") sampleClick(elText);
        });
    main.append("span").text(elText).attr("class", _class);
  }

  function loadData(callback) {
    d3.json(mainURL + "/projects")
      .get(function (error, data) {
        if (error) console.log("Error loading data: " + error);
        else callback(data.projects);
      });
  }

  // {"depth":["18277","36013"],"snp_density":["18277.YNPRC.Indian.chr1","19466.YNPRC.Indian.chr1"]}
  function renderView(projects) {
    Object.keys(projects).forEach(function (name) {
      list.addPrj(name);
      createEl(name, "project");
      projects[name].map(function(sample) {
        list.addSample(name, sample);
        createEl(sample, "sample");
      });
    });
  }

  loadData(renderView);
};
{'fraction_non_alphanumeric': 0.1912621359223301, 'fraction_numerical': 0.018932038834951457, 'mean_word_length': 2.6094570928196146, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '990091', 'n_tokens_mistral': 741, 'n_tokens_neox': 708, 'n_words': 125}