-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmfs100-9.0.2.6.js
202 lines (192 loc) · 5.7 KB
/
mfs100-9.0.2.6.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
var uri = "https://localhost:8003/mfs100/"; //Secure
//var uri = "http://localhost:8004/mfs100/"; //Non-Secure
var KeyFlag = "";
var isGetSuccess = false;
function GetMFS100Info() {
KeyFlag = "";
return GetMFS100Client("info");
}
function GetMFS100KeyInfo(key) {
KeyFlag = key;
if (!PrepareScanner())
{
return getFalseRes();
}
var MFS100Request = {
"Key": key,
};
var jsondata = JSON.stringify(MFS100Request);
return PostMFS100Client("keyinfo", jsondata);
}
function CaptureFinger(quality, timeout) {
if (!PrepareScanner()) {
return getFalseRes();
}
var MFS100Request = {
"Quality": quality,
"TimeOut": timeout
};
var jsondata = JSON.stringify(MFS100Request);
return PostMFS100Client("capture", jsondata);
}
function VerifyFinger(ProbFMR, GalleryFMR) {
if (!PrepareScanner()) {
return getFalseRes();
}
var MFS100Request = {
"ProbTemplate": ProbFMR,
"GalleryTemplate": GalleryFMR,
"BioType": "FMR" // you can paas here BioType as "ANSI" if you are using ANSI Template
};
var jsondata = JSON.stringify(MFS100Request);
return PostMFS100Client("verify", jsondata);
}
function MatchFinger(quality, timeout, GalleryFMR) {
if (!PrepareScanner()) {
return getFalseRes();
}
var MFS100Request = {
"Quality": quality,
"TimeOut": timeout,
"GalleryTemplate": GalleryFMR,
"BioType": "FMR" // you can paas here BioType as "ANSI" if you are using ANSI Template
};
var jsondata = JSON.stringify(MFS100Request);
return PostMFS100Client("match", jsondata);
}
function GetPidData(BiometricArray) {
if (!PrepareScanner()) {
return getFalseRes();
}
var req = new MFS100Request(BiometricArray);
var jsondata = JSON.stringify(req);
return PostMFS100Client("getpiddata", jsondata);
}
function GetProtoPidData(BiometricArray) {
if (!PrepareScanner()) {
return getFalseRes();
}
var req = new MFS100Request(BiometricArray);
var jsondata = JSON.stringify(req);
return PostMFS100Client("getppiddata", jsondata);
}
function GetRbdData(BiometricArray) {
if (!PrepareScanner()) {
return getFalseRes();
}
var req = new MFS100Request(BiometricArray);
var jsondata = JSON.stringify(req);
return PostMFS100Client("getrbddata", jsondata);
}
function GetProtoRbdData(BiometricArray) {
if (!PrepareScanner()) {
return getFalseRes();
}
var req = new MFS100Request(BiometricArray);
var jsondata = JSON.stringify(req);
return PostMFS100Client("getprbddata", jsondata);
}
function PostMFS100Client(method, jsonData) {
var res;
$.support.cors = true;
var httpStaus = false;
$.ajax({
type: "POST",
async: false,
crossDomain: true,
url: uri + method,
contentType: "application/json; charset=utf-8",
data: jsonData,
dataType: "json",
processData: false,
success: function (data) {
httpStaus = true;
res = { httpStaus: httpStaus, data: data };
},
error: function (jqXHR, ajaxOptions, thrownError) {
res = { httpStaus: httpStaus, err: getHttpError(jqXHR) };
},
});
return res;
}
function GetMFS100Client(method) {
var res;
$.support.cors = true;
var httpStaus = false;
$.ajax({
type: "GET",
async: false,
crossDomain: true,
url: uri + method,
contentType: "application/json; charset=utf-8",
processData: false,
success: function (data) {
httpStaus = true;
res = { httpStaus: httpStaus, data: data };
},
error: function (jqXHR, ajaxOptions, thrownError) {
res = { httpStaus: httpStaus, err: getHttpError(jqXHR) };
},
});
return res;
}
function getHttpError(jqXHR) {
var err = "Unhandled Exception";
if (jqXHR.status === 0) {
err = 'Service Unavailable';
} else if (jqXHR.status == 404) {
err = 'Requested page not found';
} else if (jqXHR.status == 500) {
err = 'Internal Server Error';
} else if (thrownError === 'parsererror') {
err = 'Requested JSON parse failed';
} else if (thrownError === 'timeout') {
err = 'Time out error';
} else if (thrownError === 'abort') {
err = 'Ajax request aborted';
} else {
err = 'Unhandled Error';
}
return err;
}
/////////// Classes
function Biometric(BioType, BiometricData, Pos, Nfiq, Na) {
this.BioType = BioType;
this.BiometricData = BiometricData;
this.Pos = Pos;
this.Nfiq = Nfiq;
this.Na = Na;
}
function MFS100Request(BiometricArray) {
this.Biometrics = BiometricArray;
}
function PrepareScanner() {
try
{
if (!isGetSuccess) {
var resInfo = GetMFS100Client("info");
if (!resInfo.httpStaus) {
//alert(resInfo.err);
return false;
}
else {
isGetSuccess = true;
}
if (KeyFlag != null && KeyFlag != 'undefined' && KeyFlag.length > 0) {
var MFS100Request = {
"Key": KeyFlag,
};
var jsondata = JSON.stringify(MFS100Request);
PostMFS100Client("keyinfo", jsondata);
}
}
}
catch(e) {}
return true;
}
function getFalseRes()
{
var res;
res = { httpStaus: false, err: "Error while calling service" };
return res;
}