add webcam to customer create/update
This commit is contained in:
43
frontend/web/js/customer.js
Normal file
43
frontend/web/js/customer.js
Normal file
@@ -0,0 +1,43 @@
|
||||
function Customer(o){
|
||||
|
||||
var defaults = {
|
||||
'image_data' : 'customerupdate-photo_data'
|
||||
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
function init(){
|
||||
|
||||
defaults = $.extend(defaults,o);
|
||||
|
||||
Webcam.set({
|
||||
width: 160,
|
||||
height: 120,
|
||||
dest_width: 320,
|
||||
dest_height: 240,
|
||||
image_format: 'jpeg',
|
||||
jpeg_quality: 90,
|
||||
// force_flash: false,
|
||||
// flip_horiz: true,
|
||||
// fps: 45
|
||||
});
|
||||
|
||||
Webcam.attach( '#my_camera' );
|
||||
|
||||
$("#snap").click(snap);
|
||||
|
||||
}
|
||||
|
||||
function snap(){
|
||||
Webcam.snap( function(data_uri) {
|
||||
document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>';
|
||||
|
||||
var raw_image_data = data_uri.replace(/^data\:image\/\w+\;base64\,/, '');
|
||||
|
||||
document.getElementById(defaults.image_data ).value = raw_image_data;
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user