0% found this document useful (0 votes)
46 views3 pages

Executed Program App Lab

The document defines functions and variables to manage a contacts list. It initializes an array to store contact objects with name, phone, and birthday properties. Functions are defined to display the current contact, navigate between contacts, add new contacts, and wrap the current index. Events are handled to respond to navigation and save buttons to display contacts and add new ones.

Uploaded by

madirajunaveen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

Executed Program App Lab

The document defines functions and variables to manage a contacts list. It initializes an array to store contact objects with name, phone, and birthday properties. Functions are defined to display the current contact, navigate between contacts, add new contacts, and wrap the current index. Events are handled to respond to navigation and save buttons to display contacts and add new ones.

Uploaded by

madirajunaveen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EXECUTED PROGRAM APP LAB

var currentIndex=0;

var contact1=[];

contact1.name="Naveen";

contact1.phone="9618300797";

contact1.birthday="1/1/20";

//contact1.imageURL="https://images.app.goo.gl/fTUgCM9YGh6X2hfL6";

var contacts=[];

appendItem(contacts,contact1);

showCurrentContacts();

//showCurrentContacts();

showCurrentContacts();{

setText("contactsInfo",contacts[currentIndex].name);

setText("contactsInfo",contacts[currentIndex].phone);

setText("contactsInfo",contacts[currentIndex].birthday);

//setText("ContactsInfo",contacts[currentIndex].name);

function showCurrentContacts() {

setText("contactsInfo",contacts[currentIndex].name);

var nameString="Name :" + contacts[currentIndex].name;

var phoneString="Phone :" + contacts[currentIndex].phone;

var birthdayString="Birthday :" + contacts[currentIndex].birthday;

setText("contactsInfo",nameString + '\n' + phoneString + '\n' + birthdayString);

//setText("contactsInfo",nameString,phoneString,birthdayString);
}

onEvent("viewContactsScreen","keydown", function() {

if (event.key=="left") {

currentIndex--;

currentIndex=wrap(currentIndex,0,contacts.length -1);

showCurrentContacts();

});

function wrap(val,low,high)

var output;

if (val < low)

output=high;

} else if (val > high) {

output=low;

else {

output=val;

return output;

onEvent("saveContactsBtn", "click", function( ) {


var newcontact=[];

newcontact.name=getText("nameInput");

newcontact.phone=getText("phoneInput");

newcontact.birthday=getText("birthdayInput");

appendItem(contacts,newcontact);

setText("nameInput", "");

setText("phoneInput", "");

setText("birthdayInput", "");

setScreen("viewContactsScreen");

onEvent("addContactsBtn","click", function() {

setScreen("addContactsScreen");

});

currentIndex=contacts.length-1;

showCurrentContacts();

onEvent("backBtn", "click", function( ) {

setScreen("viewContactsScreen");

});

});

You might also like