var app = {
initialize: function(){ this.bindEvents(); }, bindEvents: function(){ document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function(){ app.foreachContacts(); }, foreachContacts: function(){ function onSuccess(contacts) { for (var i=0; i<contacts.length; i++) { // display phone numbers for (var j=0; j<contacts[i].phoneNumbers.length; j++) { var d = "Type: " + contacts[i].phoneNumbers[j].type + "\n" + "Value: " + contacts[i].phoneNumbers[j].value + "\n" + "Preferred: " + contacts[i].phoneNumbers[j].pref; document.getElementById("contact").innerHTML += "<li class=\"userinfo\">" + d + "</li>"; } } }; function onError(contactError) { alert('onError!'); }; var options = new ContactFindOptions(); // id: A globally unique identifier. (DOMString) // displayName: The name of this Contact, suitable for display to end-users. (DOMString) // name: An object containing all components of a persons name. (ContactName) // nickname: A casual name to address the contact by. (DOMString) // phoneNumbers: An array of all the contact's phone numbers. (ContactField[]) // emails: An array of all the contact's email addresses. (ContactField[]) // addresses: An array of all the contact's addresses. (ContactAddress[]) // ims: An array of all the contact's IM addresses. (ContactField[]) // organizations: An array of all the contact's organizations. (ContactOrganization[]) // birthday: The birthday of the contact. (Date) // note: A note about the contact. (DOMString) // photos: An array of the contact's photos. (ContactField[]) // categories: An array of all the contacts user defined categories. (ContactField[]) // urls: An array of web pages associated to the contact. (ContactField[]) var fields = ["phoneNumbers"]; navigator.contacts.find(fields, onSuccess, onError); } }app.initialize();