summaryrefslogtreecommitdiff
path: root/www/js/report.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/report.js')
-rw-r--r--www/js/report.js41
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;
+}