<commit_before>/*
* MartSearch - the main object.  This is the governing object for the 
* whole search application.
*/
MartSearch = function ( params ) {
  var ms = this;
  
  // Set the base url if appropriate
  ms.base_url = params.base_url ? params.base_url : "";
  
  // Instantiate the messaging object
  ms.message = new Message({ base_url: ms.base_url });
  
  // Load in the config file
  jQuery.ajax({
    url:      ms.base_url + "/conf/martsearch.json",
    type:     'GET',
    dataType: 'json',
    async:    false,
    success:  function (conf) {
      jQuery.extend( params, conf );
    },
    error:    function( XMLHttpRequest, textStatus, errorThrown ) {
      init_status = false;
      log.error( "Error initializing MartSearch - " + textStatus + " ("+ XMLHttpRequest.status +")" );
      ms.message.add(
        "Error initializing MartSearch - " + textStatus + " ("+ XMLHttpRequest.status +") please reload the page.",
        "error",
        XMLHttpRequest.responseText
      );
    }
  });
  
  // Configure and instantiate the index object
  jQuery.extend( params.index_conf, { base_url: ms.base_url } );
  ms.index = new Index( params.index_conf );
  
  // Load the browsable content configuration
  ms.browsable_content = params.browsable_content;
  
  // Build the test_conf into the MartSearch object
  ms.test_conf = params.test_conf;
  
  // Placeholder for dataset objects
  ms.datasets = [];
  
  ms.current_query = "";
};

MartSearch.prototype = {
  
  /*
  * Initializes the MartSearch application by loading config files and 
  * adding observers to the appropriate DOM elements.
  * 
  * @alias    MartSearch.init
  * @return   {Boolean}
  */
  init: function() {
    // scope the local object
    var ms = this;
    
    // Set a variable to determine the status of the function run
    var init_status = true;
    
    /*
    * Make the interface active...
    */
    
    // Make the page tabbed
    jQuery('#tabs').tabs({ fx: { opacity: 'toggle' } });
    
    // Override the submit function on the search form
    jQuery('#mart_search').submit( function(){
      ms.search( jQuery('#query').val(), 0, 'search' );
      return false;
    });
    
    // Activate links between the tabs
    jQuery('a.help_link').click( function()  { jQuery('#tabs').tabs('select', 3); return false; } );
    jQuery('a.about_link').click( function() { jQuery('#tabs').tabs('select', 4); return false; } );
    <commit_msg>Updated the search form override: * to hide the intro text on submit * on submission of an empty string, it removes any previous results and re-displays the intro text<commit_after>/*
* MartSearch - the main object.  This is the governing object for the 
* whole search application.
*/
MartSearch = function ( params ) {
  var ms = this;
  
  // Set the base url if appropriate
  ms.base_url = params.base_url ? params.base_url : "";
  
  // Instantiate the messaging object
  ms.message = new Message({ base_url: ms.base_url });
  
  // Load in the config file
  jQuery.ajax({
    url:      ms.base_url + "/conf/martsearch.json",
    type:     'GET',
    dataType: 'json',
    async:    false,
    success:  function (conf) {
      jQuery.extend( params, conf );
    },
    error:    function( XMLHttpRequest, textStatus, errorThrown ) {
      init_status = false;
      log.error( "Error initializing MartSearch - " + textStatus + " ("+ XMLHttpRequest.status +")" );
      ms.message.add(
        "Error initializing MartSearch - " + textStatus + " ("+ XMLHttpRequest.status +") please reload the page.",
        "error",
        XMLHttpRequest.responseText
      );
    }
  });
  
  // Configure and instantiate the index object
  jQuery.extend( params.index_conf, { base_url: ms.base_url } );
  ms.index = new Index( params.index_conf );
  
  // Load the browsable content configuration
  ms.browsable_content = params.browsable_content;
  
  // Build the test_conf into the MartSearch object
  ms.test_conf = params.test_conf;
  
  // Placeholder for dataset objects
  ms.datasets = [];
  
  ms.current_query = "";
};

MartSearch.prototype = {
  
  /*
  * Initializes the MartSearch application by loading config files and 
  * adding observers to the appropriate DOM elements.
  * 
  * @alias    MartSearch.init
  * @return   {Boolean}
  */
  init: function() {
    // scope the local object
    var ms = this;
    
    // Set a variable to determine the status of the function run
    var init_status = true;
    
    /*
    * Make the interface active...
    */
    
    // Make the page tabbed
    jQuery('#tabs').tabs({ fx: { opacity: 'toggle' } });
    
    // Override the submit function on the search form
    jQuery('#mart_search').submit( function(){
      if ( jQuery('#query').val() !== "" ) {
        // Clear the intro text and submit the search
        jQuery('#intro_text').fadeOut("fast");
        ms.search( jQuery('#query').val(), 0, 'search' );
      } else {
        // Clear any messages and previous results
        if ( jQuery(".messages").html() !== "" ) { ms.message.clear(); }
        jQuery("#search_result_list").html("");
        jQuery("#search_results .pagination").html("");
        jQuery('#intro_text').fadeIn("fast");
      };
      return false;
    });
    
    // Activate links between the tabs
    jQuery('a.help_link').click( function()  { jQuery('#tabs').tabs('select', 3); return false; } );
    jQuery('a.about_link').click( function() { jQuery('#tabs').tabs('select', 4); return false; } );
    
{'fraction_non_alphanumeric': 0.1328722242446305, 'fraction_numerical': 0.0010921004732435385, 'mean_word_length': 2.6438992042440317, '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': '757724', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1610, 'n_words': 472}