-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joe Bowser
committed
Dec 1, 2009
1 parent
dcfd696
commit 4f53484
Showing
1 changed file
with
43 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,60 @@ | ||
/** | ||
* This class provides access to the device contacts. | ||
* @constructor | ||
*/ | ||
|
||
function Contact(jsonObject) { | ||
this.firstName = ""; | ||
this.lastName = ""; | ||
this.name = ""; | ||
this.phones = {}; | ||
this.emails = {}; | ||
this.address = ""; | ||
var Contact = function(){ | ||
this.name = null; | ||
this.emails = []; | ||
this.phones = []; | ||
} | ||
|
||
Contact.prototype.displayName = function() | ||
var ContactName = function() | ||
{ | ||
// TODO: can be tuned according to prefs | ||
return this.name; | ||
this.formatted = ""; | ||
this.familyName = ""; | ||
this.givenName = ""; | ||
this.additionalNames = []; | ||
this.prefixes = []; | ||
this.suffixes = []; | ||
} | ||
|
||
function ContactManager() { | ||
// Dummy object to hold array of contacts | ||
this.contacts = []; | ||
this.timestamp = new Date().getTime(); | ||
|
||
var ContactEmail = function() | ||
{ | ||
this.types = []; | ||
this.address = ""; | ||
} | ||
|
||
ContactManager.prototype.getAllContacts = function(successCallback, errorCallback, options) { | ||
// Interface | ||
|
||
var Contacts = function() | ||
{ | ||
this.records = []; | ||
} | ||
|
||
PhoneGap.addConstructor(function() { | ||
if (typeof navigator.ContactManager == "undefined") navigator.ContactManager = new ContactManager(); | ||
}); | ||
ContactManager.prototype.getAllContacts = function(successCallback, errorCallback, options) { | ||
this.win = successCallback; | ||
this.fail = errorCallback; | ||
ContactHook.getContactsAndSendBack(); | ||
var Contacts.prototype.find = function(obj, win, fail) | ||
{ | ||
if(obj.name) | ||
{ | ||
ContactHook.search(name, "", ""); | ||
} | ||
this.win = win; | ||
this.fail = fail; | ||
} | ||
|
||
ContactManager.prototype.droidAddContact = function(name, phone, email) | ||
var Contacts.prototype.droidFoundContact = function(name, npa, email) | ||
{ | ||
var contact = new Contact(); | ||
contact.name = name; | ||
contact.phones.primary = phone; | ||
contact.emails.primary = email; | ||
this.contacts.push(contact); | ||
contact.name = new ContactName(); | ||
contact.name.formatted = name; | ||
contact.name.givenName = name; | ||
var mail = new ContactEmail(); | ||
mail.types.push("home"); | ||
mail.address = email; | ||
contact.emails.push(mail); | ||
phone = new ContactPhoneNumber(); | ||
phone.types.push("home"); | ||
phone.number = npa; | ||
contact.phones.push(phone); | ||
this.records.push(contact); | ||
} | ||
|
||
ContactManager.prototype.droidDone = function() | ||
var Contacts.prototype.droidDone = function() | ||
{ | ||
this.win(this.contacts); | ||
this.win(this.records); | ||
} |