-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5958a3d
commit 1dc5132
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
function displayTaxonsCard(taxonList) { | ||
var myContainer = document.getElementById("taxons-results"); | ||
// proper call to the function | ||
taxonList.forEach((el) => { | ||
addTaxon(el, myContainer); | ||
}); | ||
} | ||
|
||
|
||
function addTaxon(arrayTaxon, refContainer) { | ||
// from an array of dicts describing taxons, populates "table_contenu" with cards describing each | ||
// get image from taxon | ||
let imgTaxon = arrayTaxon["mediaUrl"]; | ||
|
||
// Create card element to be appened to card-group | ||
let cardCont = document.createElement("div"); | ||
cardCont.className = "card col cursor-pointer"; | ||
let myCard = document.createElement("div"); | ||
myCard.classList = "card-body"; | ||
|
||
let myCardFoot = document.createElement("div"); | ||
myCardFoot.classList = "card-footer"; | ||
|
||
// set title and text | ||
let cardTitle = document.createElement("h5"); | ||
cardTitle.innerText = arrayTaxon["species"]; | ||
cardTitle.className = "card-title"; | ||
|
||
let myFigure = document.createElement("img"); | ||
myFigure.id = arrayTaxon["species"]; | ||
myFigure.src = arrayTaxon["mediaUrl"]; | ||
myFigure.className = "card-img-top"; | ||
|
||
let myStatus = document.createElement("small"); | ||
myStatus.innerText = arrayTaxon["status"]; | ||
myStatus.className = "text-muted"; | ||
|
||
// Build elements | ||
myCardFoot.appendChild(myStatus); | ||
|
||
myCard.appendChild(myFigure); | ||
myCard.appendChild(cardTitle); | ||
cardCont.appendChild(myCard); | ||
cardCont.appendChild(myCardFoot); | ||
refContainer.appendChild(cardCont); | ||
return; | ||
} | ||
|
||
|
||
//https://nc.iucnredlist.org/redlist/resources/files/1646067752-FINAL_IUCN_Red_List_colour_chart.pdf | ||
var colorStatus = { | ||
"Near threatened (NT)": "#CCE226", | ||
"Vulnerable (VU)": "#F9E814", | ||
"Endangered (EN)": "#FC7F3F", | ||
"Critically Endangered (CR)": "#D81E05", | ||
}; |