Skip to content
Permalink
Browse files
  • Loading branch information
purplecabbage committed Feb 4, 2013
2 parents de3adea + e3c14ed commit f5d892e97548153be2fcc078913835f62eaffd7c
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 29 deletions.
@@ -1 +1 @@
2.3.0
2.4.0rc1
@@ -138,7 +138,7 @@ describe('FileTransfer', function() {
});
it("should be able to download a file using file:// (when hosted from file://)", function() {
var fail = createDoNotCallSpy('downloadFail');
var remoteFile = window.location.href.replace(/\?.*/, '');
var remoteFile = window.location.href.replace(/\?.*/, '').replace(/ /g, '%20');
var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
var lastProgressEvent = null;

@@ -287,7 +287,6 @@ describe('FileTransfer', function() {
});
});
describe('upload method', function() {

it("should be able to upload a file", function() {
var remoteFile = server + "/upload";
var localFileName = "upload.txt";
@@ -27,32 +27,37 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
<title>Cordova Mobile Spec</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="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>



<script type="text/javascript" charset="utf-8">

var deviceReady = false;

//-------------------------------------------------------------------------
// Camera
// Camera
//-------------------------------------------------------------------------

function showPicture(url, callback) {
var img = document.getElementById('camera_image');
img.style.visibility = "visible";
img.style.display = "block";
img.src = url;
img.onloadend = callback;
}

/**
* Capture picture
*/
function getPicture() {
//navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,

//navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
// destinationType: Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA });

navigator.camera.getPicture(
function(data) {
var img = document.getElementById('camera_image');
img.style.visibility = "visible";
img.style.display = "block";
//img.src = "data:image/jpeg;base64," + data;
img.src = data;
showPicture(data);
document.getElementById('camera_status').innerHTML = "Success";
},
function(e) {
@@ -69,11 +74,7 @@
function getImageUsingFileUri() {
navigator.camera.getPicture(
function(data) {
var img = document.getElementById('camera_image');
img.style.visibility = "visible";
img.style.display = "block";
//img.src = "data:image/jpeg;base64," + data;
img.src = data;
showPicture(data);
document.getElementById('camera_status').innerHTML = "Success";
},
function(e) {
@@ -105,6 +106,51 @@
Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
};

function testNativeFile(inputEl) {
// iOS 6 likes to dead-lock in the onchange context if you
// do any alerts or try to remote-debug.
window.setTimeout(function() {
testNativeFile2(inputEl);
}, 0);
}

function testNativeFile2(inputEl) {
if (!inputEl.value) {
alert('No file selected.');
return;
}
var file = inputEl.files[0];
if (!file) {
alert('Got value but no file.');
return;
}
var URLApi = window.URL || window.webkitURL;
var statusText = '';
if (URLApi) {
var blobURL = URLApi.createObjectURL(file);
if (blobURL) {
showPicture(blobURL, function() {
URLApi.revokeObjectURL(blobURL);
});
} else {
statusText = 'URL.createObjectURL returned null';
}
} else {
statusText = 'URL.createObjectURL() not supported.';
}
document.getElementById('camera_status').innerHTML = statusText;
var reader = new FileReader();
reader.onloadend = function() {
if (!reader.result) {
statusText += ' FileReader.readAsDataURL() failed';
} else {
statusText += ' DataURL size: ' + reader.result.length;
}
document.getElementById('camera_status').innerHTML = statusText;
};
reader.readAsDataURL(file);
}

/**
* Function called when page has finished loading.
*/
@@ -124,7 +170,7 @@

</head>
<body onload="init();" id="stage" class="theme">

<h1>Camera</h1>
<div id="info">
<b>Status:</b> <span id="camera_status"></span><br>
@@ -134,6 +180,14 @@ <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();">Select Image Using Native URI</div>
<h3>input type=file</h3>
<input type="file" onchange="testNativeFile(this)">
<h3>capture=camera</h3>
<input type="file" accept="image/*;capture=camera" onchange="testNativeFile(this)">
<h3>capture=camcorder</h3>
<input type="file" accept="video/*;capture=camcorder" onchange="testNativeFile(this)">
<h3>capture=microphone</h3>
<input type="file" accept="audio/*;capture=microphone" onchange="testNativeFile(this)">
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>
</html>
@@ -19,7 +19,7 @@
*
*/

var VERSION='2.3.0';
var VERSION='2.4.0rc1';
var scripts = document.getElementsByTagName('script');
var cordovaPath = scripts[scripts.length - 1].src.replace('cordova.js', 'cordova-'+VERSION+'.js');

@@ -42,6 +42,11 @@
deviceReady = true;
console.log("Device="+device.platform+" "+device.version);
}, false);
function updateUserAgent() {
document.getElementById("user-agent").textContent = navigator.userAgent;
}
updateUserAgent();
window.setInterval(updateUserAgent, 1500);
window.setTimeout(function() {
if (!deviceReady) {
alert("Error: Apache Cordova did not initialize. Demo will not run correctly.");
@@ -56,9 +61,11 @@

<h1>InAppBrowser</h1>
<div id="info">
Make sure http://www.google.com is white listed
Make sure http://www.apple.com is not in the white list
Make sure http://www.google.com is white listed. </br>
Make sure http://www.apple.com is not in the white list.</br> In iOS, starred <span style="vertial-align:super">*</span> tests will leave the app with no way to return. </br>
<h4>User-Agent: <span id="user-agent"> </span></h4>
</div>
<div onclick="backHome();">Back</div>
<h1>Local URL</h1>
<div class="btn large" onclick="window.open('local.html');">Default: CordovaWebView</div>
<div class="btn large" onclick="window.open('local.html', '_self');">Target=Self: CordovaWebView</div>
@@ -67,8 +74,8 @@ <h1>Local URL</h1>
<div class="btn large" onclick="window.open('local.html', 'random_string');">Target=Random: InAppBrowser</div>
<div class="btn large" onclick="window.open('local.html', 'random_string', 'location=no');">Target=Random, no location bar: InAppBrowser</div>
<h1>White Listed URL</h1>
<div class="btn large" onclick="window.open('http://www.google.com');">Default: CordovaWebView</div>
<div class="btn large" onclick="window.open('http://www.google.com', '_self');">Target=Self: CordovaWebView</div>
<div class="btn large" onclick="window.open('http://www.google.com');">Default: CordovaWebView<span style="vertical-align:super">*</span></div>
<div class="btn large" onclick="window.open('http://www.google.com', '_self');">Target=Self: CordovaWebView<span style="vertical-align:super">*</span></div>
<div class="btn large" onclick="window.open('http://www.google.com', '_system');">Target=System: System Browser</div>
<div class="btn large" onclick="window.open('http://www.google.com', '_blank');">Target=Blank: InAppBrowser</div>
<div class="btn large" onclick="window.open('http://www.google.com', 'random_string');">Target=Random: InAppBrowser</div>
@@ -80,6 +87,9 @@ <h1>Non White Listed URL</h1>
<div class="btn large" onclick="window.open('http://www.apple.com', '_blank');">Target=Blank: InAppBrowser</div>
<div class="btn large" onclick="window.open('http://www.apple.com', 'random_string');">Target=Random: InAppBrowser</div>
<div class="btn large" onclick="window.open('http://www.apple.com', 'random_string', 'location=no');">Target=Random, no location bar: InAppBrowser</div>
<h1>PDF URL</h1>
<div class="btn large" onclick="window.open('http://www.stluciadance.com/prospectus_file/sample.pdf');">Remote URL</div>
<div class="btn large" onclick="window.open('local.pdf', '_blank');">Local URL</div>
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>
@@ -27,14 +27,25 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
<title>Cordova Mobile Spec</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="../cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
</head>
<body id="stage" class="theme">

<h1>InAppBrowser - Local URL</h1>
<div id="info">
You have successfully loaded a local URL
</div>
</div>
<div>User-Agent = <span id="u-a"></span></div>
<div><a href="http://www.google.com">Visit Google</a></div>
<div><a href="http://www.yahoo.com">Visit Yahoo</a></div>
<div><a href="http://www.stluciadance.com/prospectus_file/sample.pdf">Check out my remote PDF</a></div>
<div><a href="local.pdf">Check out my local PDF</a></div>
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
</body>
</html>
<script>
function updateUserAgent() {
document.getElementById("u-a").textContent = navigator.userAgent;
}
updateUserAgent();
window.setInterval(updateUserAgent, 1500);
</script>
</html>
BIN +8.37 KB inappbrowser/local.pdf
Binary file not shown.
@@ -41,6 +41,7 @@ <h4>Name: <span id="name"> </span></h4>
<h4>Model: <span id="model"> </span></h4>
<h4>Width: <span id="width"> </span>, Height: <span id="height">
</span>, Color Depth: <span id="colorDepth"></span></h4>
<h4>User-Agent: <span id="user-agent"> </span></h4>
</div>
<a href="autotest/index.html" class="btn large">Automatic Test</a>
<a href="accelerometer/index.html" class="btn large">Accelerometer</a>
@@ -159,4 +159,5 @@ function init() {
// doesn't have a scroll button
// document.addEventListener("touchmove", preventBehavior, false);
document.addEventListener("deviceready", deviceInfo, true);
document.getElementById("user-agent").textContent = navigator.userAgent;
}

0 comments on commit f5d892e

Please sign in to comment.