<commit_before>﻿/**
  * @constructor 
  */

var TabBase = new function()
{
  var self = this;
  var id_count = 1;
  var ids = {};

  this._ref_ids = {};

  var getId = function()
  {
    return 'tab-' + (id_count++).toString();
  }

  this.init = function(ref_id, name, has_close_button)
  {
    this.name = name;
    this.ref_id = ref_id;
    this.has_close_button = has_close_button;
    this._ref_ids[ref_id] = this;
    ids [ this.id = getId() ] = this;
  }

  this.getTabById = function(id)
  {
    return ids[id];
  }

  this.get_tab_by_ref_id = function(ref_id)
  {
    return this._ref_ids[ref_id] || null;
  };

  this._delete = function(id)
  {
    delete ids[id];
  }

  // These methods really belong to TopTabs, should make a TopTab class
  this._get_top_tab_element = function()
  {
    return document.querySelector("tab[ref-id='" + this.ref_id + "']");
  };

  this.set_badge = function(type, content)
  {
    var tab = this._get_top_tab_element();
    var badge = tab ? tab.querySelector(".badge") : null;
    if (badge)
    {
      badge.addClass(type || "");
      badge.textContent = content != null ? content : "";
    }
  };

  this.set_legend_info = function(text)
  {
    var tab = this._get_top_tab_element();
    var legends = tab.getElementsByClassName('block-content');
    var legend = legends[1];
    if (!legend)
    {
      legend = legends[0].parentNode.render(['span', '', 'class', 'block-content']);
    }
    if (legend)
    {
      legend.textContent = text;
    }
  }

  this.clear_badge = function()
  {
    this.set_badge("", null);
  };

  this.set_state = function(state)
  {
    var tab = this._get_top_tab_element();
    if (tab)
    {
      tab.setAttribute("data-state", state);
    }
  };

  this.clear_state = function()<commit_msg>Add a class to the top tab if it has legends on two rows.<commit_after>﻿/**
  * @constructor 
  */

var TabBase = new function()
{
  var self = this;
  var id_count = 1;
  var ids = {};

  this._ref_ids = {};

  var getId = function()
  {
    return 'tab-' + (id_count++).toString();
  }

  this.init = function(ref_id, name, has_close_button)
  {
    this.name = name;
    this.ref_id = ref_id;
    this.has_close_button = has_close_button;
    this._ref_ids[ref_id] = this;
    ids [ this.id = getId() ] = this;
  }

  this.getTabById = function(id)
  {
    return ids[id];
  }

  this.get_tab_by_ref_id = function(ref_id)
  {
    return this._ref_ids[ref_id] || null;
  };

  this._delete = function(id)
  {
    delete ids[id];
  }

  // These methods really belong to TopTabs, should make a TopTab class
  this._get_top_tab_element = function()
  {
    return document.querySelector("tab[ref-id='" + this.ref_id + "']");
  };

  this.set_badge = function(type, content)
  {
    var tab = this._get_top_tab_element();
    var badge = tab ? tab.querySelector(".badge") : null;
    if (badge)
    {
      badge.addClass(type || "");
      badge.textContent = content != null ? content : "";
    }
  };

  this.set_legend_info = function(text)
  {
    var tab = this._get_top_tab_element();
    var legends = tab && tab.getElementsByClassName("block-content");
    if (!legends)
      return;

    var legend = legends[1];
    if (text)
    {
      if (!legend)
      {
        tab.addClass("two-rows");
        legend = legends[0].parentNode.render(["span", "class", "block-content"]);
      }

      if (legend)
        legend.textContent = text;
    }
    else
    {
      if (legend)
      {
        legend.parentNode.removeChild(legend);
        tab.removeClass("two-rows");
      }
    }
  };

  this.clear_badge = function()
  {
    this.set_badge("", null);
  };

  this.set_state = function(state)
  {
    var tab = this._get_top_tab_element();
    if (tab)
    {
      tab.setAttribute("data-state", state);
    }
  };

  this.clear_state = function()
{'fraction_non_alphanumeric': 0.15204373860973705, 'fraction_numerical': 0.0015620932048945586, 'mean_word_length': 2.573953488372093, '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': '1319466', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1369, 'n_words': 264}