<commit_before>dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.tree.ForestStoreModel");
dojo.require("dojox.layout.ContentPane");
dojo.require("dijit.Tree");
dojo.require("dojo.fx");

// note: virtroot, tree, and this.ranges are defined in the .html file

var infoDiv,
    infoDivID = 0,
    currentLine,
    signature,
    maincontent,
    signatureVisible = false;

function closeInfo() {
  if (!infoDiv) {
    return;
  }
  dojo.query(".highlighted").removeClass("highlighted");
  dojo.fx.wipeOut({ node: infoDiv.id,
                    duration: 500,
                  }).play();
  infoDiv = null;
}

function showInfo(node) {
  var type = node.className;
  var name = node.innerHTML;
  var line = node.parentNode.id.replace('l', '');
  var file = location.pathname.replace(virtroot + '/' + tree + '/', '').replace('.html', '');
  var url = "/dxr/getinfo.cgi?virtroot=" + virtroot + "&tree=" + tree + "&div=" + infoDivID++
  if (type == 's' || type == 's-fuzzy') { // statements have matching line number
    url += "&type=" + type + "&name=" + name + "&file=" +
	   file  + "&line=" + node.getAttribute("line").replace('l','');
  } else {
    url += "&type=" + type + "&name=" + name;
  }

  if (infoDiv) {
    closeInfo();
  }

  var id = 'info-div-' + infoDivID;
  infoDiv = new dojox.layout.ContentPane({
              id: id,
              style: "margin:0; padding:0; white-space: normal !important;"
  });
  infoDiv.placeAt(node.parentNode, "after");
  infoDiv.attr('href', url); //"/dxr/getinfo2.cgi?tree-id=" + ); // /dxr/info-test.html?id=" + infoDivID);
  location.hash = line + '/' + name;
  dojo.addClass(node, 'highlighted');

  // TODO: this needs to happen in an onLoad or onDownloadEnd event vs. here...
  dojo.fx.wipeIn({node: infoDiv.id, duration: 500}).play();
}

function init() {
  signature = dojo.byId('signature');
  maincontent = dojo.byId('maincontent');
  signatureVisible = false;

  if (!location.hash) {
    dojo.byId('search-box').focus();
    return;
  }

  // hash may have line number, or line number + name separated by /
  var parts = location.hash.split('#')[1].split('/');
  if (parts[0]) {
    var l;
    // Deal with #l323 vs. #323
    if (/^l\d+/(parts[0]))
      l = dojo.byId(parts[0]);
    else
      l = dojo.byId('l' + parts[0]);
    l.scrollIntoView();

    if (parts[1] && l.hasChildNodes()) {
      var children = l.childNodes;
      for (var i = 0; i < children.length; i++) {
        // TODO: what about case of multiple items in line with same name?
        if (children[i].innerHTML == parts[1]) {
          // XXX: what's up with this, dojo?
          setTimeout(function() { showInfo(children[i]); }, 0);
          break;
        }
      }
    } else {
      dojo.addClass(l, 'highlighted');
    }
  }
}

// Given a line number, try to find the ID for the containing function in the sidebar.
function findSidebarItem(line) {
  var ranges = this.ranges;
  if (!ranges || !ranges.length) {<commit_msg>Fix virtroot path issue in getinfo.cgi<commit_after>dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.tree.ForestStoreModel");
dojo.require("dojox.layout.ContentPane");
dojo.require("dijit.Tree");
dojo.require("dojo.fx");

// note: virtroot, tree, and this.ranges are defined in the .html file

var infoDiv,
    infoDivID = 0,
    currentLine,
    signature,
    maincontent,
    sep = '',
    signatureVisible = false;

function closeInfo() {
  if (!infoDiv) {
    return;
  }
  dojo.query(".highlighted").removeClass("highlighted");
  dojo.fx.wipeOut({ node: infoDiv.id,
                    duration: 500,
                  }).play();
  infoDiv = null;
}

function showInfo(node) {
  var type = node.className;
  var name = node.innerHTML;
  var line = node.parentNode.id.replace('l', '');
  var file = location.pathname.replace(virtroot + '/' + tree + '/', '').replace('.html', '');
  var url = virtroot + sep + "getinfo.cgi?virtroot=" + virtroot + "&tree=" + tree + "&div=" + infoDivID++
  if (type == 's' || type == 's-fuzzy') { // statements have matching line number
    url += "&type=" + type + "&name=" + name + "&file=" +
	   file  + "&line=" + node.getAttribute("line").replace('l','');
  } else {
    url += "&type=" + type + "&name=" + name;
  }

  if (infoDiv) {
    closeInfo();
  }

  var id = 'info-div-' + infoDivID;
  infoDiv = new dojox.layout.ContentPane({
              id: id,
              style: "margin:0; padding:0; white-space: normal !important;"
  });
  infoDiv.placeAt(node.parentNode, "after");
  infoDiv.attr('href', url); //"/dxr/getinfo2.cgi?tree-id=" + ); // /dxr/info-test.html?id=" + infoDivID);
  location.hash = line + '/' + name;
  dojo.addClass(node, 'highlighted');

  // TODO: this needs to happen in an onLoad or onDownloadEnd event vs. here...
  dojo.fx.wipeIn({node: infoDiv.id, duration: 500}).play();
}

function init() {
  signature = dojo.byId('signature');
  maincontent = dojo.byId('maincontent');
  signatureVisible = false;

  if (!location.hash) {
    dojo.byId('search-box').focus();
    return;
  }

  // hash may have line number, or line number + name separated by /
  var parts = location.hash.split('#')[1].split('/');
  if (parts[0]) {
    var l;
    // Deal with #l323 vs. #323
    if (/^l\d+/(parts[0]))
      l = dojo.byId(parts[0]);
    else
      l = dojo.byId('l' + parts[0]);
    l.scrollIntoView();

    if (parts[1] && l.hasChildNodes()) {
      var children = l.childNodes;
      for (var i = 0; i < children.length; i++) {
        // TODO: what about case of multiple items in line with same name?
        if (children[i].innerHTML == parts[1]) {
          // XXX: what's up with this, dojo?
          setTimeout(function() { showInfo(children[i]); }, 0);
          break;
        }
      }
    } else {
      dojo.addClass(l, 'highlighted');
    }
  }

  // Figure out the right path separator to use with virtroot
  sep = virtroot[virtroot.length - 1] === '/' ? '' : '/';
}

// Given a line number, try to find the ID for the containing function in the sidebar.
function findSidebarItem(line) {
  var ranges = this.ranges;
  if (!ranges || !ranges.length) {
{'fraction_non_alphanumeric': 0.1806009144350098, 'fraction_numerical': 0.008327890267798824, 'mean_word_length': 2.8305190744215136, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1480982', 'n_tokens_mistral': 2147, 'n_tokens_neox': 2084, 'n_words': 509}