<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<% request.setCharacterEncoding("UTF-8"); %>
<html>

<!-- UCBioBSPCOM Component -->
<OBJECT classid="CLSID:20E4176F-7756-4630-86AA-AB0ECD841BC3" width=0 height=0 VIEWASTEXT></OBJECT>


<!-- ----------------- --
  -- JavaScript Sample --
  -- ----------------- -->
<script lang='javascript'>

function Capture()
{	
  var err;
	var result = false;
	
	// Check ID is not NULL
	if (document.MainForm.UserID.value == "")
	{
		alert("Please enter user id!");
		return(false);
	}
	
	try // Exception handling
	{
		var objUCBioBSP = new ActiveXObject("UCBioBSPCOM.UCBioBSP.1");
		var objDevice = objUCBioBSP.Device;
		var objExtraction = objUCBioBSP.Extraction;

		// Open device. [255 = AUTO_DETECT]
		// You must open device before capture.
		objDevice.Open(255);
		err = objUCBioBSP.ErrorCode;
		if (err != 0)		// Device open failed
		{
			alert("Device open failed!");
		}
		else
		{
			// Capture user's fingerprint.
			objExtraction.Capture();
			err = objUCBioBSP.ErrorCode;
			if (err != 0)		// Capture failed
			{
				alert("Capture failed! [Error : " + err + " (" + ibjUCBioBSP.ErrorDescription + ")]");
			}
			else	// Capture success
			{
				// Get text encoded FIR data from NBioBSP module.
				document.MainForm.FIRTextData.value = objExtraction.TextFIR;
				result = true;
			}
		
			// Close device. [AUTO_DETECT]
			objDevice.Close(255);
		}
				
		objExtraction = 0;
		objDevice = 0;		
		objUCBioBSP = 0;
	}
	catch(e)
	{
		alert(e.message);
		return(false);
	}
	
	if (result)
	{
		// Submit main form
		document.MainForm.submit();
	}
	
	return (result);
}

</script>


<!-- --------------- --
  -- VBScript Sample --
  -- --------------- -->
<SCRIPT Language="VBScript"> 

const AUTO_DETECT = 255

Function Capture_VBS()

	Dim result
	Dim objUCBioBSP
	Dim objDevice, objExtraction

	result = false

	' Check ID is not NULL
	if document.MainForm.UserID.value = "" then
		MsgBox "Please enter user id!"
		Exit Function
	end if
		
	Set objUCBioBSP = CreateObject("UCBioBSPCOM.UCBioBSP.1")
	Set objDevice = objUCBioBSP.Device
	Set objExtraction = objUCBioBSP.Extraction
	
	' Open device. [AUTO_DETECT]
	' You must open device before capture.
	objDevice.Open(AUTO_DETECT)

	err = objUCBioBSP.ErrorCode	' Get error code	
	if err <> 0 then		' Device open failed
		MsgBox "Device open failed!"
	else
		' Capture user's fingerprint.
		objExtraction.Capture
		err = objUCBioBSP.ErrorCode	' Get error code
	
		if err <> 0 then		' Capture failed
			MsgBox "Capture failed! [Error : " & err & " (" & objUCBioBSP.ErrorDescription & ")]"
		else ' Capture success
			' Get text encoded FIR data from NBioBSP module.
			document.MainForm.FIRTextData.value = objExtraction.TextFIR
			result = true
		end if
	
		' Close device. [AUTO_DETECT]
		objDevice.Close(AUTO_DETECT)
	end if
	
	objExtraction = 0
	objDevice = 0
	objUCBioBSP = 0
	
	if result then
		document.MainForm.submit()
	end if
	
	capture = result

End Function

</script>



<body>

<center>
<hr>
<H2>Demo Page for Verification</H2>
<hr>

<br>
<form action='verify_ok.jsp' name='MainForm' method='post' OnSubmit='javascript:return false;'>
<input type=hidden name='FIRTextData'>

<table>
<tr><td>User ID</td>
	<td>: <input type=text name=UserID size=20> 
	<input type=button OnClick='Capture()' value=' Verify '></td></tr>
</table>

</form>

<br>
<input type=button OnClick="javascript:location.href='./default.jsp';" value=" << Return to Home ">
<br>
<p>
<hr>
<font size=2>Copyright ⓒ 2008. UNION COMMUNITY Co., Ltd.</font>
</center>

</body>
</html>