Birds
Thu Feb 29 2024 20:41:45 GMT+0000 (Coordinated Universal Time)
Saved by
@Starblster
//All images in this app come from Code.organd are
//Creative Commons free to use
var namesList = getColumn("100 Birds of the World", "Name");
var colorsList = getColumn("100 Birds of the World", "Primary Color");
var birdImageList = getColumn("100 Birds of the World", "Image of Bird");
var index = 0;
//Filtered Lists
var filternameList = [];
var filterbirdImageList = [];
onEvent("colorDropDown", "click", function( ) {
var color = getText("colorDropDown");
createFilteredList(color);
});
onEvent("leftButton", "click", function( ) {
index = index - 1;
updatescreen();
});
onEvent("rightButton", "click", function( ) {
index = index + 1;
updatescreen();
});
function createFilteredList(color) {
filterbirdImageList = [];
filternameList = [];
for (var i = 0; i < colorsList.length; i++) {
if (color == colorsList[i]) {
appendItem(filterbirdImageList, birdImageList[i]);
appendItem(filternameList, namesList[i]);
}
}
console.log(filternameList);
updatescreen();
}
function updatescreen(){
if (index > 0 && index < filternameList.length){
setImageURL("birdImage", filterbirdImageList[index]);
setText("nameLabel", filternameList[index]);
} else {
index = 0;
setImageURL("birdImage", filterbirdImageList[index]);
setText("nameLabel", filternameList[index]);
}
}
//forgot to call the function "updatescreen"
content_copyCOPY
Comments