<commit_before>/*global d3 */

// construct query string
var params = d3.select("#search-form");

if (!params.empty()) {
  var site_url = params.attr('data-site-url');
  var search_url = params.attr('data-search-url');
  var page = getParameterByName('page');
  if (page === null) { page = 1; }
  var query = getParameterByName('query');
  var tag = getParameterByName('tag');

  var query_url = encodeURI(search_url + "/pages?page=" + page);
  if (query !== null) { query_url += "&query=" + query; }
  if (tag !== null) { query_url += "&tag=" + tag; }
}

// load the data from the DataCite Labs API API
if (query) {
  d3.json(query)
    .get(function(error, json) {
      if (error) { return console.warn(error); }
      searchResult(json);

      json.meta["page"] = page;
      json.meta["total_pages"] = Math.ceil(json.meta.total/25);
      paginate(json, "#content");
  });
}

// add search results to page
function searchResult(json) {
  data = json.data;
  meta = json.meta;

  d3.select("#q").property("value", q);

  json.href = "?page={{number}}";
  if (q !== null) { json.href += "&q=" + q; }
  if (tag !== null) { json.href += "&tag=" + tag; }

  if (typeof data === "undefined" || data.length === 0) {
    d3.select("#content").text("")<commit_msg>use correct variable for query url<commit_after>/*global d3 */

// construct query string
var params = d3.select("#search-form");

if (!params.empty()) {
  var site_url = params.attr('data-site-url');
  var search_url = params.attr('data-search-url');
  var page = getParameterByName('page');
  if (page === null) { page = 1; }
  var query = getParameterByName('query');
  var tag = getParameterByName('tag');

  var query_url = encodeURI(search_url + "/pages?page=" + page);
  if (query !== null) { query_url += "&query=" + query; }
  if (tag !== null) { query_url += "&tag=" + tag; }
}

// load the data from the DataCite Labs API API
if (query_url) {
  d3.json(query_url)
    .get(function(error, json) {
      if (error) { return console.warn(error); }
      searchResult(json);

      json.meta["page"] = page;
      json.meta["total_pages"] = Math.ceil(json.meta.total/25);
      paginate(json, "#content");
  });
}

// add search results to page
function searchResult(json) {
  data = json.data;
  meta = json.meta;

  d3.select("#q").property("value", q);

  json.href = "?page={{number}}";
  if (q !== null) { json.href += "&q=" + q; }
  if (tag !== null) { json.href += "&tag=" + tag; }

  if (typeof data === "undefined" || data.length === 0) {
    d3.select("#content").text("")
{'fraction_non_alphanumeric': 0.20384163073304587, 'fraction_numerical': 0.007056056448451587, 'mean_word_length': 3.508833922261484, 'pattern_counts': {'":': 0, '<': 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': '189814', 'n_tokens_mistral': 892, 'n_tokens_neox': 881, 'n_words': 216}