Skip to content

Instantly share code, notes, and snippets.

@philipbreau
Last active May 9, 2017 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipbreau/7555046 to your computer and use it in GitHub Desktop.
Save philipbreau/7555046 to your computer and use it in GitHub Desktop.
BridgeIt Camera
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<script type="text/javascript" src="http://bridgeit.github.io/bridgeit.js/src/bridgeit.js"></script>
</head>
<body>
<style>
.button{
height: 80px;
margin: 10px 0;
padding: 10px;
width: 100%;
border: 1px solid #333;
background: linear-gradient(to bottom, #EEE 0%, #DDD 100%);
text-decoration: none;
color: #333;
font-size: 16px;
line-height: 60px;
font-weight: bold;
display: block;
box-sizing: border-box;
}
</style>
<script type="text/javascript">
var uploadServiceURL = 'http://api.bridgeit.mobi/echo/';
function onAfterPhotoCapture(event){
var cameraBtn = document.getElementById('cameraBtn');
if (event.preview) {
//show the thumbnail preview
var thumbnailElem = document.createElement("img");
thumbnailElem.setAttribute('src', event.preview);
thumbnailElem.style.float = 'right';
}
if (event.response) {
//show the image
var photoURL = event.response;
var imageLink = document.createElement('a');
imageLink.setAttribute('class','button');
imageLink.innerHTML = 'Click to view the photo';
imageLink.setAttribute('href', photoURL);
//set the thumbnail img as the link child
imageLink.appendChild(thumbnailElem);
//append the new link after the camera btn
cameraBtn.parentNode.appendChild(imageLink);
}
}
</script>
<button id='cameraBtn' class="button" type="button"
onclick="bridgeit.camera('cameraBtn', 'onAfterPhotoCapture', {postURL: uploadServiceURL + 'blob/'});">
Take a Photo</button>
</body>
</html>
@bbirdiman
Copy link

i get a 404 as the event.response that's placed into the photourl variable.
the preview, which comes in as data:image/jpg;base64, is accurate though.

@sutton
Copy link

sutton commented Mar 10, 2016

I get the same 404 response - any ideas on how to fix it?

@mpandey-myglobalit
Copy link

Same issue still persist. Anyone have any idea how to fix it?

@JustFine
Copy link

JustFine commented May 9, 2017

Has anyone got this working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment