Skip to content

ContactParser API

hc09141 edited this page Nov 4, 2016 · 4 revisions

Deals with parsing between formats required for displaying contacts in the UI and the vCard stored in the database. Also provides functions for updating/modifying the two formats in response to user changes.

ContactParser.createEmptyContactSections(contactSections)

Clears all information about a contact held in the main panel

Param Type Description
contactSections Array Infomation to clear

ContactParser.createEmptyPersonalSection(details)

Clears all information about a contact held in the header

Param Type Description
details Array Infomation to clear

ContactParser._parseProperty(property, cProperty, tProperty, cSections, tSections, pField, tpField, jCardIndex)

Parses a single property of a contact vCard for the UI

Param Type Description
property <Property The property to parse
cProperty Array Contact property in UI
tProperty Array Temporary contact property in UI (for editing purposes)
cSections Array Contact sections in UI
tSections Array Temporary contact sections in UI (for editing purposes)
pField Array Personal details of contact fields in UI header
tpField Array Temporary personal details of contact fields in UI header (for editing purposes)
jCardIndex Integer Index of the jCard which the property belongs to

ContactParser._addPersonalDetail(pField, tpField, type, jCardIndex, cProperty, tProperty, content)

Adds a personal property to the personal and temporary contact fields for the UI header of a contact

Param Type Description
pField Array Personal details of contact fields in UI header
tpField Array Temporary personal details of contact fields in UI header (for editing purposes)
type string The type of personal detail
jCardIndex Intger Index of the jCard which the detail belongs to
cProperty Property Contact property in UI header
tProperty Property Temporary contact property in UI header (for editing purposes)
content string The content of the property

ContactParser._addFieldProperty(index, currentOption, content, sections, jCardIndex, property)

Adds a property to the appropriate contact section for displaying the contact in the UI

Param Type Description
index Integer The index of the contact section to add to
currentOption string The option type associated with the property
content string The content of the property
sections Array The sections of the contact
jCardIndex Integer Index of the jCard which the detail belongs to
property Property Property to add

ContactParser.updateContent(ab, index, fieldID, content)

Updates the value of an existing property that is from a contact section

Param Type Description
ab AddressBook The addressbook UI component
index Integer The index of the temporary contact section to update
fieldID Integer The index of the field in the temporary contact section to update
content string The content to update the property with

ContactParser.updatePersonalDetail(ab, detail, content)

Updates the value of an existing property that is a personal detail

Param Type Description
ab AddressBook The addressbook UI component
detail string The detail to update
content string The content to update the property with

ContactParser.updateOption(ab, option, index, fieldID)

Updates the option associated with a property

Param Type Description
ab AddressBook The addressbook UI component
option string The option to update to
index Integer The index of the temporary contact section to update
fieldID Integer The index of the field in the temporary contact section to update

ContactParser.updateProfileImage(ab, image)

Updates the profile image of a contact

Param Type Description
ab AddressBook The addressbook UI component
image Blob The new image for the contact

ContactParser.removeContactDetail(tempContact, tempSectionIndex, tempSections, propertyID, ab)

Removes a property from a contact

Param Type Description
tempContact Contact The temporary contact (for editing purposes) to be modified
tempSectionIndex Integer The index of the temporary section of a contact to add to
tempSections Array All sections of the contact
propertyID Integer The id of the property to be removed
ab AddressBook The addressbook UI component

ContactParser.addContactDetail(tempContact, tempSectionIndex, tempSections, ab)

Adds a new property to a contact

Param Type Description
tempContact Contact The temporary contact (for editing purposes) to be modified
tempSectionIndex Integer The index of the temporary section of a contact to add to
tempSections Array All sections of the contact
ab AddressBook The addressbook UI component

ContactParser.rename(id, name, contactsList)

Renames a contact on the sidebar

Param Type Description
id Integer The id of the contact to be renamed
name string The new name of the contact
contactsList Array The list of contacts displayed on the sidebar

ContactParser.deleteContact(contactsList, id) ⇒ Array

Deletes a contact from the sidebar

Returns: Array - contactsList The list of contacts with the desired contact removed

Param Type Description
contactsList Array The list of contacts displayed on the sidebar
id Integer The id of the contact to be deleted

ContactParser.saveContactPersonalDetails(tpSection, pSection, tempContact, contactsList, name, id)

Saves the contact details from the temporary details for the UI

Param Type Description
tpSection Array The temporary details to save
pSection Array The permanent details to save to
tempContact Contact The temporary contact to save
contactsList Array The list of all contacts
name string The name of the contact before editing
id Integer The id of the contact being saved

ContactParser.saveContactPhotoToContactsList(contactsList, tempContact, id)

Saves the image of a contact to the sidebar/contacts list

Param Type Description
contactsList Array The list of all contacts
tempContact Contact The temporary contact to save
id Integer The id of the contact being saved

ContactParser.saveContactSections(tSections, cSections, contact)

Saves the contact sections from the temporary sections for the UI

Param Type Description
tSections Array The temporary sections of the contact to save
cSections Array The permanent sections of the contact to save to
contact Array The contact to save

ContactParser.cancelContactEdit(ab)

Cancels the editing of a contact and resets the temporary fields to the original set of fields

Param Type Description
ab AddressBook The addressbook UI component

ContactParser.findCloneProperty(property, contact) ⇒ Property

Finds a property within a contact

Returns: Property - property - the identical found property

Param Type Description
property Property The property to find
contact Contact The contact to search through

ContactParser.equals(element, index)

Checks if two properties are identical

this: Array

Param Type Description
element Property The property to check
index Integer The index of the other property
Clone this wiki locally