<commit_before>/**
 * Handle facet actions (add/remove facet filter from url) and redirect to that url
 * @param string action Accepted value "remove" / "add" what needs to be done with the facet
 * @param string groupName The facet group name used as facet group name in filter query
 * @param string facetValue The facet value that needs to be added or removed
 * @param string baseUrl The url to redirect to, optional parameter
 **/
var handleFacet = function(action, groupName, facetValue, baseUrl) {
  //Will be done later using smart tags / q boosts
  //TODO: Fix this and make it possible to add or remove tags
  var url = $.url(window.location.href);

  var newUrl = (typeof baseUrl !== "undefined") ? baseUrl : url.attr("path");
  var paramId = 0;
  var params = $.url(window.location.href).param();

  /*if (action == "add") {
    if (typeof params["ff"] === "undefined") {
      params["ff"] = new Object();
    }

    params["ff"][groupName] = groupName + "%5B" + facetValue + "%5D";
  } else {
    delete params["ff"][groupName];
  }*/

  //replacing [] with '' ff=publication-type%5BCase+Reports%5D
  
  console.log(params);
  //newUrl += ($.param(params)) ? "?" + ($.param(params)) : "";
  newUrl += "?ff="+groupName + "[" + facetValue + "]";
  console.log(newUrl);
  window.location.href = newUrl;
  //ReloadMain content doesn't work because jquery doesn't serialize the params correctly'
  //reloadMainContent(params, newUrl);
};

/** Handle events on clickable tags **/
var bindClickableTagsEvents = function(){
  $("#results .label-tag.clickable").unbind();
  $("#results .label-tag.clickable").click(function() {
    var filter = $(this).attr("data-filter").split(":");
    if (filter.length == 2) {
      var path = $.url(window.location.href).attr("path");
      var pieces = path.split("/");

      var baseUrl = path;
      /*if (pieces[2] != "search") {<commit_msg>Stacking url params to match the way they are processed by Search elements.<commit_after>/**
 * Handle facet actions (add/remove facet filter from url) and redirect to that url
 * @param string action Accepted value "remove" / "add" what needs to be done with the facet
 * @param string groupName The facet group name used as facet group name in filter query
 * @param string facetValue The facet value that needs to be added or removed
 * @param string baseUrl The url to redirect to, optional parameter
 **/
var handleFacet = function(action, groupName, facetValue, baseUrl) {
  //Will be done later using smart tags / q boosts
  //TODO: Fix this and make it possible to add or remove tags
  var url = $.url(window.location.href);

  var newUrl = (typeof baseUrl !== "undefined") ? baseUrl : url.attr("path");
  var paramId = 0;
  var params = $.url(window.location.href).param();
  
  if (action == "add") {
    if (typeof params["ff"] === "undefined") {
      params["ff"] = new Object();
    }

    if($.inArray(groupName + "[" + facetValue + "]", params["ff"]) == -1){
      params["ff"].push(groupName + "[" + facetValue + "]");
    }
  } else {
    delete params["ff"][groupName];
  }

  //replacing [] with '' ff=publication-type%5BCase+Reports%5D
  
  //newUrl += ($.param(params)) ? "?" + ($.param(params)) : "";
  newUrl += "?ff="+groupName + "[" + facetValue + "]";
  console.log(newUrl);
  //window.location.href = newUrl;
  //ReloadMain content doesn't work because jquery doesn't serialize the params correctly'
  //reloadMainContent(params, newUrl);
};

/** Handle events on clickable tags **/
var bindClickableTagsEvents = function(){
  $("#results .label-tag.clickable").unbind();
  $("#results .label-tag.clickable").click(function() {
    var filter = $(this).attr("data-filter").split(":");
    if (filter.length == 2) {
      var path = $.url(window.location.href).attr("path");
      var pieces = path.split("/");

      var baseUrl = path;
      /*if (pieces[2] != "search") {
{'fraction_non_alphanumeric': 0.16345412490362374, 'fraction_numerical': 0.003341043433564636, 'mean_word_length': 3.6333333333333333, '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': '5978935', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1172, 'n_words': 380}