You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/17 16:00:30 UTC
[1/3] spec commit: [CB-2213] Added a new test for getMetadata.
[CB-2213] Added a new test for getMetadata.
Also consolidated NATIVE_URI tests.
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/5e640cbe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/5e640cbe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/5e640cbe
Branch: refs/heads/native-uri
Commit: 5e640cbe8e9c2537a3ea15c932fe6abe8f9ef0b0
Parents: 485a9ef
Author: Max Woghiren <ma...@gmail.com>
Authored: Wed Jan 16 12:40:48 2013 -0500
Committer: Max Woghiren <ma...@gmail.com>
Committed: Wed Jan 16 13:17:46 2013 -0500
----------------------------------------------------------------------
camera/index.html | 59 ++++++++++++++++++++---------------------------
1 files changed, 25 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/5e640cbe/camera/index.html
----------------------------------------------------------------------
diff --git a/camera/index.html b/camera/index.html
index 969272b..22cdedb 100644
--- a/camera/index.html
+++ b/camera/index.html
@@ -87,52 +87,44 @@
/**
* Select image from library using a NATIVE_URI destination type
*/
- function getImageInfoUsingNativeUri() {
- var onFileReceived = function(file) {
- var img = document.getElementById('camera_image');
- img.style.visibility = "hidden";
- document.getElementById('camera_status').innerHTML = "Success; fullPath = " + file.fullPath + "; name = " + file.name + "; type = " + file.type + "; size = " + file.size + "; date = " + file.lastModifiedDate;
+ function getImageUsingNativeUri() {
+ var onMetadataReceived = function(metadata) {
+ document.getElementById('camera_status').innerHTML += "FileEntry.getMetadata <b>success</b>: modificationTime = " + metadata.modificationTime + "<br />";
};
- var onError = function(e) {
- console.log("Error getting picture: " + e);
- document.getElementById('camera_status').innerHTML = "Error getting picture: " + e;
+
+ var onFileReadAsDataURL = function(evt) {
+ var img = document.getElementById('camera_image');
+ img.style.visibility = "visible";
+ img.style.display = "block";
+ img.src = evt.target.result;
+ document.getElementById('camera_status').innerHTML += "FileReader.readAsDataURL <b>success</b><br />"
};
- navigator.camera.getPicture(
- function(data) {
- var fileEntry = new FileEntry('image_name.png', data);
- var file = fileEntry.file(onFileReceived, onError);
- },
- onError,
- { quality: 50, destinationType:
- Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
- };
- /**
- * Select image from library using a NATIVE_URI destination type
- */
- function getImageUsingNativeUri() {
var onFileReceived = function(file) {
+ document.getElementById('camera_status').innerHTML += "FileEntry.file <b>success</b>: fullPath = " + file.fullPath + "; name = " + file.name;
+ document.getElementById('camera_status').innerHTML += "; type = " + file.type + "; size = " + file.size + "; date = " + file.lastModifiedDate + "<br />";
+
+ // Test File API here.
var reader = new FileReader();
- reader.onload = function(evt) {
- var img = document.getElementById('camera_image');
- img.style.visibility = "visible";
- img.style.display = "block";
- img.src = evt.target.result;
- document.getElementById('camera_status').innerHTML = "Success";
- };
+ reader.onload = onFileReadAsDataURL;
reader.onerror = function(evt) {
- onError(evt.target.error.code);
+ onError(evt.target.error);
};
reader.readAsDataURL(file);
};
+
var onError = function(e) {
- console.log("Error getting picture: " + e);
- document.getElementById('camera_status').innerHTML = "Error getting picture: " + e;
+ console.log("Error getting picture: " + e.code);
+ document.getElementById('camera_status').innerHTML += "Error getting picture: " + e.code + "<br />";
};
+
navigator.camera.getPicture(
function(data) {
var fileEntry = new FileEntry('image_name.png', data);
- var file = fileEntry.file(onFileReceived, onError);
+
+ // Test FileEntry API here.
+ fileEntry.getMetadata(onMetadataReceived, onError);
+ fileEntry.file(onFileReceived, onError);
},
onError,
{ quality: 50, destinationType:
@@ -167,8 +159,7 @@
<h2>Action</h2>
<div class="btn large" onclick="getPicture();">Take Picture</div>
<div class="btn large" onclick="getImageUsingFileUri();">Select Image Using File URI</div>
- <div class="btn large" onclick="getImageInfoUsingNativeUri();">Native URI: Select Image, Show Info</div>
- <div class="btn large" onclick="getImageUsingNativeUri();">Native URI: Select Image, Show Image</div>
+ <div class="btn large" onclick="getImageUsingNativeUri();">Select Image Using Native URI</div>
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>