// Variables
// Initializing lists
var title = getColumn("Books", "Title");
var author = getColumn("Books", "Author");
var genre = getColumn("Books", "Genre");
//Initializing Filtered Lists
var selectedTitle = [];
var selectedAuthor = [];
var genres;
//When you click the butttons, the variables change values and take you to the designated screen and shows you a recommended book
onEvent("GenreDD", "change", function( ) {
genres = getText("GenreDD");
});
onEvent("Go", "click", function( ) {
setScreen("bookScreen");
if (genres=="Mystery") {
setText("title2", "Mystery");
} else if ((genres=="Fantasy")) {
setText("title2", "Fantasy");
} else if ((genres=="Horror")) {
setText("title2", "Horror");
}
filter();
});
onEvent("homeButton1", "click", function( ) {
setScreen("titleScreen");
});
//Filter Function
//If the selected genre matches the genre in the list, append the Titles and Authors to the appropriate list
function filter(input) {
selectedTitle = [];
selectedAuthor = [];
for (var i = 0; i < genre.length; i++) {
if (genre == input) {
appendItem(selectedTitle, title[i]);
appendItem(selectedAuthor, author[i]);
}
}
console.log(selectedTitle);
}
function updateScreen() {
var randomindex = randomNumber(0, 3);
}