Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Last active April 30, 2018 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazrdogan/ef66ce4055e555598a0c0e4afeefbd43 to your computer and use it in GitHub Desktop.
Save nazrdogan/ef66ce4055e555598a0c0e4afeefbd43 to your computer and use it in GitHub Desktop.
<script>
document.addEventListener("message", function (event) {
let parsed = JSON.parse(event.data);
if (parsed.type === "photo") {
setPhoto(parsed.params);
}
if (parsed.type === "location") {
setLocation(parsed.params);
}
});
function setPhoto(params) {
document.getElementById('img').setAttribute('src', 'data:image/png;base64,' + params.data);
}
function setLocation(params) {
var myJSON = JSON.stringify(params);
document.getElementById("demo").innerHTML = myJSON;
}
</script>
<script>
function myFunction() {
window.postMessage("takePicture");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment