1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // document.getElementById("findContact").addEventListener("click", onSuccess);
- // // function showLocalStorage() {
- // // document.getElementById("demo").innerHTML = "value is empty";
- // // console.log('fsdfsd');
- // // alert("am i amazing!!")
- // function onSuccess(contacts) {
- // alert('Found ' + contacts.length + ' contacts.');
- // };
-
- // function onError(contactError) {
- // alert('onError!');
- // };
-
- // // find all contacts with 'Bob' in any name field
- // var options = new ContactFindOptions();
- // options.multiple = true;
- // options.desiredFields = [navigator.contacts.fieldType.id];
- // options.hasPhoneNumber = true;
- // var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
- // navigator.contacts.find(fields, onSuccess, onError, options);
- // }
-
- function onLoad() {
-
- // document.addEventListener("deviceready", onDeviceReady, false);
- document.getElementById("findContact").addEventListener("click", onDeviceReady);
- }
-
- // device APIs are available
- //
- function onDeviceReady() {
- navigator.contactsPhoneNumbers.list(function(contacts) {
- console.log(contacts.length + ' contacts found');
- for(var i = 0; i < contacts.length; i++) {
- console.log(contacts[i].id + " - " + contacts[i].displayName);
- for(var j = 0; j < contacts[i].phoneNumbers.length; j++) {
- var phone = contacts[i].phoneNumbers[j];
- console.log("===> " + phone.type + " " + phone.number + " (" + phone.normalizedNumber+ ")");
- }
- }
- }, function(error) {
- console.error(error);
- });
- }
|