Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
47
gaia/dev_apps/uitest/js/API/contacts_saver.js
Executable file
47
gaia/dev_apps/uitest/js/API/contacts_saver.js
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
function ContactsSaver(data) {
|
||||
this.data = data;
|
||||
var next = 0;
|
||||
var self = this;
|
||||
|
||||
this.start = function() {
|
||||
saveContact(data[0]);
|
||||
};
|
||||
|
||||
function saveContact(cdata) {
|
||||
if (cdata.bday) {
|
||||
cdata.bday = new Date(cdata.bday);
|
||||
}
|
||||
if (cdata.anniversary) {
|
||||
cdata.anniversary = new Date(cdata.anniversary);
|
||||
}
|
||||
var contact = new mozContact(cdata);
|
||||
var req = navigator.mozContacts.save(contact);
|
||||
req.onsuccess = function(e) {
|
||||
if (typeof self.onsaved === 'function') {
|
||||
self.onsaved(next + 1);
|
||||
}
|
||||
continuee();
|
||||
};
|
||||
|
||||
req.onerror = function(e) {
|
||||
if (typeof self.onerror === 'function') {
|
||||
self.onerror(self.data[next], e.target.error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function continuee() {
|
||||
next++;
|
||||
if (next < self.data.length) {
|
||||
saveContact(self.data[next]);
|
||||
}
|
||||
else {
|
||||
// End has been reached
|
||||
if (typeof self.onsuccess === 'function') {
|
||||
self.onsuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue