Skip to content

Commit 956599a

Browse files
committed
camera
1 parent c6a2198 commit 956599a

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

Diff for: index.html

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<body>
1010
<h1>Pigeon Logger</h1>
1111
<button class="take-photo">Take Photo</button>
12+
<img id="image"></img>
1213

1314
<script type="text/javascript" src="phonegap.js"></script>
1415
<script type="text/javascript" src="lib/app.js"></script>

Diff for: src/app.coffee

+8-15
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,15 @@ class PigeonLogger
77
# alert "deviceready"
88

99
capturePhoto: ->
10-
# capture callback
11-
captureSuccess = (mediaFiles) ->
12-
navigator.notification.alert "Total files: #{mediaFiles.length}"
13-
for i in [0...mediaFiles.length]
14-
img = document.createElement 'img'
15-
img.src = mediaFiles[i].fullPath
16-
document.body.appendChild img
10+
onSuccess = (imageData) ->
11+
image = document.getElementById("image")
12+
image.src = "data:image/jpeg;base64," + imageData
13+
onFail = (message) ->
14+
alert "Failed because: " + message
15+
navigator.camera.getPicture onSuccess, onFail,
16+
quality: 50
17+
destinationType: Camera.DestinationType.DATA_URL
1718

18-
# capture error callback
19-
captureError = (error) ->
20-
navigator.notification.alert "Error code: " + error.code, null, "Capture Error"
21-
22-
23-
# start image capture
24-
navigator.device.capture.captureImage captureSuccess, captureError,
25-
limit: 2
2619

2720

2821
window.app = new PigeonLogger()

0 commit comments

Comments
 (0)