- From: Richard Tibbett via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 14 Jan 2011 12:07:56 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/contacts
In directory hutz:/tmp/cvs-serv7507/contacts
Modified Files:
Overview.html
Log Message:
Added data URI examples to 'Adding and Updating Contacts' section.
Index: Overview.html
===================================================================
RCS file: /sources/public/2009/dap/contacts/Overview.html,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- Overview.html 10 Jan 2011 15:24:41 -0000 1.103
+++ Overview.html 14 Jan 2011 12:07:53 -0000 1.104
@@ -1674,12 +1674,29 @@
<h4>Adding a new Contact</h4>
<p>
- A web page can dynamically generate a vCard object on the client side for download to the user's unified address book via the
- [[FILE-WRITER]] and [[FILE-API]] interfaces. The following example shows the process in which a web site may create a vCard object
- dynamically and then present this to the user. The user may then save this information by clicking on the presented information, download the
+ A web page can dynamically generate a vCard object on the client side for download to the user's unified address book via either data: URIs [[RFC2397]] or using the
+ [[FILE-WRITER]] and [[FILE-API]] interfaces. The following examples show two methods for creating a vCard object
+ dynamically and then presenting this to the user. The user may then save this information by clicking on the presented information, download the
dynamically generated vCard object and invoke a suitable application with which to handle the dynamic resource.
</p>
-
+
+ <div class="example">
+ <pre class="sh_javascript"><a id="vcard">Save our Contact Details</a>
+
+<script type="text/javascript">
+ var vcard = 'BEGIN:VCARD\r\n' +
+ 'VERSION:2.1\r\n' +
+ 'N:Doe;John\r\n' +
+ 'FN:John Doe\r\n' +
+ 'TEL;WORK;VOICE:123456\r\n' +
+ 'END:VCARD';
+
+ // assign vCard as a Data URI to an anchor element for presentation and download by the user
+ document.getElementById('vcard').href = "data:text/x-vcard;charset=utf-8," + encodeURIComponent( vcard );
+</script>
+</pre>
+ </div>
+
<div class="example">
<pre class="sh_javascript"><a id="vcard">Save our Contact Details</a>
@@ -1718,11 +1735,32 @@
</p>
<p>
- The example below shows how to update an existing Contact in the user's unified address book by maintaining a valid UID property
+ The examples below show two methods for updating an existing Contact in the user's unified address book by maintaining a valid UID property
while changing other parameters of the Contact card. The user is then required to click on the resulting anchor element to download
the modified Contact resource.
</p>
-
+
+ <div class="example">
+ <pre class="sh_javascript"><a id="vcard">Save our Contact Details</a>
+
+<script type="text/javascript">
+ // Obtain a single existing Contact object resulting from navigator.service.contacts.find()
+ var existingContactObj = ...;
+
+ var vcard = 'BEGIN:VCARD\r\n' +
+ 'VERSION:2.1\r\n' +
+ 'UID:' + existingContactObj.id + // assign the Contact.id to a UID property
+ 'N:Doe;John\r\n' +
+ 'FN:John Doe\r\n' +
+ 'TEL;HOME;VOICE:654321\r\n' +
+ 'END:VCARD';
+
+ // assign vCard as a Data URI to an anchor element for presentation and download by the user
+ document.getElementById('vcard').href = "data:text/x-vcard;charset=utf-8," + encodeURIComponent( vcard );
+</script>
+</pre>
+ </div>
+
<div class="example">
<pre class="sh_javascript"><a id="vcard">Update our Contact Details</a>
@@ -1733,7 +1771,7 @@
// Modify some parameters as required. e.g. add a new phone number
existingContactObj.phoneNumbers.push({
type: 'home',
- value: '+440000000002'
+ value: '654321'
});
// With the existing Contact object, create an ArrayBuffer consisting of valid vCard
Received on Friday, 14 January 2011 12:07:57 UTC