-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (71 loc) · 2.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Camera</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style type="text/css">
.cameraRoll {
width: 130px;
height: 130px;
background-size: cover;
background-position: center center;
overflow: hidden;
border-radius: 50%;
}
.fullscreen {
width: 100%;
height: 100%;
}
img {
max-width: 100%;
max-height: 100%;
}
</style>
</head>
<body>
<!--
<input type="file" accept="image/*" id="capture" capture="camera">
<script type="text/javascript">
$("#capture").change(function() {
var file = $('#capture')[0].files[0];
console.log( file );
var reader = new FileReader();
reader.readAsDataURL(file);
});
</script> -->
<!-- <section id="landing" class="fullscreen">
</section> -->
<section id="main" class="fullscreen">
<div>
<input type="file" accept="image/*" capture="camera" id="camera" style="display: none;">
<input type="button" value="Open Camera/Browse Photos" onclick="document.getElementById('camera').click();" />
</div>
<div>
<img id="frame">
</div>
<div>
<div id="cameraRoll"></div>
</div>
</section>
<script>
var camera = document.getElementById('camera');
var frame = document.getElementById('frame');
var cameraRoll = $("#cameraRoll")
camera.addEventListener('change', function(e) {
var file = e.target.files[0];
console.log('file=' + URL.createObjectURL(file));
// Do something with the image file.
frame.src = URL.createObjectURL(file);
addImageToView(file)
});
function addImageToView(file) {
var photo = $('<div><div/>');
photo.css({ 'background-image': "url('" + URL.createObjectURL(file) + "')" });
photo.addClass('cameraRoll');
cameraRoll.prepend(photo);
}
</script>
</body>
</html>