Skip to content

Instantly share code, notes, and snippets.

@lovuikeng
Created December 3, 2011 09:33
Show Gist options
  • Select an option

  • Save lovuikeng/1426675 to your computer and use it in GitHub Desktop.

Select an option

Save lovuikeng/1426675 to your computer and use it in GitHub Desktop.
SpringOne 2GX HTMLExpense client controller
// source: https://github.com/SpringSource/html5expense/blob/master/client/www/controller.js
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
...
}
$('#create-new-add-receipt').live('pagecreate', function(event) {
$('#create-new-add-receipt-capture-photo').click(function() {
navigator.camera.getPicture(onPhotoCaptureSuccess, onPhotoCaptureError, {
quality : imageQuality,
targetWidth : imageWidth,
destinationType : destinationType.FILE_URI
});
return false;
});
...
});
function onPhotoCaptureSuccess(imageURI) {
$.mobile.showPageLoadingMsg();
var image = document.getElementById('receiptImage');
image.src = imageURI;
...
var url = getApiUrl('reports/' + expenseReport.id + '/expenses/' + expense.id + '/receipt');
// PhoneGap component
var fileTransfer = new FileTransfer();
fileTransfer.upload(imageURI, url, onFileTransferSuccess, onFileTransferError, opts);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment