Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

vcard

  • Loading branch information...
commit 71ab39d1b2bceb090151e557ec8e4ad1667ff635 1 parent 5422d8d
@don don authored
View
2  .classpath
@@ -4,6 +4,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/phonegap-nfc.jar"/>
- <classpathentry kind="lib" path="lib/phonegap-1.0.0rc1.jar"/>
+ <classpathentry kind="lib" path="lib/phonegap-1.0.0rc1-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
6 .gitignore
@@ -1,2 +1,6 @@
bin/
-gen/
+gen/
+.idea/
+*.iml
+pg.sh
+update.sh
View
20 assets/www/index.html
@@ -3,9 +3,9 @@
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>Rock Paper Scissors</title>
+ <title>PhoneGap Peer to Peer Demo</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
- <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0rc1.js"></script>
+ <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0rc1-SNAPSHOT.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-nfc.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
@@ -13,10 +13,20 @@
<h1>PhoneGap NFC P2P</h1>
<form>
Mime Type:<br/>
- <input type="text" name="mimeType" value="game/rockpaperscissors" size="30" /><br/>
+ <input type="text" name="mimeType" value="text/x-vCard" size="30" /><br/>
Payload:<br/>
- <textarea name="payload" rows="10" cols="30">Rock</textarea>
+ <textarea name="payload" rows="10" cols="30">BEGIN:VCARD
+VERSION:2.1
+N:Coleman;Don;;;
+FN:Don Coleman
+ORG:Chariot Solutions;
+URL:http://chariotsolutions.com
+TEL;WORK:215-358-1780
+EMAIL;WORK:dcoleman@chariotsolutions.com
+END:VCARD
+</textarea>
+ <br/>
+ <input type="checkbox" name="share" id="checkbox" value="Share"/><label for="checkbox">Share Tag</label>
</form>
- <button id="button">Share</button>
</body>
</html>
View
36 assets/www/main.js
@@ -1,21 +1,41 @@
/*global Ndef */
+function onChange(e) {
+ if (e.target.checked) {
+ shareTag();
+ } else {
+ unshareTag();
+ }
+}
+
+function unshareTag() {
+ navigator.nfc.unshareTag(
+ function () {
+ navigator.notification.vibrate(100);
+ setTimeout(function() {
+ navigator.notification.vibrate(100);
+ }, 200);
+ }, function () {
+ alert("Failed to unshare tag.");
+ });
+}
+
function shareTag() {
- var mimeType = document.forms[0].elements["mimeType"].value,
- payload = document.forms[0].elements["payload"].value,
- record = Ndef.mimeMediaRecord(mimeType, Ndef.stringToBytes(payload));
+ var mimeType = document.forms[0].elements["mimeType"].value,
+ payload = document.forms[0].elements["payload"].value,
+ record = Ndef.mimeMediaRecord(mimeType, Ndef.stringToBytes(payload));
- navigator.nfc.p2p(
- [record],
- function () {
+ navigator.nfc.shareTag(
+ [record],
+ function () {
navigator.notification.vibrate(100);
}, function () {
alert("Failed to share tag.");
- });
+ });
}
var ready = function () {
- document.getElementById('button').addEventListener("click", shareTag, false);
+ document.getElementById('checkbox').addEventListener("change", onChange, false);
};
document.addEventListener('deviceready', ready, false);
View
17 assets/www/master.css
@@ -6,9 +6,14 @@ p {
margin: 10px 15px 0 5px;
}
-button {
- margin-top: 10px;
- font-size: 1.25em;
- height: 50px;
- width: 150px;
-}
+textarea {
+ margin-bottom: 20px;
+}
+
+input:last-of-type {
+ margin-left: 10px;
+}
+
+label {
+ font-size: 1.25em;
+}
View
43 assets/www/phonegap-1.0.0rc1.js → assets/www/phonegap-1.0.0rc1-SNAPSHOT.js
@@ -1067,8 +1067,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1163,8 +1161,6 @@ PhoneGap.addConstructor(function() {
navigator.app = window.app = new App();
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1262,8 +1258,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1454,9 +1448,7 @@ PhoneGap.addConstructor(function(){
navigator.device.capture = window.device.capture = new Capture();
}
});
-}
-
-/*
+}/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
@@ -1575,8 +1567,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1887,8 +1877,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -1932,8 +1920,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -2039,8 +2025,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3100,8 +3084,6 @@ PhoneGap.addConstructor(function() {
if(typeof window.resolveLocalFileSystemURI == "undefined") window.resolveLocalFileSystemURI = pgLocalFileSystem.resolveLocalFileSystemURI;
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3187,8 +3169,6 @@ var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
this.params = params || null;
};
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3387,17 +3367,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010, IBM Corporation
- */
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3609,8 +3578,6 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
}
};
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3693,8 +3660,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3817,8 +3782,6 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -3908,8 +3871,6 @@ PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
PositionError.TIMEOUT = 3;
}
-
-
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@@ -4338,5 +4299,3 @@ PhoneGap.addConstructor(function() {
}
});
}
-
-
View
14 assets/www/phonegap-nfc.js
@@ -121,9 +121,9 @@ var Ndef = {
navigator.nfc = {
- addMimeTypeListener: function (mime_type, callback, win, fail) {
+ addMimeTypeListener: function (mimeType, callback, win, fail) {
document.addEventListener("ndef-mime", callback, false);
- PhoneGap.exec(win, fail, "NdefPlugin", "registerMimeType", [mime_type]);
+ PhoneGap.exec(win, fail, "NdefPlugin", "registerMimeType", [mimeType]);
},
addNdefListener: function (callback, win, fail) {
@@ -140,10 +140,14 @@ navigator.nfc = {
PhoneGap.exec(win, fail, "NdefPlugin", "writeTag", [ndefMessage]);
},
- p2p: function (ndefMessage, win, fail) {
- PhoneGap.exec(win, fail, "NdefPlugin", "p2p", [ndefMessage]);
+ shareTag: function (ndefMessage, win, fail) {
+ PhoneGap.exec(win, fail, "NdefPlugin", "shareTag", [ndefMessage]);
},
-
+
+ unshareTag: function (win, fail) {
+ PhoneGap.exec(win, fail, "NdefPlugin", "unshareTag", []);
+ },
+
// Java is responsible for calling this method
// Type is ndef-mime, ndef, or ndef-unformatted
fireEvent: function (type, tagData) {
View
BIN  lib/phonegap-1.0.0rc1.jar → lib/phonegap-1.0.0rc1-SNAPSHOT.jar
Binary file not shown
View
BIN  lib/phonegap-nfc.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.