Skip to content

Instantly share code, notes, and snippets.

@nielsdoorn
Created November 18, 2014 07:24
Show Gist options
  • Save nielsdoorn/d870af8c855a5d711c1c to your computer and use it in GitHub Desktop.
Save nielsdoorn/d870af8c855a5d711c1c to your computer and use it in GitHub Desktop.
cordova begin
body, html {
height: 100%;
}
body {
background: linear-gradient(0deg, blue, darkblue);
font-family: sans-serif;
}
h1 {
text-align: center;
}
img {
width: 100%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Foto maken</title>
</head>
<body>
<div id="app">
<h1>Foto!</h1>
<button id="maak-foto">Maken</button>
<img id="myImage">
Cool
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
document.addEventListener('deviceready', init, false);
var fotos = ['plaatje1.jpg', 'plaatje2.jpg', 'plaatje3.jpg'];
var huidigeFoto = 0;
// Het apparaat is klaar
function init() {
document.querySelector("#maak-foto").onclick = function() {
navigator.camera.getPicture(fotoGemaakt, onFail, {
quality: 80,
//sourceType:Camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: Camera.DestinationType.DATA_URL
});
}
}
function fotoGemaakt(imageData) {
var image = document.querySelector('#myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment