Skip to content

Commit

Permalink
Merge from staging
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemSempere committed Jul 2, 2024
2 parents ca25f42 + f20be5c commit 7770283
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/webapp/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,28 @@ function buildHeader(token, assemblyId, individuals) {
if (individuals != null)
headers["ind"] = individuals;
return headers;
}

function getNcbiTaxonDetails(ncbiTaxonId)
{
var result = $.ajax({
async:false,
type:"GET",
url:"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=taxonomy&retmode=json&id=" + ncbiTaxonId,
error:function(xhr, ajaxOptions, thrownError) {}
});
return result['responseJSON']['result'][ncbiTaxonId];
}

function grabNcbiTaxon(inputObj)
{
if ($(inputObj).val() == '' || isNaN($(inputObj).val()))
return;
var taxonDetails=getNcbiTaxonDetails($(inputObj).val()), taxonName=taxonDetails['scientificname'], genus=taxonDetails['genus'], species=taxonDetails['species'];
if (taxonName != null && taxonName != '')
$(inputObj).attr('title', $(inputObj).val());
if (species != null && species != '')
$(inputObj).attr('species', genus + " " + species);

$(inputObj).val(taxonName);
}

0 comments on commit 7770283

Please sign in to comment.