Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

vcard

  • Loading branch information...
commit 71ab39d1b2bceb090151e557ec8e4ad1667ff635 1 parent 5422d8d
Don Coleman don authored
2  .classpath
@@ -4,6 +4,6 @@
4 4 <classpathentry kind="src" path="gen"/>
5 5 <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6 6 <classpathentry kind="lib" path="lib/phonegap-nfc.jar"/>
7   - <classpathentry kind="lib" path="lib/phonegap-1.0.0rc1.jar"/>
  7 + <classpathentry kind="lib" path="lib/phonegap-1.0.0rc1-SNAPSHOT.jar"/>
8 8 <classpathentry kind="output" path="bin"/>
9 9 </classpath>
6 .gitignore
... ... @@ -1,2 +1,6 @@
1 1 bin/
2   -gen/
  2 +gen/
  3 +.idea/
  4 +*.iml
  5 +pg.sh
  6 +update.sh
20 assets/www/index.html
@@ -3,9 +3,9 @@
3 3 <head>
4 4 <meta name="viewport" content="width=320; user-scalable=no" />
5 5 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6   - <title>Rock Paper Scissors</title>
  6 + <title>PhoneGap Peer to Peer Demo</title>
7 7 <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
8   - <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0rc1.js"></script>
  8 + <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0rc1-SNAPSHOT.js"></script>
9 9 <script type="text/javascript" charset="utf-8" src="phonegap-nfc.js"></script>
10 10 <script type="text/javascript" charset="utf-8" src="main.js"></script>
11 11 </head>
@@ -13,10 +13,20 @@
13 13 <h1>PhoneGap NFC P2P</h1>
14 14 <form>
15 15 Mime Type:<br/>
16   - <input type="text" name="mimeType" value="game/rockpaperscissors" size="30" /><br/>
  16 + <input type="text" name="mimeType" value="text/x-vCard" size="30" /><br/>
17 17 Payload:<br/>
18   - <textarea name="payload" rows="10" cols="30">Rock</textarea>
  18 + <textarea name="payload" rows="10" cols="30">BEGIN:VCARD
  19 +VERSION:2.1
  20 +N:Coleman;Don;;;
  21 +FN:Don Coleman
  22 +ORG:Chariot Solutions;
  23 +URL:http://chariotsolutions.com
  24 +TEL;WORK:215-358-1780
  25 +EMAIL;WORK:dcoleman@chariotsolutions.com
  26 +END:VCARD
  27 +</textarea>
  28 + <br/>
  29 + <input type="checkbox" name="share" id="checkbox" value="Share"/><label for="checkbox">Share Tag</label>
19 30 </form>
20   - <button id="button">Share</button>
21 31 </body>
22 32 </html>
36 assets/www/main.js
... ... @@ -1,21 +1,41 @@
1 1 /*global Ndef */
2 2
  3 +function onChange(e) {
  4 + if (e.target.checked) {
  5 + shareTag();
  6 + } else {
  7 + unshareTag();
  8 + }
  9 +}
  10 +
  11 +function unshareTag() {
  12 + navigator.nfc.unshareTag(
  13 + function () {
  14 + navigator.notification.vibrate(100);
  15 + setTimeout(function() {
  16 + navigator.notification.vibrate(100);
  17 + }, 200);
  18 + }, function () {
  19 + alert("Failed to unshare tag.");
  20 + });
  21 +}
  22 +
3 23 function shareTag() {
4   - var mimeType = document.forms[0].elements["mimeType"].value,
5   - payload = document.forms[0].elements["payload"].value,
6   - record = Ndef.mimeMediaRecord(mimeType, Ndef.stringToBytes(payload));
  24 + var mimeType = document.forms[0].elements["mimeType"].value,
  25 + payload = document.forms[0].elements["payload"].value,
  26 + record = Ndef.mimeMediaRecord(mimeType, Ndef.stringToBytes(payload));
7 27
8   - navigator.nfc.p2p(
9   - [record],
10   - function () {
  28 + navigator.nfc.shareTag(
  29 + [record],
  30 + function () {
11 31 navigator.notification.vibrate(100);
12 32 }, function () {
13 33 alert("Failed to share tag.");
14   - });
  34 + });
15 35 }
16 36
17 37 var ready = function () {
18   - document.getElementById('button').addEventListener("click", shareTag, false);
  38 + document.getElementById('checkbox').addEventListener("change", onChange, false);
19 39 };
20 40
21 41 document.addEventListener('deviceready', ready, false);
17 assets/www/master.css
@@ -6,9 +6,14 @@ p {
6 6 margin: 10px 15px 0 5px;
7 7 }
8 8
9   -button {
10   - margin-top: 10px;
11   - font-size: 1.25em;
12   - height: 50px;
13   - width: 150px;
14   -}
  9 +textarea {
  10 + margin-bottom: 20px;
  11 +}
  12 +
  13 +input:last-of-type {
  14 + margin-left: 10px;
  15 +}
  16 +
  17 +label {
  18 + font-size: 1.25em;
  19 +}
43 assets/www/phonegap-1.0.0rc1.js → assets/www/phonegap-1.0.0rc1-SNAPSHOT.js
@@ -1067,8 +1067,6 @@ PhoneGap.addConstructor(function() {
1067 1067 }
1068 1068 });
1069 1069 }
1070   -
1071   -
1072 1070 /*
1073 1071 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1074 1072 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1163,8 +1161,6 @@ PhoneGap.addConstructor(function() {
1163 1161 navigator.app = window.app = new App();
1164 1162 });
1165 1163 }
1166   -
1167   -
1168 1164 /*
1169 1165 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1170 1166 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1262,8 +1258,6 @@ PhoneGap.addConstructor(function() {
1262 1258 }
1263 1259 });
1264 1260 }
1265   -
1266   -
1267 1261 /*
1268 1262 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1269 1263 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1454,9 +1448,7 @@ PhoneGap.addConstructor(function(){
1454 1448 navigator.device.capture = window.device.capture = new Capture();
1455 1449 }
1456 1450 });
1457   -}
1458   -
1459   -/*
  1451 +}/*
1460 1452 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1461 1453 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
1462 1454 *
@@ -1575,8 +1567,6 @@ PhoneGap.addConstructor(function() {
1575 1567 }
1576 1568 });
1577 1569 }
1578   -
1579   -
1580 1570 /*
1581 1571 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1582 1572 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1887,8 +1877,6 @@ PhoneGap.addConstructor(function() {
1887 1877 }
1888 1878 });
1889 1879 }
1890   -
1891   -
1892 1880 /*
1893 1881 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1894 1882 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1932,8 +1920,6 @@ PhoneGap.addConstructor(function() {
1932 1920 }
1933 1921 });
1934 1922 }
1935   -
1936   -
1937 1923 /*
1938 1924 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
1939 1925 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -2039,8 +2025,6 @@ PhoneGap.addConstructor(function() {
2039 2025 }
2040 2026 });
2041 2027 }
2042   -
2043   -
2044 2028 /*
2045 2029 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
2046 2030 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3100,8 +3084,6 @@ PhoneGap.addConstructor(function() {
3100 3084 if(typeof window.resolveLocalFileSystemURI == "undefined") window.resolveLocalFileSystemURI = pgLocalFileSystem.resolveLocalFileSystemURI;
3101 3085 });
3102 3086 }
3103   -
3104   -
3105 3087 /*
3106 3088 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3107 3089 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3187,8 +3169,6 @@ var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
3187 3169 this.params = params || null;
3188 3170 };
3189 3171 }
3190   -
3191   -
3192 3172 /*
3193 3173 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3194 3174 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3387,17 +3367,6 @@ PhoneGap.addConstructor(function() {
3387 3367 }
3388 3368 });
3389 3369 }
3390   -
3391   -
3392   -/*
3393   - * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3394   - * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
3395   - *
3396   - * Copyright (c) 2005-2010, Nitobi Software Inc.
3397   - * Copyright (c) 2010, IBM Corporation
3398   - */
3399   -
3400   -
3401 3370 /*
3402 3371 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3403 3372 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3609,8 +3578,6 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
3609 3578 }
3610 3579 };
3611 3580 }
3612   -
3613   -
3614 3581 /*
3615 3582 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3616 3583 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3693,8 +3660,6 @@ PhoneGap.addConstructor(function() {
3693 3660 }
3694 3661 });
3695 3662 }
3696   -
3697   -
3698 3663 /*
3699 3664 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3700 3665 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3817,8 +3782,6 @@ PhoneGap.addConstructor(function() {
3817 3782 }
3818 3783 });
3819 3784 }
3820   -
3821   -
3822 3785 /*
3823 3786 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3824 3787 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3908,8 +3871,6 @@ PositionError.PERMISSION_DENIED = 1;
3908 3871 PositionError.POSITION_UNAVAILABLE = 2;
3909 3872 PositionError.TIMEOUT = 3;
3910 3873 }
3911   -
3912   -
3913 3874 /*
3914 3875 * PhoneGap is available under *either* the terms of the modified BSD license *or* the
3915 3876 * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -4338,5 +4299,3 @@ PhoneGap.addConstructor(function() {
4338 4299 }
4339 4300 });
4340 4301 }
4341   -
4342   -
14 assets/www/phonegap-nfc.js
@@ -121,9 +121,9 @@ var Ndef = {
121 121
122 122 navigator.nfc = {
123 123
124   - addMimeTypeListener: function (mime_type, callback, win, fail) {
  124 + addMimeTypeListener: function (mimeType, callback, win, fail) {
125 125 document.addEventListener("ndef-mime", callback, false);
126   - PhoneGap.exec(win, fail, "NdefPlugin", "registerMimeType", [mime_type]);
  126 + PhoneGap.exec(win, fail, "NdefPlugin", "registerMimeType", [mimeType]);
127 127 },
128 128
129 129 addNdefListener: function (callback, win, fail) {
@@ -140,10 +140,14 @@ navigator.nfc = {
140 140 PhoneGap.exec(win, fail, "NdefPlugin", "writeTag", [ndefMessage]);
141 141 },
142 142
143   - p2p: function (ndefMessage, win, fail) {
144   - PhoneGap.exec(win, fail, "NdefPlugin", "p2p", [ndefMessage]);
  143 + shareTag: function (ndefMessage, win, fail) {
  144 + PhoneGap.exec(win, fail, "NdefPlugin", "shareTag", [ndefMessage]);
145 145 },
146   -
  146 +
  147 + unshareTag: function (win, fail) {
  148 + PhoneGap.exec(win, fail, "NdefPlugin", "unshareTag", []);
  149 + },
  150 +
147 151 // Java is responsible for calling this method
148 152 // Type is ndef-mime, ndef, or ndef-unformatted
149 153 fireEvent: function (type, tagData) {
BIN  lib/phonegap-1.0.0rc1.jar → lib/phonegap-1.0.0rc1-SNAPSHOT.jar
Binary file not shown
BIN  lib/phonegap-nfc.jar
Binary file not shown

0 comments on commit 71ab39d

Please sign in to comment.
Something went wrong with that request. Please try again.