<!doctype html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <title>111{{ConfigInfo.AppTitle}}</title>
    <link href="{%public assets/css/nucleo-glyph.css%}" type="text/css" rel="stylesheet">
    <link href="{%public assets/css/nucleo-outline.css%}" type="text/css" rel="stylesheet">
    <link href="{%public assets/css/idangerous.swiper.css%}" type="text/css" rel="stylesheet">
    <link href="{%public assets/css/idangerous.swiper.scrollbar-2.4.1.css%}" type="text/css" rel="stylesheet">
      <style type="text/css">
.layui-layer-content {
color:black;
}
    </style>
    
    <!--[if lt IE 9]>
        <script src="{{PageContext.ContextPath}}public/assets2/js/html5.min.js"></script>
        <script src="{{PageContext.ContextPath}}public/assets2/js/respond.min.js"></script>
    <![endif]-->
    
    <script type="text/javascript">
		{% set cp PageContext.ContextPath %}
		var __webPath = "{{cp}}";
		var __signature = "{{PageContext.SignatureInfo}}";
	</script>
	 <script src="{{PageContext.ContextPath}}public/assets2/js/jquery.min.js"></script>
	<script  type="text/javascript" src="{{PageContext.ContextPath}}public/scripts/socket/JS/jquery-1.10.2.min.js"></script>
	<script  type="text/javascript" src="{%public assets/js/bootstrap-notify.min.js%}"></script>
	<script  type="text/javascript" src="{%public assets/js/bootstrap.min.js%}"></script>
	<script  type="text/javascript" src="{%public assets/js/idangerous.swiper.min.js%}"></script>
	<script  type="text/javascript" src="{%public assets/js/idangerous.swiper.scrollbar-2.4.1.min.js%}"></script>
	<script  type="text/javascript" src="{{PageContext.ContextPath}}public/scripts/a?t=js&m=bootstrap.min.js,jquery.plugin.js,LEx.core.js,LEx.json.js,LEx.command.js,LEx.template.js,LEx.cookie.js,LEx.control.js,LEx.util.Format.js"></script>
	 <script  type="text/javascript" src="{%public scripts/laypage/laypage.js%}"></script>  
	<script src="{{PageContext.ContextPath}}public/scripts/fineload/js/vendor/jquery.ui.widget.js"></script>
	<script src="{{PageContext.ContextPath}}public/scripts/layer/layer.js"></script>
 <script src="{{PageContext.ContextPath}}public/assets2/js/jquery.carouFredSel.packed.js"></script>

    <script type="text/javascript">
		plugin.add('dialog', {
			path: '{{cp}}public/scripts/dialog/a?t=js&m=jquery.artDialog.js,plugins/iframeTools.js',
			type: 'js',
			charset: 'utf-8',
			rely: ['dialog_css']
		});
		plugin.add('dialog_css', {
			path: '{{cp}}public/scripts/dialog/skins/default.css',
			type: 'css',
			charset: 'utf-8'
		});
		plugin.add('tree', {
			path: '{{cp}}public/scripts/zTreeStyle/jquery.ztree.js',
			type: 'js',
			charset: 'utf-8',
			rely: ['tree_css']
		});
		plugin.add('tree_css', {
			path: '{{cp}}public/scripts/zTreeStyle/zTreeStyle.css',
			type: 'css',
			charset: 'utf-8'
		});
		
		plugin.add('calendar', {
			path: '{{cp}}public/scripts/calendar/calendar-min.js',
			type: 'js',
			charset: 'utf-8',
			rely: ['calendar_css']
		});
		plugin.add('calendar_css', {
			path: '{{cp}}public/scripts/calendar/calendar-min.css',
			type: 'css',
			charset: 'utf-8'
		});
		plugin.add('editor',{path:'{{cp}}public/scripts/kindeditor/kindeditor-min.js',type:'js',charset:'utf-8'});
		plugin.add('fullCalendar',{
			path:'{{cp}}public/scripts/fullcalendar/fullcalendar.js',
			type:'js',
			charset:'utf-8',
			rely: ['jquery_ui']
		});
		
		plugin.add('jquery_ui',{
			path:'{{cp}}public/scripts/fullcalendar/jquery-ui-1.10.2.custom.min.js',
			type:'js',
			charset:'utf-8',
			rely: ['fullCalendar_css']
		});
		
		plugin.add('fullCalendar_css',{
			path:'{{cp}}public/scripts/fullcalendar/a?t=css&m=fullcalendar.css,fullcalendar.print.css',
			type:'css',
			charset:'utf-8'
		});
	</script>
   
</head>
<OBJECT ID="EloamGlobal_ID" CLASSID="CLSID:52D1E686-D8D7-4DF2-9A74-8B8F4650BF73"></OBJECT>
<script language="javascript" type="text/javascript">
	var EloamGlobal;
	var EloamDevice;
	var EloamVideo;
	var EloamRect
	
	function Load()
	{
		EloamGlobal = document.getElementById("EloamGlobal_ID");
		EloamGlobal.InitDevs();
	}

	function Unload()
	{
		CloseVideo();
		if(EloamDevice)
		{
			EloamDevice.Destroy();
			EloamDevice = null;
		}
		
		EloamGlobal.DeinitDevs();
		EloamGlobal = null;
	}

	function selectDevice()
	{		
		CloseVideo();	
		if(EloamDevice)
		{
			EloamDevice.Destroy();
			EloamDevice = null;
		}
		
		var select = document.getElementById('device'); 
		var devIdx = select.selectedIndex;
		
		document.getElementById('subtype').options.length = 0; 
		
		if(-1 != devIdx)
		{
			EloamDevice = EloamGlobal.CreateDevice(1, devIdx);
		
			var mode = document.getElementById('subtype');
			var subType = EloamDevice.GetSubtype();
			if(0 != (subType & 1))
			{
				mode.add(new Option("YUY2"));
			}
			if(0 != (subType & 2))
			{
				mode.add(new Option("MJPG"));
			}
			if(0 != (subType & 4))
			{
				mode.add(new Option("UYVY"));
			}
			
			mode.selectedIndex = 0;
		}
		
		selectSubtype();
	}
	
	function selectSubtype()
	{
		document.getElementById('resolution').options.length = 0; 
		
		var mode = document.getElementById('subtype');
		var modeIdx = mode.options.selectedIndex;
		if(-1 != modeIdx)
		{
			var modeText = mode.options[modeIdx].text;
			var subtype = (modeText == "YUY2"? 1:(modeText == "MJPG"? 2:(modeText == "UYVY"? 4:-1)));
			if((-1 != subtype) && (null != EloamDevice))
			{
				var select = document.getElementById('resolution');
				var nResolution = EloamDevice.GetResolutionCountEx(subtype);
				for(var i = 0; i < nResolution; i++)
				{
					var width = EloamDevice.GetResolutionWidthEx(subtype, i);
					var heigth = EloamDevice.GetResolutionHeightEx(subtype, i);
					select.add(new Option(width.toString() + "*" + heigth.toString())); 
				}
				select.selectedIndex = 0;
			}
		}
		selectResolution();
	}
	function selectResolution()
	{
		ShowVideo();
	}
	
	function Scan() {
	    var ss = EloamDevice.GetSonixSerialNumber();
	    //alert(ss);
		if (EloamVideo)
		{
			var date = new Date();
			var yy = date.getFullYear().toString();
			var mm = (date.getMonth() + 1).toString();
			var dd = date.getDate().toString();
			var hh = date.getHours().toString();
			var nn = date.getMinutes().toString();
			var ss = date.getSeconds().toString();
			var mi = date.getMilliseconds().toString();
			var Name = "D:\\" + yy + mm + dd + hh + nn + ss + mi + ".jpg";  
					
			var image = EloamVideo.CreateImage(0, EloamView.GetView());
			if (image)
			{
				EloamView.PlayCaptureEffect();
				image.Save(Name, 0);
				EloamThumbnail.Add(Name);
				image.Destroy();
				image = null;
			}
		}
	}
	function ShowVideo()
	{
		CloseVideo();
		if (EloamDevice)
		{
			var mode = document.getElementById('subtype');
			var modeIdx = mode.options.selectedIndex;
			if(-1 != modeIdx)
			{
				var modeText = mode.options[modeIdx].text;
				var subtype = (modeText == "YUY2"? 1:(modeText == "MJPG"? 2:(modeText == "UYVY"? 4:-1)));
			
				var select = document.getElementById('resolution'); 
				var nResolution = select.selectedIndex;
				
				EloamVideo = EloamDevice.CreateVideo(nResolution, subtype);
				
				if (EloamVideo)
				{
					EloamView.SelectVideo(EloamVideo);
					EloamView.SetText("打开视频中，请等待...", 0);
				}
			}	
		}	
	}
	
	function CloseVideo()
	{
		if (EloamVideo)
		{
			EloamView.SetText("", 0);
			EloamVideo.Destroy();
			EloamVideo = null;
		}	
	}
	
</script>

<script language="Javascript" event="DevChange(type, idx, dbt)" for="EloamGlobal_ID" type="text/JavaScript">

	if (1 == type)
	{
		if (1 == dbt)
		{
			var select = document.getElementById('device'); 
			var name = EloamGlobal.GetFriendlyName(1, idx);
			select.add(new Option(name));
			
			var type = EloamGlobal.GetEloamType(1, idx);	
			if(1 == type) //若为主摄像头，打开视频
			{
				select.selectedIndex = idx;
			}
			selectDevice();
		}
		if (2 == dbt)
		{
			if(EloamDevice)
			{
				if(idx == EloamDevice.GetIndex())
				{
					EloamView.SetText("", 0);
					if (EloamVideo)
					{
						EloamVideo.Destroy();
						EloamVideo = null;
					}
				
					EloamDevice.Destroy();
					EloamDevice = null;
				}
			}
			
			document.getElementById('device').options.remove(idx);
			selectDevice();
		}
	}
	
</script>



<BODY onload="Load()" onunload="Unload()" style="width:600px; height:420px;">

<div>
	<OBJECT ID="EloamView" CLASSID="CLSID:26BA9E7F-78E9-4FB8-A05C-A4185D80D759" style="margin-top: -80px;" WIDTH="1000" HEIGHT="700"></OBJECT>
</div>
<div>
	<OBJECT ID="EloamThumbnail" CLASSID="CLSID:B5535A1B-D25B-4B3C-854F-94B12E284A4E" WIDTH="600" HEIGHT="0"></OBJECT>
</div>

<tr>
	<td style="display: none;">
	    <select id="device" style="display: none;width: 90px" onchange="selectDevice()"></select> 
		<select id="subtype" style="display: none;width: 90px" onchange="selectSubtype()"></select> 
		<select id="resolution" style="display: none;width: 900px" onchange="selectResolution()"></select> 
		<input class="submit_01" style="display: none;" type="button" value="打开视频" onclick="ShowVideo()" />
		<input class="submit_01"  style="display: none;" type="button" value="关闭视频" onclick="CloseVideo()" />	
		<div style=" font-size: 30px;">请选择扫描文件大小	</div>
		<input class="submit_01"  style="background-color: #28a745;width: 100px;height: 50px;margin-right: 50px;" type="button" value="A3" onclick="changeScanSize('0')" /> 
		<input class="submit_01" style="background-color: #28a745;width: 100px;height: 50px;margin-right: 50px;" type="button" value="A4" onclick="changeScanSize('2')" /> 
			<!-- 	<input class="submit_01"  style="background-color: #28a745;width: 100px;height: 50px;margin-right: 50px;" type="button" value="身份证" onclick="changeScanSize()" /> 
	 -->	
		
		
		
		<!-- <input class="submit_01" type="button" value="上传" onclick="UpPhoto()" /> -->
		
	</td>
</tr>

<script>
function upphotodata(){
	/* var datastr=undefined;
	
	
	var width = EloamVideo.GetWidth();
	var heigth = EloamVideo.GetHeight();	
	
	var rect = EloamGlobal.CreateRect(width/2, heigth/2, width/2, heigth/2);
	EloamView.SetState(2);
	EloamView.SetSelectRect(rect);
	
	
	var image = EloamVideo.CreateImage(0, EloamView.GetView()); */
	//var image =  EloamGlobal.CreateImage(50, 50, LONG channels); 
	
	var datastr=undefined;
	var image = EloamVideo.CreateImage(0, EloamView.GetView());
		if (image)
		{
			var bb = image.GetBase64(2,0);
			
			 $.ajax({
 	 			type : "post",
 	 			url : LEx.webPath + "bsp/uploadifyKiosk?action=uploadPhoto",
 	 			data : { fileUrl : bb},
 	 			async : false,
 	 			success : function(data) {
 	 				datastr=data;
 	 			  }
			  });
		}
		//alert(datastr);
	return datastr;
	}
	
	
function changeScanSize(scanSize)
{
	if(EloamVideo)
	{
		
		if(0 == scanSize)//原始尺寸
		{
			EloamView.SetState(1);
		}
		else if(1 == scanSize || 2 == scanSize)
		{
			var rect;
			var width = EloamVideo.GetWidth();
			var heigth = EloamVideo.GetHeight();	
				
			if(1 == scanSize)//中等尺寸
			{
				rect = EloamGlobal.CreateRect(width/6, heigth/6, width*2/3, heigth*2/3);
			}
			if(2 == scanSize)//较小尺寸
			{
				rect = EloamGlobal.CreateRect(1200, 100, 1200, 1600);
			}
			
			EloamView.SetState(2);
			EloamView.SetSelectRect(rect);
		}
		else if(3 == scanSize)//自定义尺寸
		{
			//切换状态，清空框选区域
			EloamView.SetState(1);
			EloamView.SetState(2);
			alert("在主摄像头界面中，按住鼠标拖动即可框选尺寸!");
		}
	}
	else
	{
		alert("主摄像头视频未打开！");
	}
}
</script>
</BODY>
</HTML>
