Created
September 15, 2010 20:53
-
-
Save billdawson/581465 to your computer and use it in GitHub Desktop.
Show data for all contacts (Titanium)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dosubs(person, property, labels) { | |
if (!(person[property])) { | |
return; | |
} | |
var pset = person[property]; | |
for (var i = 0; i < labels.length; i++) { | |
var label = labels[i]; | |
if (!(pset[label])) { | |
continue; | |
} | |
var values = pset[label]; | |
for (var j = 0; j < values.length; j++) { | |
var value = values[j]; | |
if (typeof value === 'object' && "Street" in value) { | |
Ti.API.info(label + ' ' + property + ': ' + value.Street); | |
} else { | |
Ti.API.info(label + ' ' + property + ': ' + value); | |
} | |
} | |
} | |
} | |
function info(person) { | |
var fullName = person.fullName || "[no name]"; | |
Ti.API.info("==================="); | |
Ti.API.info("Name: " + fullName); | |
if (person.note && person.note.length > 0) { | |
Ti.API.info("Note: " + person.note); | |
} | |
dosubs(person, "email", ['home', 'work', 'other']); | |
dosubs(person, "address", ['home', 'work', 'other'], ""); | |
dosubs(person, "phone", ['home', 'work', 'other', 'mobile', 'workFax', 'pager', 'homeFax', 'main']); | |
} | |
var people = Ti.Contacts.getAllPeople(); | |
for (var i = 0; i < people.length; i++) { | |
var person = people[i]; | |
info(person); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You saved my day