2013년 11월 7일 목요일

Fetching the Device's Contracts

Fetching the Device's Contracts

Arguments for PhoneGap Contracts API
Argument
Description
Example
contactField
Required argument, This is an array field of contacts that need to be returned.
[“name”,”phoneNumbers”]
contactSuccess
A Javascript callback function that gets a contact array as an argument.
function onSuccess(contacts){
}
contactError
A Javascript callback function that gets an error as an argument.
function onError(error){
}
contactfindOptions
Options like filterring by name
var options = new
ContactFindOptions()
options.filter=”Bob”;

<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" src="phonegap-1.1.0.js"></script>
<script type="text/javascript">
/** Called when phonegap javascript is loaded */
function onDeviceReady() {
// find all contacts
var options = new ContactFindOptions();
options.filter = "";
var fields = [ "phoneNumbers", "name" ]; → We need to define the contact fields that we want to fetch.
navigator.service.contacts.find(fields, onSuccess, onError, options);
}
function onSuccess(contacts) {
var ul = document.getElementById("list");
for (var index = 0; index < contacts.length; index++) {
var name = contacts[index].name.formatted;
var phoneNumber = contacts[index].phoneNumbers[0].value;
var li = document.createElement('li');
li.innerHTML = "<a href=\"tel://"+phoneNumber+"\">" + name + "</a>";
ul.appendChild(li);
}
};
function onError() {
alert('onError!');
};
/** Called when browser load this page*/
function init() {
document.addEventListener("deviceready", onDeviceReady, false);
}
</script>
</head>
<body onLoad="init()">
<h1>Contacts</h1>
<ul id="list">
</ul>
</body>
</html>

댓글 없음:

댓글 쓰기

ETL 솔루션 환경

ETL 솔루션 환경 하둡은 대용량 데이터를 값싸고 빠르게 분석할 수 있는 길을 만들어줬다. 통계분석 엔진인 “R”역시 하둡 못지 않게 관심을 받고 있다. 빅데이터 역시 데이터라는 점을 볼때 분산처리와 분석 그 이전에 데이터 품질 등 데이...