Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

findContact.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // document.getElementById("findContact").addEventListener("click", onSuccess);
  2. // // function showLocalStorage() {
  3. // // document.getElementById("demo").innerHTML = "value is empty";
  4. // // console.log('fsdfsd');
  5. // // alert("am i amazing!!")
  6. // function onSuccess(contacts) {
  7. // alert('Found ' + contacts.length + ' contacts.');
  8. // };
  9. // function onError(contactError) {
  10. // alert('onError!');
  11. // };
  12. // // find all contacts with 'Bob' in any name field
  13. // var options = new ContactFindOptions();
  14. // options.multiple = true;
  15. // options.desiredFields = [navigator.contacts.fieldType.id];
  16. // options.hasPhoneNumber = true;
  17. // var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
  18. // navigator.contacts.find(fields, onSuccess, onError, options);
  19. // }
  20. function onLoad() {
  21. // document.addEventListener("deviceready", onDeviceReady, false);
  22. document.getElementById("findContact").addEventListener("click", onDeviceReady);
  23. }
  24. // device APIs are available
  25. //
  26. function onDeviceReady() {
  27. navigator.contactsPhoneNumbers.list(function(contacts) {
  28. console.log(contacts.length + ' contacts found');
  29. for(var i = 0; i < contacts.length; i++) {
  30. console.log(contacts[i].id + " - " + contacts[i].displayName);
  31. for(var j = 0; j < contacts[i].phoneNumbers.length; j++) {
  32. var phone = contacts[i].phoneNumbers[j];
  33. console.log("===> " + phone.type + " " + phone.number + " (" + phone.normalizedNumber+ ")");
  34. }
  35. }
  36. }, function(error) {
  37. console.error(error);
  38. });
  39. }