<commit_before>/*
 * Misc Javascript variables and functions.
 *
 * This could all likely use some cleanup.  Some of this stuff could be:
 *
 *  - turned into event-based unobtrusive javascript
 *  - simply named / namespaced a bit better
 *  - the html generated from javascript strings could
 *    likely be improved or moved to the server-side
 *
 */ 

// DEPRECATED
var image_attribution_panel_open = false;
function toggle_image_attribution()         { EOL.log("obsolete method called: toggle_image_attribution"); }
function hide_image_attribution()           { EOL.log("obsolete method called: hide_image_attribution"); }
function show_image_attribution()           { EOL.log("obsolete method called: show_image_attribution"); }
function create_attribution_table_header()  { EOL.log("obsolete method called: create_attribution_table_header"); }
function create_attribution_table_row()     { EOL.log("obsolete method called: create_attribution_table_row"); }
function create_attribution_table_footer()  { EOL.log("obsolete method called: create_attribution_table_footer"); }

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
		cntfield.innerHTML = maxlimit - field.value.length + ' remaining';
}

// update the content area
function eol_update_content_area(taxon_id,category_id) {
    // i feel like this could be a lot simpler ... 
    new Ajax.Request('/taxa/content/', {
             parameters: { id: taxon_id, category_id: category_id },         
            onComplete:function(request){hideAjaxIndicator(true);updateReferences();},
            onSuccess:function(request){hideAjaxIndicator(true);updateReferences();},
            onError: function(request){hideAjaxIndicator(true);},
            onLoading:function(request){showAjaxIndicator(true);},
            asynchronous:true,
            evalScripts:true});
    $A(document.getElementsByClassName('active', $('toc'))).each(function(e) { e.className = ''; });
}

// show the pop-up in the div 
function eol_show_pop_up(div_name,partial_name,taxon_name) {
				if (partial_name==null) partial_name=div_name;
				if (taxon_name==null) taxon_name='';
        new Ajax.Updater(
        div_name,
        '/taxa/show_popup',
          {
            asynchronous:true, 
            evalScripts:true, 
            method:'post', 
            onComplete:function(request){hideAjaxIndicator();EOL.Effect.toggle_with_effect(div_name);},
            onLoading:function(request){showAjaxIndicator();},
            parameters:{name: partial_name,taxon_name: taxon_name}
          }
    );
    
}

// Updates the main image and calls eol_update_credit()
function eol_update_image(large_image_url, params) {
  $('main-image').src = large_image_url;
  $('main-image').alt=params.nameString;
  $('main-image').title=params.nameString;
    
  // update the hrefs for the comment, curation, etc popups
  if (!params.curated) {
    $$('div#large-image-trust-button a')[0].href="/data_objects/"+params.data_object_id+"/curate?_method=put&curator_activity_id=3";
    $$('div#large-image-untrust-button a')[0].href="/data_objects/"+params.data_object_id+"/curate?_method=put&curator_activity_id=7";
    $$('div#large-image-untrust-button a')[0].writeAttribute('data-data_object_id', params.data_object_id);

    $('large-image-trust-button').appear();
    $('large-image-untrust-button').appear();
  } else {
    $('large-image-trust-button').disappear();
    $('large-image-untrust-button').disappear();
  }
  if ($('large-image-comment-button-popup-link'))     $('large-image-comment-button-popup-link').href = "/data_objects/" + params.data_object_id + "/comments";
  if ($('large-image-attribution-button-popup-link')) $('large-image-attribution-button-popup-link').href = "/data_objects/" + params.data_object_id + "/attribution"; 
  if ($('large-image-tagging-button-popup-link'))     $('large-image-tagging-button-popup-link').href = "/data_objects/" + params.data_object_id + "/tags"; 
  if ($('large-image-curator-button-popup-link'))     $('large-image-curator-button-popup-link').href = "/data_objects/" + params.data_object_id + "/curation"; 
<commit_msg>updated data object id on thumbs up button. fixes EOLINFRASTRUCTURE-532<commit_after>/*
 * Misc Javascript variables and functions.
 *
 * This could all likely use some cleanup.  Some of this stuff could be:
 *
 *  - turned into event-based unobtrusive javascript
 *  - simply named / namespaced a bit better
 *  - the html generated from javascript strings could
 *    likely be improved or moved to the server-side
 *
 */ 

// DEPRECATED
var image_attribution_panel_open = false;
function toggle_image_attribution()         { EOL.log("obsolete method called: toggle_image_attribution"); }
function hide_image_attribution()           { EOL.log("obsolete method called: hide_image_attribution"); }
function show_image_attribution()           { EOL.log("obsolete method called: show_image_attribution"); }
function create_attribution_table_header()  { EOL.log("obsolete method called: create_attribution_table_header"); }
function create_attribution_table_row()     { EOL.log("obsolete method called: create_attribution_table_row"); }
function create_attribution_table_footer()  { EOL.log("obsolete method called: create_attribution_table_footer"); }

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
		cntfield.innerHTML = maxlimit - field.value.length + ' remaining';
}

// update the content area
function eol_update_content_area(taxon_id,category_id) {
    // i feel like this could be a lot simpler ... 
    new Ajax.Request('/taxa/content/', {
             parameters: { id: taxon_id, category_id: category_id },         
            onComplete:function(request){hideAjaxIndicator(true);updateReferences();},
            onSuccess:function(request){hideAjaxIndicator(true);updateReferences();},
            onError: function(request){hideAjaxIndicator(true);},
            onLoading:function(request){showAjaxIndicator(true);},
            asynchronous:true,
            evalScripts:true});
    $A(document.getElementsByClassName('active', $('toc'))).each(function(e) { e.className = ''; });
}

// show the pop-up in the div 
function eol_show_pop_up(div_name,partial_name,taxon_name) {
				if (partial_name==null) partial_name=div_name;
				if (taxon_name==null) taxon_name='';
        new Ajax.Updater(
        div_name,
        '/taxa/show_popup',
          {
            asynchronous:true, 
            evalScripts:true, 
            method:'post', 
            onComplete:function(request){hideAjaxIndicator();EOL.Effect.toggle_with_effect(div_name);},
            onLoading:function(request){showAjaxIndicator();},
            parameters:{name: partial_name,taxon_name: taxon_name}
          }
    );
    
}

// Updates the main image and calls eol_update_credit()
function eol_update_image(large_image_url, params) {
  $('main-image').src = large_image_url;
  $('main-image').alt=params.nameString;
  $('main-image').title=params.nameString;
    
  // update the hrefs for the comment, curation, etc popups
  if (!params.curated) {
    $$('div#large-image-trust-button a')[0].href="/data_objects/"+params.data_object_id+"/curate?_method=put&curator_activity_id=3";
    $$('div#large-image-untrust-button a')[0].href="/data_objects/"+params.data_object_id+"/curate?_method=put&curator_activity_id=7";
    $$('div#large-image-untrust-button a')[0].writeAttribute('data-data_object_id', params.data_object_id);
    $$('div#large-image-trust-button a')[0].writeAttribute('data-data_object_id', params.data_object_id);

    $('large-image-trust-button').appear();
    $('large-image-untrust-button').appear();
  } else {
    $('large-image-trust-button').disappear();
    $('large-image-untrust-button').disappear();
  }
  if ($('large-image-comment-button-popup-link'))     $('large-image-comment-button-popup-link').href = "/data_objects/" + params.data_object_id + "/comments";
  if ($('large-image-attribution-button-popup-link')) $('large-image-attribution-button-popup-link').href = "/data_objects/" + params.data_object_id + "/attribution"; 
  if ($('large-image-tagging-button-popup-link'))     $('large-image-tagging-button-popup-link').href = "/data_objects/" + params.data_object_id + "/tags"; 
  if ($('large-image-curator-button-popup-link'))     $('large-image-curator-button-popup-link').href = "/data_objects/" + params.data_object_id + "/curation"; 

{'fraction_non_alphanumeric': 0.14601972929571003, 'fraction_numerical': 0.0018352833218628125, 'mean_word_length': 4.066240557815224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4008662', 'n_tokens_mistral': 2802, 'n_tokens_neox': 2702, 'n_words': 464}