2009-12-02 03:48:10 +08:00
|
|
|
var Contact = function(){
|
|
|
|
this.name = null;
|
|
|
|
this.emails = [];
|
|
|
|
this.phones = [];
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 03:48:10 +08:00
|
|
|
var ContactName = function()
|
2009-11-18 02:38:49 +08:00
|
|
|
{
|
2009-12-02 03:48:10 +08:00
|
|
|
this.formatted = "";
|
|
|
|
this.familyName = "";
|
|
|
|
this.givenName = "";
|
|
|
|
this.additionalNames = [];
|
|
|
|
this.prefixes = [];
|
|
|
|
this.suffixes = [];
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 03:48:10 +08:00
|
|
|
|
|
|
|
var ContactEmail = function()
|
|
|
|
{
|
|
|
|
this.types = [];
|
|
|
|
this.address = "";
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 06:56:43 +08:00
|
|
|
var ContactPhoneNumber = function()
|
|
|
|
{
|
|
|
|
this.types = [];
|
|
|
|
this.number = "";
|
|
|
|
}
|
|
|
|
|
2009-12-02 03:48:10 +08:00
|
|
|
|
|
|
|
var Contacts = function()
|
|
|
|
{
|
|
|
|
this.records = [];
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 06:56:43 +08:00
|
|
|
Contacts.prototype.find = function(obj, win, fail)
|
2009-12-02 03:48:10 +08:00
|
|
|
{
|
2009-12-02 06:56:43 +08:00
|
|
|
if(obj.name != null)
|
2009-12-02 03:48:10 +08:00
|
|
|
{
|
|
|
|
ContactHook.search(name, "", "");
|
|
|
|
}
|
|
|
|
this.win = win;
|
|
|
|
this.fail = fail;
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 06:56:43 +08:00
|
|
|
Contacts.prototype.droidFoundContact = function(name, npa, email)
|
2009-11-18 02:38:49 +08:00
|
|
|
{
|
|
|
|
var contact = new Contact();
|
2009-12-02 03:48:10 +08:00
|
|
|
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);
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
|
|
|
|
2009-12-02 06:56:43 +08:00
|
|
|
Contacts.prototype.droidDone = function()
|
2009-11-18 02:38:49 +08:00
|
|
|
{
|
2009-12-02 03:48:10 +08:00
|
|
|
this.win(this.records);
|
2009-11-18 02:38:49 +08:00
|
|
|
}
|
2009-12-02 06:56:43 +08:00
|
|
|
|
|
|
|
PhoneGap.addConstructor(function() {
|
|
|
|
if(typeof navigator.Contacts == "undefined") navigator.Contacts = new Contacts();
|
|
|
|
});
|