Ejemplo n.º 1
0
 function webcamjs($_id, $_data = '')
 {
     if (self::$webcam_init) {
         return 'ERROR: ONLY 1 WEBCAM PER FORM';
     }
     self::$webcam_init = true;
     $this->controls_js .= "\n\t\tif (typeof {$_id} === 'undefined') { \n\t\t\tWebcam.set({ width: 320, height: 240 }); Webcam.attach( '#{$_id}_cam' );\n\t\t} else { alert('ID {$_id} Already Used'); }\n\t\t";
     $_style = 'float:left;overflow:hidden;';
     //$_style = '';
     return "\n\t\t<div><img src=\"{$_data}\" width='320' height='240' alt='No Image' style='{$_style}'></div>&nbsp;\n\t\t<div id='{$_id}_cam' onClick='take_pic()' style='{$_style}'>\n\t\t\t<script language='JavaScript'>\n\t\t\t\t//Webcam.set({ width: 320, height: 240 }); Webcam.attach( '#{$_id}_cam' );\n\t\t\t\tfunction take_pic() {\n\t\t\t\t\tif (\$('#{$_id}_dat').val() == '') {\n\t\t\t\t\t\tWebcam.snap( function(data_uri) { \n\t\t\t\t\t\t\t\$('#{$_id}_dat').val( data_uri ); \n\t\t\t\t\t\t\t//\$('#{$_id}_dat').val( data_uri.replace(/^data\\:image\\/\\w+\\;base64\\,/, '') ); \n\t\t\t\t\t\t} ); Webcam.freeze();\n\t\t\t\t\t} else { Webcam.unfreeze(); \$('#{$_id}_dat').val(''); }\n\t\t\t\t}\n\t\t\t</script>\n\t\t</div>\n\t\t<input id='{$_id}_dat' name='{$_id}' type='hidden' value=''/>\n\t\t";
 }