4/22/24, 3:35 PM [Link].
io/codePrint/
//this is the list to store all the information from the profile data set.
var nameList = [];
var genderList = [];
var heightList = [];
var hairColorList = [];
var skinColorList = [];
var traitsList = [];
//filtered list stores the information of the profile after the filter function
var nameFilter = [];
var genderFilter = [];
var heightFilter = [];
var hairColorFilter = [];
var skinColorFilter = [];
var traitsFilter = [];
var searchChoice = "";//this is to store the choice of the users
var index = 0;//this is to store the index that is going to go through the list
//OnEvents
//This onEvent function by calling the function updateData and passinh the arguments from inputs into the
onEvent("doneButton", "click", function( ) {
updateData(getText("nameInput") , getText("genderInput") , getText("heightInput") , getText("hairColor
});
//This code functions by setting screen when the button createProfile is clicked.
onEvent("createProfile", "click", function( ) {
setScreen("infoInputScreen");
});
//This code functions by setting screen back to the introduction screen when the button homeButton on the
onEvent("homeButton", "click", function( ) {
setScreen("introScreen");
});
//This function by setting the screen when the onEvent, pressing the button, happens.
onEvent("homeButton2", "click", function( ) {
setScreen("introScreen");
setText("profileName", ""); //This clears the text area that present the profile so the interface is cl
setText("profileInformation", "");
});
onEvent("searchProfile", "click", function( ) {
setScreen("searchScreen"); //This function not only set the screen to the screen for searching profile
hideElement("nextButton"); //This funciton will be putting all the information into seperate list tha
hideElement("backButton");
nameList = getColumn("Profiles", "Name" );
genderList = getColumn("Profiles", "Gender" );
heightList = getColumn("Profiles", "Height" );
hairColorList = getColumn("Profiles", "Hair_Color" );
skinColorList = getColumn("Profiles", "Skin_Color" );
traitsList = getColumn("Profiles", "Traits");
});
[Link] 1/4
4/22/24, 3:35 PM [Link]/codePrint/
onEvent("searchButton", "click", function( ) {
searchChoice = (getText("searchInput")); //This function by getting the user's input of what they are s
setText("searchInput", "");
nameFilter = [];
genderFilter = [];
heightFilter = [];
hairColorFilter = [];
skinColorFilter = [];
traitsFilter = [];
index = 0;
searchData(); //This call the function to filter out the data and appending the matched information int
checkEmpty(); //This will call the function to check each of the filter list to see if any of the list
updateScreen(); //This will call the function that updates the screen to present the data found.
});
onEvent("nextButton", "click", function( ) {
if (index == [Link]-1) { //This function by adding 1 to the index so that everytime the one
index = 0;
} else {
index = index + 1;
}
setText("profileName", nameFilter[index]);
setText("profileInformation", "Gender: " + genderFilter[index] + "\n" + "Height: " + heightFilter[index
"Other Traits: " + traitsFilter[index]);
});
onEvent("backButton", "click", function( ) {
if (index > 0) { //This function by subtracting the index by one and presenting all the information usi
index = index - 1;
setText("profileName", nameFilter[index]);
setText("profileInformation", "Gender: " + genderFilter[index] + "\n" + "Height: " + heightFilter[index
"Other Traits: " + traitsFilter[index]);
}
});
//functions
function updateData(name , gender , height , hairColor , skinColor , traits) {
var personInfo = {}; //This function by using the argument that are passed into this parameter, getting
[Link] = name;
[Link] = gender;
[Link] = height;
personInfo.Hair_Color = hairColor;
personInfo.Skin_Color = skinColor;
[Link] = traits;
createRecord("Profiles", personInfo, function(){ //This will add the information into the data base
});
setText("nameInput", ""); //This function also clears the input box for the users if the user's wish th
setText("heightInput", "");
setText("hairColorInput", "");
setText("skinColorInput", "");
setText("otherInput", "");
setProperty("doneButton", "text", "ADD ANOTHER");
}
[Link] 2/4
4/22/24, 3:35 PM [Link]/codePrint/
function searchData(){
for (var i = 0; i < [Link]; i++) {//This function will filter the entire data base and chec
if(nameList[i] == searchChoice || genderList[i] == searchChoice || heightList[i] == searchChoice |
appendItem(nameFilter, nameList[i]);
appendItem(genderFilter, genderList[i]);
appendItem(heightFilter, heightList[i]);
appendItem(hairColorFilter, hairColorList[i]);
appendItem(skinColorFilter, skinColorList[i]);
appendItem(traitsFilter, traitsList[i]);
}}
}
function checkEmpty() {
for (var i = 0; i < [Link]; i++) { //This function work by going through all of the filte
if (heightFilter[i] == "") {
removeItem(heightFilter, i);
insertItem(heightFilter, i , "No information");
}
}
for (var j = 0; j < [Link]; j++) {
if (hairColorFilter[j] == "") {
removeItem(hairColorFilter, j);
insertItem(hairColorFilter, j , "No information");
}
}
for (var q = 0; q < [Link]; q++) {
if (skinColorFilter[q] == "") {
removeItem(skinColorFilter, q);
insertItem(skinColorFilter, q , "No information");
}
}
for (var e = 0; e < [Link]; e++) {
if (traitsFilter[e] == "") {
removeItem(traitsFilter, e);
insertItem(traitsFilter, e , "No Information");
}
}
}
function updateScreen() {
if ([Link] > 1) { //This function work by checking how long the filtered list is first, then i
setProperty("profileName", "font-size", 21); //If the filtered list contain more than 1 item, it will
setText("profileName", nameFilter[index]);
setText("profileInformation", "Gender: " + genderFilter[index] + "\n" + "Height: " + heightFilter[ind
"Other Traits: " + traitsFilter[index]);
showElement("nextButton");
showElement("backButton");
} else if ([Link] > 0) {//If the filter list contain 1 item, it will present the profile and
setProperty("profileName", "font-size", 21);
setText("profileName", nameFilter[index]);
setText("profileInformation", "Gender: " + genderFilter[index] + "\n" + "Height: " + heightFilter[ind
"Other Traits: " + traitsFilter[index]);
hideElement("nextButton");
hideElement("backButton");
} else { //If the filter list is empty, this mean that the user should search again or use words that a
setText("profileName", "Sorry, profile not found");
[Link] 3/4
4/22/24, 3:35 PM [Link]/codePrint/
168 setProperty("profileName", "font-size", 12);
169 setText("profileInformation", "Sorry, profile not found");
170 hideElement("nextButton"); //The button for the next and back button is not needed becuase there are
171 hideElement("backButton");
}
}
PDF document made with CodePrint using Prism
[Link] 4/4