cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/11] spec commit: [CB-2213] Added a new test for getMetadata.
Date Tue, 12 Feb 2013 03:15:59 GMT
[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/0cb7f681
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/0cb7f681
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/0cb7f681

Branch: refs/heads/master
Commit: 0cb7f681e2dc1f6503d73d2587f83e1a7e76a8db
Parents: ba2711e
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Wed Jan 16 12:40:48 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 11 21:18:02 2013 -0500

----------------------------------------------------------------------
 camera/index.html |   57 +++++++++++++++++++++---------------------------
 1 files changed, 25 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/0cb7f681/camera/index.html
----------------------------------------------------------------------
diff --git a/camera/index.html b/camera/index.html
index 4462a21..552e4bb 100644
--- a/camera/index.html
+++ b/camera/index.html
@@ -102,52 +102,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:
@@ -231,6 +223,7 @@
     <div class="btn large" onclick="getImageUsingFileUri(true);">Upload to jitsu with
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>
     <h3>input type=file</h3>
     <input type="file" onchange="testNativeFile(this)">
     <h3>capture=camera</h3>


Mime
View raw message