<commit_before>/**
 * A Tab interface to organize Placeholder panes.
 */
var cp_tabs = {};

(function($)
{

  // Cached DOM objects
  var $empty_tabnav = null;
  var $empty_tab = null;
  var $placeholder_inline;
  var $loading_tabnav;
  var $orphaned_tabnav;
  var $orphaned_tab;
  var $tabnav_root;
  var $tabs_root;

  var placeholder_group_prefix = null;
  var placeholder_id_prefix = null;
  var plahceolder_name_prefix = null;

  // Allow debugging
  var stub = function() {};
  var console = window.console || {'log': stub, 'error': stub, 'warn': stub};


  cp_tabs.init = function()
  {
    // Get the tab templates
    $empty_tabnav = $("#cp-tabnav-template");
    $empty_tab = $(".cp-tab.empty-form");
    $loading_tabnav = $("#cp-tabnav-loading");
    $orphaned_tabnav = $("#cp-tabnav-orphaned");
    $orphaned_tab = $("#tab-orphaned");
    $tabnav_root = $("#cp-tabnav");
    $tabs_root = $("#cp-tabmain");

    // Bind events
    $tabnav_root.find("a").mousedown( cp_tabs.onTabMouseDown ).click( cp_tabs.onTabClick );

    $placeholder_inline = $(".inline-placeholder-group");
    placeholder_group_prefix = $placeholder_inline.attr('id').replace(/-group$/, '');
    placeholder_id_prefix = 'id_' + placeholder_group_prefix;   // HACK: assume id_%s as auto_id.

    // Improve quick editing a lot:
    cp_tabs._select_previous_or_first_tab();

    // Hide empty message
    if( cp_data.get_placeholders().length )
      $("#cp-tabs-empty").hide();
  }


  /**
   * Get a fallback tab to store an orphaned item.
   */
  cp_tabs.get_fallback_pane = function(role, last_known_nr)
  {
    $orphaned_tabnav.css("display", "inline");
    return cp_data.get_object_for_pane($("#tab-orphaned"), undefined);
  }


  /**
   * Hide the tab to display an orphaned item.
   */
  cp_tabs.hide_fallback_pane = function()
  {
    $orphaned_tabnav.hide();
    $orphaned_tab.hide();<commit_msg>Bail out with JavaScript warning when missing the inline-placeholder-group<commit_after>/**
 * A Tab interface to organize Placeholder panes.
 */
var cp_tabs = {};

(function($)
{

  // Cached DOM objects
  var $empty_tabnav = null;
  var $empty_tab = null;
  var $placeholder_inline;
  var $loading_tabnav;
  var $orphaned_tabnav;
  var $orphaned_tab;
  var $tabnav_root;
  var $tabs_root;

  var placeholder_group_prefix = null;
  var placeholder_id_prefix = null;
  var plahceolder_name_prefix = null;

  // Allow debugging
  var stub = function() {};
  var console = window.console || {'log': stub, 'error': stub, 'warn': stub};


  cp_tabs.init = function()
  {
    // Get the tab templates
    $empty_tabnav = $("#cp-tabnav-template");
    $empty_tab = $(".cp-tab.empty-form");
    $loading_tabnav = $("#cp-tabnav-loading");
    $orphaned_tabnav = $("#cp-tabnav-orphaned");
    $orphaned_tab = $("#tab-orphaned");
    $tabnav_root = $("#cp-tabnav");
    $tabs_root = $("#cp-tabmain");

    // Bind events
    $tabnav_root.find("a").mousedown( cp_tabs.onTabMouseDown ).click( cp_tabs.onTabClick );

    $placeholder_inline = $(".inline-placeholder-group");
    if($placeholder_inline.length == 0)
      console.error("Missing .inline-placeholder-group in the page!");

    placeholder_group_prefix = $placeholder_inline.attr('id').replace(/-group$/, '');
    placeholder_id_prefix = 'id_' + placeholder_group_prefix;   // HACK: assume id_%s as auto_id.

    // Improve quick editing a lot:
    cp_tabs._select_previous_or_first_tab();

    // Hide empty message
    if( cp_data.get_placeholders().length )
      $("#cp-tabs-empty").hide();
  }


  /**
   * Get a fallback tab to store an orphaned item.
   */
  cp_tabs.get_fallback_pane = function(role, last_known_nr)
  {
    $orphaned_tabnav.css("display", "inline");
    return cp_data.get_object_for_pane($("#tab-orphaned"), undefined);
  }


  /**
   * Hide the tab to display an orphaned item.
   */
  cp_tabs.hide_fallback_pane = function()
  {
    $orphaned_tabnav.hide();
    $orphaned_tab.hide();
{'fraction_non_alphanumeric': 0.1539630286148392, 'fraction_numerical': 0.0002532286654849329, 'mean_word_length': 3.5454545454545454, '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': '1559757', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1334, 'n_words': 282}