mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Adding new data model to contact.js to conform to W3C spec
This commit is contained in:
parent
633100a3ce
commit
0efe871efe
@ -1,32 +1,76 @@
|
||||
|
||||
var Contact = function() {
|
||||
this.name = new ContactName();
|
||||
this.emails = [];
|
||||
this.phones = [];
|
||||
var Contact = function(id, displayName, name, nickname, phoneNumbers, emails, addresses,
|
||||
ims, organizations, published, updated, birthday, anniversary, gender, note,
|
||||
preferredUsername, photos, tags, relationships, urls, accounts, utcOffset, connected) {
|
||||
this.id = id || '';
|
||||
this.displayName = displayName || '';
|
||||
this.name = name || null; // ContactName
|
||||
this.nickname = nickname || '';
|
||||
this.phoneNumbers = phoneNumbers || null; // ContactField[]
|
||||
this.emails = emails || null; // ContactField[]
|
||||
this.addresses = addresses || null; // ContactAddress[]
|
||||
this.ims = ims || null; // ContactField[]
|
||||
this.organizations = organizations || null; // ContactOrganization[]
|
||||
this.published = published || '';
|
||||
this.updated = updated || '';
|
||||
this.birthday = birthday || '';
|
||||
this.anniversary = anniversary || '';
|
||||
this.gender = gender || '';
|
||||
this.note = note || '';
|
||||
this.preferredUsername = preferredUsername || '';
|
||||
this.photos = photos || null; // ContactField[]
|
||||
this.tags = tags || null; // ContactField[]
|
||||
this.relationships = relationships || null; // ContactField[]
|
||||
this.urls = urls || null; // ContactField[]
|
||||
this.accounts = accounts || null; // ContactAccount[]
|
||||
this.utcOffset = utcOffset || '';
|
||||
this.connected = connected || '';
|
||||
};
|
||||
|
||||
var ContactName = function() {
|
||||
this.formatted = "";
|
||||
this.familyName = "";
|
||||
this.givenName = "";
|
||||
this.additionalNames = [];
|
||||
this.prefixes = [];
|
||||
this.suffixes = [];
|
||||
var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
|
||||
this.formatted = formatted || '';
|
||||
this.familyName = familyName || '';
|
||||
this.givenName = givenName || '';
|
||||
this.middleName = middle || '';
|
||||
this.honorificPrefix = prefix || '';
|
||||
this.honorificSuffix = suffix || '';
|
||||
};
|
||||
|
||||
var ContactEmail = function() {
|
||||
this.types = [];
|
||||
this.address = "";
|
||||
var ContactField = function(type, value, primary) {
|
||||
this.type = type || '';
|
||||
this.value = value || '';
|
||||
this.primary = primary || '';
|
||||
};
|
||||
|
||||
var ContactPhoneNumber = function() {
|
||||
this.types = [];
|
||||
this.number = "";
|
||||
var ContactAddress = function(formatted, streetAddress, locality, region, postalCode, country) {
|
||||
this.formatted = formatted || '';
|
||||
this.streetAddress = streetAddress || '';
|
||||
this.locality = locality || '';
|
||||
this.region = region || '';
|
||||
this.postalCode = postalCode || '';
|
||||
this.country = country || '';
|
||||
};
|
||||
|
||||
var ContactOrganization = function(name, dept, title, startDate, endDate, location, desc) {
|
||||
this.name = name || '';
|
||||
this.department = dept || '';
|
||||
this.title = title || '';
|
||||
this.startDate = startDate || '';
|
||||
this.endDate = endDate || '';
|
||||
this.location = location || '';
|
||||
this.description = desc || '';
|
||||
};
|
||||
|
||||
var ContactAccount = function(domain, username, userid) {
|
||||
this.domain = domain || '';
|
||||
this.username = username || '';
|
||||
this.userid = userid || '';
|
||||
}
|
||||
|
||||
var Contacts = function() {
|
||||
this.inProgress = false;
|
||||
this.records = [];
|
||||
};
|
||||
}
|
||||
|
||||
Contacts.prototype.find = function(obj, win, fail) {
|
||||
this.win = win;
|
||||
@ -48,17 +92,21 @@ Contacts.prototype.find = function(obj, win, fail) {
|
||||
};
|
||||
|
||||
Contacts.prototype.droidFoundContact = function(name, npa, email) {
|
||||
this.records = new Array();
|
||||
var contact = new 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 = new Array();
|
||||
var mail = new ContactField();
|
||||
mail.type = "home";
|
||||
mail.value = email;
|
||||
mail.primary = true;
|
||||
contact.emails.push(mail);
|
||||
phone = new ContactPhoneNumber();
|
||||
phone.types.push("home");
|
||||
phone.number = npa;
|
||||
contact.phones = new Array();
|
||||
phone = new ContactField();
|
||||
phone.type = "home";
|
||||
phone.value = npa;
|
||||
contact.phones.push(phone);
|
||||
this.records.push(contact);
|
||||
};
|
||||
@ -67,6 +115,42 @@ Contacts.prototype.droidDone = function() {
|
||||
this.win(this.records);
|
||||
};
|
||||
|
||||
Contacts.prototype.remove = function(contact) {
|
||||
|
||||
};
|
||||
|
||||
Contacts.prototype.save = function(contact) {
|
||||
|
||||
};
|
||||
|
||||
Contacts.prototype.create = function(contact) {
|
||||
|
||||
};
|
||||
|
||||
Contacts.prototype.m_foundContacts = function(win, contacts) {
|
||||
this.inProgress = false;
|
||||
win(contacts);
|
||||
};
|
||||
|
||||
var ContactFindOptions = function() {
|
||||
this.filter = '';
|
||||
this.multiple = true;
|
||||
this.limit = 0;
|
||||
this.updatedSince = 0;
|
||||
};
|
||||
|
||||
var ContactError = function() {
|
||||
};
|
||||
|
||||
ContactError.INVALID_ARGUMENT_ERROR = 0;
|
||||
ContactError.IO_ERROR = 1;
|
||||
ContactError.NOT_FOUND_ERROR = 2;
|
||||
ContactError.NOT_SUPPORTED_ERROR = 3;
|
||||
ContactError.PENDING_OPERATION_ERROR = 4;
|
||||
ContactError.PERMISSION_DENIED_ERROR = 5;
|
||||
ContactError.TIMEOUT_ERROR = 6;
|
||||
ContactError.UNKNOWN_ERROR = 7;
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
if(typeof navigator.contacts == "undefined") navigator.contacts = new Contacts();
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user