-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (45 loc) · 1.44 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
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.6/jquery.mousewheel.min.js"></script>
<script src="js/imageBox.js"></script>
<script>
$('document').ready(function() {
$('#box').imageBox({fileInput: $('input[name=my_file]')});
var fileInput = $('input[name=my_file]');
fileInput.on('change', function(e) {
reader = new FileReader()
reader.onloadend = function() {
$('#box').imageBox('setImage', reader.result);
}
reader.readAsDataURL(this.files[0])
});
$('#box').imageBox('setImage', 'http://www.coolanimalworld.com/wp-content/uploads/2012/09/How-to-choose-a-healthy-dog-2.jpg');
$('.clear').on('click', function() {
$('#box').imageBox('clearImage');
});
$('.draw').on('click', function() {
xy = $('#box').imageBox('getXY');
console.log(xy);
});
});
</script>
<style>
#box {
height: 400px;
width: 300px;
overflow: hidden;
border: 1px solid #ccc;
}
</style>
</head>
<h1>Demo</h1>
<form>
<input type="file" name="my_file" accept="image/*" capture="camera" />
</form>
<div id="box">
</div>
<div class="clear">Clear Box</div>
<div class="draw">XY</div>
</body>
</html>