<commit_before>// Examples:
//  Static: http://bl.ocks.org/mbostock/1667139

var endpoint = "http://localhost:3000/";

var width = window.innerWidth,
    height = window.innerHeight;

var circleRadius = 6;


// ================================================================================
// Leaflet map initialization
// ================================================================================

var map = L.map('map'),
    tileUrl = "http://otile2.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png",
    pointStyle = {},
    tileLayer = new L.TileLayer(tileUrl, {
      minZoom: 4, maxZoom: 13,
      opacity: 1
    }).addTo(map),
    geojsonLayer = new L.geoJson(null, {
      pointToLayer: function (feature, latlng) {
        return L.circleMarker(latlng, pointStyle);
      }
    }).addTo(map);

var resizeTimer;
var nodes = {},
    links = {};

var circle,
    text,
    link,
    label;

var force = d3.layout.force()
    .gravity(.09)
    .charge(-800)
    .linkDistance(200)
    .on("tick", tick)
    .size([width, height]);

var svg = d3.select("#graph");

var linkG = svg.append("g"),
    circleG = svg.append("g"),
    textG = svg.append("g"),
    labelG = svg.append("g");

d3.select(window).on("resize", function() {
  clearInterval(resizeTimer);
  resizeTimer = setInterval(resize, 20);
});

d3.selectAll("#name-input, #uri-input").on('keyup', function() {
  if(d3.event.keyCode == 13){
    var value = d3.select(this).property('value').trim();
    var id = d3.select(this).attr('id');
    if (id === "uri-input") {
      getData('uri', value);
    } else if (id === "name-input") {
      getData('name', value);
    }
  }
});

function resize() {
  width = window.innerWidth, height = window.innerHeight;
  svg.attr("width", width).attr("height", height);
  force.size([width, height]).resume();
}

function getData(type, query) {
  var url = endpoint + "q?" + type + "=" + query;
  d3.json(url, function(json) {
    if (json && json.nodes && Object.keys(json.nodes).length > 0 && json.links && Object.keys(json.links).length > 0) {

      location.hash = type + "=" + query;

      nodes = {};
      links = {};

      width = window.innerWidth, height = window.innerHeight;

      // Compute the distinct nodes from the links.
      for (var linkId in json.links) {

        var link = json.links[linkId];

        var source = nodes[link.source] || (nodes[link.source] = {
          uri: json.nodes[link.source].uri,
          name: json.nodes[link.source].name,
          geometry: json.nodes[link.source].geometry,<commit_msg>close box at new query<commit_after>// Examples:
//  Static: http://bl.ocks.org/mbostock/1667139

var endpoint = "http://localhost:3000/";

var width = window.innerWidth,
    height = window.innerHeight;

var circleRadius = 6;


// ================================================================================
// Leaflet map initialization
// ================================================================================

var map = L.map('map'),
    tileUrl = "http://otile2.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png",
    pointStyle = {},
    tileLayer = new L.TileLayer(tileUrl, {
      minZoom: 4, maxZoom: 13,
      opacity: 1
    }).addTo(map),
    geojsonLayer = new L.geoJson(null, {
      pointToLayer: function (feature, latlng) {
        return L.circleMarker(latlng, pointStyle);
      }
    }).addTo(map);

var resizeTimer;
var nodes = {},
    links = {};

var circle,
    text,
    link,
    label;

var force = d3.layout.force()
    .gravity(.09)
    .charge(-800)
    .linkDistance(200)
    .on("tick", tick)
    .size([width, height]);

var svg = d3.select("#graph");

var linkG = svg.append("g"),
    circleG = svg.append("g"),
    textG = svg.append("g"),
    labelG = svg.append("g");

d3.select(window).on("resize", function() {
  clearInterval(resizeTimer);
  resizeTimer = setInterval(resize, 20);
});

d3.selectAll("#name-input, #uri-input").on('keyup', function() {
  if(d3.event.keyCode == 13){
    var value = d3.select(this).property('value').trim();
    var id = d3.select(this).attr('id');
    if (id === "uri-input") {
      getData('uri', value);
    } else if (id === "name-input") {
      getData('name', value);
    }
  }
});

function resize() {
  width = window.innerWidth, height = window.innerHeight;
  svg.attr("width", width).attr("height", height);
  force.size([width, height]).resume();
}

function getData(type, query) {
  closeBox();
  var url = endpoint + "q?" + type + "=" + query;
  d3.json(url, function(json) {
    if (json && json.nodes && Object.keys(json.nodes).length > 0 && json.links && Object.keys(json.links).length > 0) {

      location.hash = type + "=" + query;

      nodes = {};
      links = {};

      width = window.innerWidth, height = window.innerHeight;

      // Compute the distinct nodes from the links.
      for (var linkId in json.links) {

        var link = json.links[linkId];

        var source = nodes[link.source] || (nodes[link.source] = {
          uri: json.nodes[link.source].uri,
          name: json.nodes[link.source].name,
          geometry: json.nodes[link.source].geometry,
{'fraction_non_alphanumeric': 0.23599453445246926, 'fraction_numerical': 0.016396642592231114, 'mean_word_length': 3.1189710610932475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7082433', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1649, 'n_words': 342}