diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-02-25 11:06:59 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-02-25 11:06:59 -0500 |
commit | 4a62fe6388e75ed11f61dab23c63721fa52aa54e (patch) | |
tree | 3aa0e340e339d8cd2be3ea3fcd3e508f1fac61cb /www/js | |
parent | 16dbb6d67620fd86adc44dfd704a5f590eaf8348 (diff) |
Stuff
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/report.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/www/js/report.js b/www/js/report.js new file mode 100644 index 0000000..661d63f --- /dev/null +++ b/www/js/report.js @@ -0,0 +1,41 @@ +document.addEventListener("deviceready", onDeviceReady, false); +function onDeviceReady() { + var ui = document.getElementById("camera-ui"); + if (navigator.camera) { + ui.innerHTML = "<button onclick=\"takePhoto(true);return false\">Add Photo</button>" + } else { + ui.innerHTML = "Camera not supported on your device"; + } +} +function takePhoto(firstrun) { + var options = { + /*quality: 50,*/ + destinationType: Camera.DestinationType.DATA_URL, /* DATA_URL, FILE_URI, NATIVE_URI */ + sourceType: Camera.PictureSourceType.CAMERA, /* PHOTOLIBRARY, CAMERA, SAVEDPHOTOALBUM */ + allowEdit: true, + encodingType: Camera.EncodingType.JPEG, /* JPEG, PNG */ + /*targetWidth: 300,*/ + /*targetHeight: 300,*/ + mediaType: Camera.MediaType.PICTURE, /* PICTURE, VIDEO, ALLMEDIA */ + correctOrientation: true, + /* saveToPhotoAlbum: false, */ + /* popoverOptions: (iOS only), */ + cameraDirection: Camera.Direction.BACK /* BACK, FRONT */ + }; + navigator.camera.getPicture( + function(imgData) { + if (firstrun) { + var ui = document.getElementById("camera-ui"); + ui.innerHTML = "<input name=photo id=photo type=hidden /><button onclick=\"takePhoto(false);return false\">Change Photo</button><img id=thumbnail />" + } + var input = document.getElementById("photo"); + var img = document.getElementById("thumbnail"); + img.src = "data:image/jpeg;base64,"+imgData; + input.value = imgData; + }, + function() { + alert("Error taking picture", "Error"); + }, + options); + return false; +} |