<commit_before>////
//// A full take on a production live search for GOlr.
//// It ends up being a light wrapping around the search_pane widget.
//// 

//
function LiveSearchGOlrInit(){

    // Logger.
    var logger = new bbop.logger();
    logger.DEBUG = true;
    function ll(str){ logger.kvetch('LS: ' + str); }    

    // Start messages.
    ll('');
    ll('LiveSearchGOlr.js');
    ll('LiveSearchGOlrInit start...');

    // Aliases.
    var loop = bbop.core.each;

    // Make unnecessary things roll up.
    amigo.ui.rollup(["inf01"]);

    // Use jQuery UI to tooltip-ify doc.
    var tt_args = {'position': {'my': 'left bottom', 'at': 'right top'}};
    jQuery('.bbop-js-tooltip').tooltip(tt_args);

    ///
    /// A description of the active buttons and what to do when they
    /// are clicked. Very likely the only thing that you'd have to
    /// change on this page.
    ///

    function _establish_buttons(personality, manager){
	if( personality == 'bbop_ann' ){
	    manager.clear_buttons();
	    manager.add_button(facet_matrix_button);
	    manager.add_button(gaf_download_button);
	    //manager.add_button(gaf_galaxy_button);
	    manager.add_button(bookmark_button);
	}else if( personality == 'bbop_ont' ){
	    manager.clear_buttons();
	    manager.add_button(id_download_button);
	    //manager.add_button(id_term_label_galaxy_button);
	    manager.add_button(bookmark_button);
	}else if( personality == 'bbop_bio' ){
	    manager.clear_buttons();
	    manager.add_button(id_download_button);
	    //manager.add_button(id_symbol_galaxy_button);
	    manager.add_button(bookmark_button);
	//}else if( personality == 'bbop_ann_ev_agg' ){
	}else{
	    manager.clear_buttons();
	}
    }

    var active_classes = [
	{
	    id: 'bbop_ann', 
	    on_click: function(manager){
		manager.add_query_filter('document_category',
					 'annotation', ['*']);
		_establish_buttons('bbop_ann', manager);
	    }
	},
	{
	    id: 'bbop_ont',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'ontology_class', ['*']);
		_establish_buttons('bbop_ont', manager);
	    }
	},
	{
	    id: 'bbop_bio',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'bioentity', ['*']);
		_establish_buttons('bbop_bio', manager);
	    }
	},
	{
	    id: 'bbop_family',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'family', ['*']);
		_establish_buttons('bbop_family', manager);
	    }
	},
	{
	    id: 'bbop_general',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'general', ['*']);
		_establish_buttons('bbop_general', manager);
	    }
	},
	{
	    id: 'bbop_ann_ev_agg',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
    					 'annotation_evidence_aggregate',['*']);
		_establish_buttons('bbop_ann_ev_agg', manager);
	    }
	}
    ];

    // Helper function to pull out class by id.
    function _get_active_class(cid){
	var retcls = null;
	loop(active_classes,
	     function(acls, index){
		 //ll("index: " + index);		 
		 //ll("acls['id']: " + acls['id']);		 
		 if( acls['id'] == cid ){
		     retcls = acls;
		 }
	     });
	return retcls;
    }

    ///
    /// Tabify the layout if we can (may be in a non-tabby version).
    ///

    // var dtabs = jQuery("#display-tabs");
    // if( dtabs ){
    // 	ll('Apply tabs...');
    // 	jQuery("#display-tabs").tabs();
    // 	//dtabs.tabs();
    // 	jQuery("#display-tabs").tabs('select', 0);
    // }

    ///
    /// Ready the configuration that we'll use.
    ///

    var gconf = new bbop.golr.conf(amigo.data.golr);
    var sd = new amigo.data.server();
    var linker = new amigo.linker();
    var solr_server = sd.golr_base();
    var div_id = 'display-general-search';

    ///
    /// Defined some useful buttons.
    ///

    // Download limit.    
    //var dlimit = 7500;
    var dlimit = 100000;

    // Global download properties.
    var _dl_props = {
	'entity_list': null,
	'rows': dlimit
    };

    // Define the rows that we'll use to create a psuedo-GAF.
    var _gaf_fl = [
	'source', // c1
	'bioentity_internal_id', // c2; not bioentity
	'bioentity_label', // c3
	'qualifier', // c4
	'annotation_class', // c5
	'reference', // c6
	'evidence_type', // c7
	'evidence_with', // c8
	'aspect', // c9
	'bioentity_name', // c10
	'synonym', // c11
	'type', // c12
	'taxon', // c13
	'date', // c14
	'assigned_by', // c15
	'annotation_extension_class', // c16
	'bioentity_isoform' // c17
    ];

    // Create button templates to use from our library.
    var btmpl = bbop.widget.display.button_templates;

    var id_download_button =
	btmpl.field_download('Download IDs (up to ' +
			     dlimit + ')',
			     dlimit, ['id']);
    var gaf_download_button =
	btmpl.field_download('GAF chunk download (up to ' +
			     dlimit + ')',
			     dlimit, _gaf_fl);
    var bookmark_button = btmpl.bookmark(linker);
    var facet_matrix_button = btmpl.open_facet_matrix(gconf, sd);
    var gaf_galaxy_button =
	btmpl.send_fields_to_galaxy('Send GAF chunk to Galaxy (up to ' +
				    dlimit + ')',
				    dlimit, _gaf_fl, global_galaxy_url);
    var id_term_label_galaxy_button =
	btmpl.send_fields_to_galaxy('Send IDs and names to Galaxy (up to ' +
				    dlimit + ')',
				    dlimit, ['annotation_class',<commit_msg>ids and label in ont download<commit_after>////
//// A full take on a production live search for GOlr.
//// It ends up being a light wrapping around the search_pane widget.
//// 

//
function LiveSearchGOlrInit(){

    // Logger.
    var logger = new bbop.logger();
    logger.DEBUG = true;
    function ll(str){ logger.kvetch('LS: ' + str); }    

    // Start messages.
    ll('');
    ll('LiveSearchGOlr.js');
    ll('LiveSearchGOlrInit start...');

    // Aliases.
    var loop = bbop.core.each;

    // Make unnecessary things roll up.
    amigo.ui.rollup(["inf01"]);

    // Use jQuery UI to tooltip-ify doc.
    var tt_args = {'position': {'my': 'left bottom', 'at': 'right top'}};
    jQuery('.bbop-js-tooltip').tooltip(tt_args);

    ///
    /// A description of the active buttons and what to do when they
    /// are clicked. Very likely the only thing that you'd have to
    /// change on this page.
    ///

    function _establish_buttons(personality, manager){
	if( personality == 'bbop_ann' ){
	    manager.clear_buttons();
	    manager.add_button(facet_matrix_button);
	    manager.add_button(gaf_download_button);
	    //manager.add_button(gaf_galaxy_button);
	    manager.add_button(bookmark_button);
	}else if( personality == 'bbop_ont' ){
	    manager.clear_buttons();
	    manager.add_button(id_label_download_button);
	    //manager.add_button(id_term_label_galaxy_button);
	    manager.add_button(bookmark_button);
	}else if( personality == 'bbop_bio' ){
	    manager.clear_buttons();
	    manager.add_button(id_download_button);
	    //manager.add_button(id_symbol_galaxy_button);
	    manager.add_button(bookmark_button);
	//}else if( personality == 'bbop_ann_ev_agg' ){
	}else{
	    manager.clear_buttons();
	}
    }

    var active_classes = [
	{
	    id: 'bbop_ann', 
	    on_click: function(manager){
		manager.add_query_filter('document_category',
					 'annotation', ['*']);
		_establish_buttons('bbop_ann', manager);
	    }
	},
	{
	    id: 'bbop_ont',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'ontology_class', ['*']);
		_establish_buttons('bbop_ont', manager);
	    }
	},
	{
	    id: 'bbop_bio',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'bioentity', ['*']);
		_establish_buttons('bbop_bio', manager);
	    }
	},
	{
	    id: 'bbop_family',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'family', ['*']);
		_establish_buttons('bbop_family', manager);
	    }
	},
	{
	    id: 'bbop_general',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
					 'general', ['*']);
		_establish_buttons('bbop_general', manager);
	    }
	},
	{
	    id: 'bbop_ann_ev_agg',
	    on_click: function(manager){
    		manager.add_query_filter('document_category',
    					 'annotation_evidence_aggregate',['*']);
		_establish_buttons('bbop_ann_ev_agg', manager);
	    }
	}
    ];

    // Helper function to pull out class by id.
    function _get_active_class(cid){
	var retcls = null;
	loop(active_classes,
	     function(acls, index){
		 //ll("index: " + index);		 
		 //ll("acls['id']: " + acls['id']);		 
		 if( acls['id'] == cid ){
		     retcls = acls;
		 }
	     });
	return retcls;
    }

    ///
    /// Tabify the layout if we can (may be in a non-tabby version).
    ///

    // var dtabs = jQuery("#display-tabs");
    // if( dtabs ){
    // 	ll('Apply tabs...');
    // 	jQuery("#display-tabs").tabs();
    // 	//dtabs.tabs();
    // 	jQuery("#display-tabs").tabs('select', 0);
    // }

    ///
    /// Ready the configuration that we'll use.
    ///

    var gconf = new bbop.golr.conf(amigo.data.golr);
    var sd = new amigo.data.server();
    var linker = new amigo.linker();
    var solr_server = sd.golr_base();
    var div_id = 'display-general-search';

    ///
    /// Defined some useful buttons.
    ///

    // Download limit.    
    //var dlimit = 7500;
    var dlimit = 100000;

    // Global download properties.
    var _dl_props = {
	'entity_list': null,
	'rows': dlimit
    };

    // Define the rows that we'll use to create a psuedo-GAF.
    var _gaf_fl = [
	'source', // c1
	'bioentity_internal_id', // c2; not bioentity
	'bioentity_label', // c3
	'qualifier', // c4
	'annotation_class', // c5
	'reference', // c6
	'evidence_type', // c7
	'evidence_with', // c8
	'aspect', // c9
	'bioentity_name', // c10
	'synonym', // c11
	'type', // c12
	'taxon', // c13
	'date', // c14
	'assigned_by', // c15
	'annotation_extension_class', // c16
	'bioentity_isoform' // c17
    ];

    // Create button templates to use from our library.
    var btmpl = bbop.widget.display.button_templates;

    var id_download_button =
	btmpl.field_download('Download IDs (up to ' +
			     dlimit + ')',
			     dlimit, ['id']);
    var id_label_download_button =
	btmpl.field_download('Download IDs and labels (up to ' +
			     dlimit + ')',
			     dlimit, ['annotation_class',
				      'annotation_class_label']);
    var gaf_download_button =
	btmpl.field_download('GAF chunk download (up to ' +
			     dlimit + ')',
			     dlimit, _gaf_fl);
    var bookmark_button = btmpl.bookmark(linker);
    var facet_matrix_button = btmpl.open_facet_matrix(gconf, sd);
    var gaf_galaxy_button =
	btmpl.send_fields_to_galaxy('Send GAF chunk to Galaxy (up to ' +
				    dlimit + ')',
				    dlimit, _gaf_fl, global_galaxy_url);
    var id_term_label_galaxy_button =
	btmpl.send_fields_to_galaxy('Send IDs and names to Galaxy (up to ' +
				    dlimit + ')',
				    dlimit, ['annotation_class',
{'fraction_non_alphanumeric': 0.1538881806592606, 'fraction_numerical': 0.006920415224913495, 'mean_word_length': 2.7497439399112324, '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': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1534417', 'n_tokens_mistral': 4115, 'n_tokens_neox': 3738, 'n_words': 782}