forked from nsjcy/frontEnd/nsjcy

Mr Ke
2020-05-27 326bdb73c590cb669af344cfdc4ee6f02bf1b0a8
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
/**
 * ----------------------------------------------------------common start--------------------------------------------------------------
*/
//采集指纹次数
var FINGERPRINT_NUMBER = 3;
//胁迫指纹数--胁迫指纹时,在普通指纹上加的数
var DURESS_FINGER_NUM = 16;
//胁迫指纹标记
var duressFingerFlag = null;
//是否显示胁迫指纹(用户登记指纹时,不需要胁迫指纹),默认显示胁迫指纹
var duressFingerShowFlag = true;
//手指标记数组
var fingerIdArray = new Array();//[]
//指纹模板数据数组
var templateDataArray = new Array();//[]
//定时器--关闭setTimeOut时用到
var timer = null;
//定时器--验证
var verifyTimer = null;
//判断当前手指是否正在采集中
var collectFlag = false;
//当前点击的手指标记
var fpIdNum = null;
//访问ISSOnline_server的ip
var serverIp = null;
//访问的ISSOnline_server端口
var serverPort = null;
//ISSOnline_server的url的公共部分:http://127.0.0.1:22001/ZKBIOOnline
//var issOnlineUrl = null;
var issOnlineUrl = "http://127.0.0.1:22001/ZKBIOOnline";
//是否是访客
var isVisPager = false;
//定义驱动的版本号
var fpDriverVersion="5.0.0.1";
//是否为比对功能
var isComp= false;
 
/**
 * 加载xml中ISSOnline_server的ip和port
 * @author wenxin
 * @create 2013-06-15 15:01:31 pm
 * @param url 加载xml的url
 */
function loadXml(url)
{
    $.ajax( {
        type : "GET",
        url : url,
        dataType : "xml",
        async: false,
        success : function(xml) 
        {
            $(xml).find('service').each(function(){
                var service = $(this);
                serverIp = service.find('ISSOnline_serverIp').text(); 
                serverPort = service.find('ISSOnline_serverPort').text();
            })
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) 
        {
            //如果取配置文件出错,则设置默认
            serverIp = "127.0.0.1";
            serverPort = "22001";
        }
    });
    //给issOnlineUrl赋值
    issOnlineUrl = "http://"+serverIp+":"+serverPort+"/ZKBIOOnline";
}
 
/**
 * 获取编辑时,查询的数据库的指纹标记和指纹模板
 * @author wenxin
 * @create 2013-04-22 10:18:31 am
 * @param fingerIdList 数据库查询的指纹标记
 * @param templateList 数据库查询的指纹模板
 */
function loadFPDataTemplate(fingerIdList, templateList)
{
    if(fingerIdList == "[]") 
    {
        $("#fingerId").val(" ");
    } 
    else 
    {
        $("#fingerId").val(fingerIdList);
    }
    if(templateList == "[]") 
    {
        $("#fingerTemplate10").val(" ");
    } 
    else 
    {
        $("#fingerTemplate10").val(templateList);
    }
}
 
 
/**
 * 获取浏览器类型
 * @author wenxin
 * @create 2013-08-09 17:24:31 pm
 */
function getBrowserType()
{
    var browserFlag = "";
     //是否支持html5的cors跨域
    if (typeof(Worker) !== "undefined")
    {
        browserFlag = "html5";
    }
    //此处判断ie8、ie9
    else if(navigator.userAgent.indexOf("MSIE 8.0")>0 || navigator.userAgent.indexOf("MSIE 9.0")>0)
    {
        browserFlag = "simple";
    }
    else
    {
        browserFlag = "upgradeBrowser";//当前浏览器不支持该功能,请升级浏览器
    }
    return browserFlag;
}
 
/**
 * 判断是否安装指纹驱动
 * @author wenxin
 * @create 2013-04-22 20:18:31 pm
 * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 * @param paramArray 存放国际化元素的数组
 * @param isFPLogin 是否是指纹登录 true:是;false:否
 */
function checkDriver(paramArray, browserFlag, isFPLogin)
{
    var hrefStr = "";
    if(browserFlag == "html5")
    {
        // 发送一个请求,检查是否安装驱动
        getWebServerInfo(paramArray, isFPLogin, "0");
    }
    else if(browserFlag == "simple")
    {
        //发送一个请求,检查是否安装驱动
        getWebServerInfoForSimple(paramArray, isFPLogin, "0");
    }
    else if(browserFlag == "upgradeBrowser")
    {
        if($("#userLoginForm [name='fingerLogin']").val() != undefined)
        {
            $("#userLoginForm [name='fingerLogin']").attr("onclick", "");
            $("#userLoginForm [name='fingerLogin']").attr("title", "当前浏览器不支持改功能,请升级浏览器!");
        }
        if($("#fpRegister").val() != undefined)
        {
            $("#fpRegister").attr("onclick", "");
            $("#fpRegister").attr("title", "当前浏览器不支持改功能,请升级浏览器!");
        }
    }
}
 
/**
 * 获取webserver的信息
 * @author wenxin
 * @param 
 * @param paramArray 存放国际化元素的数组
 * @param isFPLogin 是否是指纹登录 true:是;false:否
 * @param type 0 表示发送完请求后,还有别的操作。1 表示发送完请求后,没有其余的操作了
 * @create 2013-08-09 17:24:31 pm
 */
function getWebServerInfo(paramArray, isFPLogin, type)
{
    $.ajax( {
        type : "GET",
        url : issOnlineUrl+"/info",
        dataType : "json",
        async: true,
        //timeout:1000,
        success : function(result) 
        {
            //检查驱动
            if(type == "0")
            {
                getWebServerInfoCallBack(result, paramArray, isFPLogin);
            }
            //检查动态库连接
            else if(type == "1")
            {
                getDLLConnectCallBack(result,isComp);
            }
            
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) 
        {
            
        }
    });
}
 
/**
 * 获取webserver的信息
 * @author wenxin
 * @param paramArray 存放国际化元素的数组
 * @param isFPLogin 是否是指纹登录 true:是;false:否
 * @param type 0 表示发送完请求后,还有别的操作。1 表示发送完请求后,没有其余的操作了
 * @create 2013-08-09 17:24:31 pm
 */
function getWebServerInfoForSimple(paramArray, isFPLogin, type)
{
    //创建XDomainRequest实例,用于ie8和ie9跨域访问
    var xDomainRequest = new XDomainRequest();
    //如果xDomainRequest存在,则可以使用xDomainRequest函数,否则,说明不是ie浏览器
    if (xDomainRequest) 
    {  
        xDomainRequest.open('GET', issOnlineUrl+"/info?random="+getRandomNum());  
        xDomainRequest.onload = function()
        {
            //检查驱动
            if(type == "0")
            {
                getInfoForSimpleCallBack(xDomainRequest, paramArray, isFPLogin);
            }
            //检查动态库连接
            else if(type == "1")
            {
                getDLLConnectCallBack(xDomainRequest,isComp);
            }
        };  
        xDomainRequest.onerror = function()
        {
            //用完后,将对象置为空
            xDomainRequest = null;
        };
        xDomainRequest.send();  
    } 
}
 
 
/**
 * 获取webserver信息的回调函数
 * @author wenxin
 * @create 2013-08-09 17:24:31 pm
 */
function getWebServerInfoCallBack(result, paramArray, isFPLogin)
{
    //返回码
    var ret = null;
    ret = result.ret;
    //接口调用成功返回时
    if(ret == 0)
    {
        if(isFPLogin)
        {
            //显示指纹登录
            showFPVerify(paramArray);
        }
        else
        {
            //显示登记--可以点击采集指纹
            showRegister(paramArray);
            //计算指纹数量${pers_person_templateCount}:指纹数
            showFPCountInit(paramArray[5], paramArray[6]);
            //鼠标over事件
            //mouseOverEvent();
            // 对比指纹驱动
            if (result.data&&result.data.server_version){
                compareFPDriver(result.data.server_version);
            }
        }
        
    }
}
 
/**
 * 显示指纹登录--点击进行指纹验证
 * @author wenxin
 * @create 2013-06-14 10:09:20 am
 * @param paramArray 存放国际化元素的数组
 */
function showFPVerify(paramArray)
{
    $("#userLoginForm .but_fing_disabled").hide();
    $("#userLoginForm .but_fing").show();
}
 
/**
 * 显示登记--点击采集指纹
 * @author wenxin
 * @create 2013-06-14 10:09:20 am
 * @param paramArray 存放国际化元素的数组
 */
function showRegister(paramArray)
{
    var hrefStr = "";
    var param = '"'+paramArray[0]+'", "'+paramArray[1]+'", "'+paramArray[2]+'", '+null+'';
    $("#fpRegister").remove();
    $("#downloadDriver").remove();
    //webservice接口调用成功,说明驱动已经安装
    hrefStr = "<a id='fpRegister' onclick='submitRegister("+param+", true"+")' title='"+paramArray[3]+"' class='linkStyle'>"+paramArray[3]+"</a>";
    $("#fpRegisterDiv").append(hrefStr);
}
 
/**
 * 在页面初始化时,计算指纹数量
 * @author wenxin
 * @create 2013-04-25 11:31:20 am
 * 
 */
function showFPCountInit(fingerIdCount, text)
{
    $("#fpCountMessage").text(text +" "+ fingerIdCount);
}
 
/**
 * 对比指纹驱动版本
 * @author gordon.zhang
 * @param oldVersion 旧驱动版本
 * @create 2015-01-28 17:24:31 pm
 */
function compareFPDriver(oldVersion)
{
    var existVersion = fpDriverVersion
    var curVersion = oldVersion;//3.5.2
    var existVersionArr = existVersion.split(".");
    var curVersionArr = curVersion.split(".");
    var isLast = true;
    var len = existVersionArr.length;
    for(var i=len;i>0;i--)
    {
        var existVersionTemp = parseInt(existVersionArr[i-1]);
        var curVersionTemp = parseInt(curVersionArr[i-1]);
        if(existVersionTemp<curVersionTemp)
        {
            isLast = false;
        }
        else if(existVersionTemp>curVersionTemp)
        {
            isLast = true;
        }
        else
        {
            //等于 忽略
        }
    }
}
/**
 * 显示发现新驱动
 * @author gordon.zhang
 * @create 2015-01-28 17:24:31 pm
 */
function showNewDriver(){
    var hrefStr = "<a id='downloadDriver' href='base/middleware/zkbioonline.exe' title='下载新驱动'>下载新驱动</a>";
    $("#driverDownload").append(hrefStr);
}
 
/**
 * 获取webserver的信息--简易版
 * @author wenxin
 * @param paramArray 存放国际化元素的数组
 * @param isFPLogin 是否是指纹登录 true:是;false:否
 * @create 2013-08-09 17:43:31 pm
 */
function getInfoForSimpleCallBack(xDomainRequest, paramArray, isFPLogin)
{
    //获取接口返回值
    var resultData = xDomainRequest.responseText;
    //转化为json对象
    var obj = jQuery.parseJSON(resultData);
    //返回码
    var ret = null;
    if(obj != null && obj.ret != undefined)
    {
        ret = obj.ret;
    }
    //接口调用成功返回时
    if(ret == 0)
    {
        if(isFPLogin)
        {
            //显示指纹比对
            showFPVerify(paramArray);
        }
        else
        {
            //显示登记--点击采集指纹
            showRegister(paramArray);
            //计算指纹数量${pers_person_templateCount}:指纹数
            
            showFPCountInit(paramArray[5], paramArray[6]);
            //鼠标over事件
            //mouseOverEvent();
        }
        //用完后,将对象置为空
        xDomainRequest = null;
    }
}
//------
/**
 * 点击登记,触发事件
 * @author wenxin
 * @create 2013-05-21 11:31:20 am
 * @param title 页面标题国际化内容
 * @param fpCount 指纹数国际化内容
 * @param saveText 提示:是否保存国际化内容
 * @param downloadText 驱动安装国际化内容
 * @param isDriverInstall 是否安装了驱动
 */
function submitRegister(title, fpCount, saveText, downloadText, isDriverInstall)
{
    //支持html5
    if (typeof(Worker) !== "undefined" && isDriverInstall)   
    {  
        var box=document.getElementById("box");
        var bg=document.getElementById("bg");
           box.style.display="block";//显示内容层,显示覆盖层
         box.style.left=parseInt((document.documentElement.scrollWidth-box.offsetWidth)/2)+document.documentElement.scrollLeft+"px";
         box.style.top=Math.abs(parseInt((document.documentElement.clientHeight-box.offsetHeight)/2))+document.documentElement.scrollTop+"px"; //为内容层设置位置
         bg.style.display="block";
         bg.style.height=document.documentElement.scrollHeight+"px"; 
         isComp=false;
         dataInitReg();
        //关闭页面时,提示保存数据
        //storeBeforeClose(fpCount, saveText);
    } 
    else if(typeof(Worker) == "undefined" && isDriverInstall)
    {  
        //createWindow('base_baseFPRegisterSimple.action?random=' + getRandomNum() + '^0^0^465^460^' + title);//public/html/applet.html
        showModalDialog('webapp/html/baseFPRegisterSimple.html',title,'dialogWidth:465px;dialogHeight:460px;dialogLeft:600px;dialogTop:150px;center:yes;resizable:no;status:yes');
        //关闭页面时,提示保存数据
        //storeBeforeClose(fpCount, saveText);
    }  
    else if(!isDriverInstall)
    {
        alert("请安装指纹驱动或启动该服务!");
        //messageBox({messageType: "alert", title: "提示", text: "请安装指纹驱动或启动该服务!"});
        if(typeof($("#downloadDriver").val()) == "undefined")
        {
            var hrefStr = "<a id='downloadDriver' href='webapp/middleware/zkbioonline.exe' title='" + downloadText + "'>"+downloadText+"</a>";
            $("#driverDownload").append(hrefStr);
        }
    }
}
 
 
/**
 * 关闭页面时,如果有修改操作,则提示用户保存数据
 * @author wenxin
 * @create 2013-06-08 19:36:20 pm
 * @param fpCount 指纹数国际化内容
 * @param saveText 提示:是否保存国际化内容
 */
function storeBeforeClose(fpCount, saveText)
{
     //关闭页面时,监听关闭的onclick事件
    getCurrentWindow().button("close").attachEvent("onClick", function(){
        //判断是否修改了数据(包括新增和删除)
        if ($("#whetherModify").val() != undefined && (fpModifyFlag != undefined && fpModifyFlag)) 
        {
            //获取指纹标记数据
            var fingerIdData = fingerIdArray;
            //获取指纹模板数据
            var fingerTemplateData = templateDataArray;
            var flag=confirm(saveText);
            saveFPData(flag, fpCount);
        }
        else
        {
            //取消采集 
            cancelRegister();
            //将定时器的递归调用关闭
            clearTimeout(timer);
            //closeWindow();
            close();
        }
    });
}
 
/**
 * 获取页面的指纹数据 
 * @author wenxin
 * @create 2013-05-13 10:18:31 am
 * @param 
 */
function getDataFromPage() 
{
    var fingerId = $("#fingerId").val();
    var fingerTemplate = $("#fingerTemplate10").val();
    //如果有数据
    if($.trim(fingerId) != "")
    {
        fingerId = fingerId.substr(1, fingerId.length-2);
        fingerTemplate = fingerTemplate.substr(1, fingerTemplate.length-2);
        fingerIdArray = fingerId.split(",");
        templateDataArray = fingerTemplate.split(",");
    }else{
        fingerIdArray=new Array();
        templateDataArray=new Array();
    }
}
 
/**
 * 初始化绘画手指、手掌、圆弧的起始坐标,并做成json格式
 * @author wenxin
 * @create 2013-06-15 15:40:31 pm
 */
function initCoordJson()
{
    var coordJson = [{"num" : 0, "coord" : {"x" : x + 3, "y" : y - 37}},
                     {"num" : 1, "coord" : {"x" : x + 25, "y" : y - 37}},
                     {"num" : 2, "coord" : {"x" : x + 47, "y" : y - 34}},
                     {"num" : 3, "coord" : {"x" : x + 67, "y" : y - 26}},
                     {"num" : 4, "coord" : {"x" : x + 77, "y" : y + 18}},
                     {"num" : 5, "coord" : {"x" : x + 153, "y" : y + 34}},
                     {"num" : 6, "coord" : {"x" : x + 159, "y" : y - 19}},
                     {"num" : 7, "coord" : {"x" : x + 177, "y" : y - 30}},
                     {"num" : 8, "coord" : {"x" : x + 198, "y" : y - 36}},
                     {"num" : 9, "coord" : {"x" : x + 220, "y" : y - 36}},
                     {"num" : 10, "coord" : {"x" : x, "y" : y}},
                     {"num" : 11, "coord" : {"x" : x + 170, "y" : y + 12}},
                     {"num" : 12, "coord" : {"x" : x + 210, "y" : y - 346}}];
    return coordJson;
}
 
/**
 * 将绘画的坐标点放入数组
 * @author wenxin
 * @create 2013-05-31 18:01:33 pm
 * @param coordArray 传入的数组,放入坐标后,返回
 * @param x, y 绘画手指的起点的坐标
 * @param num 手指、手掌编号0-9:手指编号;10:左手掌,11:右手掌,12:圆弧。
 */
function initCoordArray(coordArray, x, y, num)
{
    if(num == 0)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 2, y - 35);
        coordArray[2] = new Coord(x + 5, y - 40);
        coordArray[3] = new Coord(x + 11, y - 42);
        coordArray[4] = new Coord(x + 16, y - 40);
        coordArray[5] = new Coord(x + 18, y - 35);
        coordArray[6] = new Coord(x + 18, y + 1);
        coordArray[7] = new Coord(x + 15, y + 5);
        coordArray[8] = new Coord(x + 9, y + 7);
        coordArray[9] = new Coord(x + 3, y + 5);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 1)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 8, y - 50);
        coordArray[2] = new Coord(x + 12, y - 54);
        coordArray[3] = new Coord(x + 19, y - 55);
        coordArray[4] = new Coord(x + 22, y - 53);
        coordArray[5] = new Coord(x + 24, y - 49);
        coordArray[6] = new Coord(x + 18, y + 1);
        coordArray[7] = new Coord(x + 15, y + 6);
        coordArray[8] = new Coord(x + 8, y + 7);
        coordArray[9] = new Coord(x + 3, y + 4);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 2)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 14, y - 54);
        coordArray[2] = new Coord(x + 16, y - 57);
        coordArray[3] = new Coord(x + 23, y - 58);
        coordArray[4] = new Coord(x + 28, y - 55);
        coordArray[5] = new Coord(x + 29, y - 50);
        coordArray[6] = new Coord(x + 17, y + 4);
        coordArray[7] = new Coord(x + 13, y + 8);
        coordArray[8] = new Coord(x + 6, y + 9);
        coordArray[9] = new Coord(x + 1, y + 5);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 3)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 19, y - 37);
        coordArray[2] = new Coord(x + 21, y - 39);
        coordArray[3] = new Coord(x + 28, y - 39);
        coordArray[4] = new Coord(x + 32, y - 36);
        coordArray[5] = new Coord(x + 33, y - 31);
        coordArray[6] = new Coord(x + 17, y + 6);
        coordArray[7] = new Coord(x + 12, y + 10);
        coordArray[8] = new Coord(x + 6, y + 10);
        coordArray[9] = new Coord(x + 1, y + 6);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 4){
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 30, y - 18);
        coordArray[2] = new Coord(x + 34, y - 17);
        coordArray[3] = new Coord(x + 37, y - 14);
        coordArray[4] = new Coord(x + 39, y - 11);
        coordArray[5] = new Coord(x + 39, y - 8);
        coordArray[6] = new Coord(x + 38, y - 6);
        coordArray[7] = new Coord(x + 12, y + 15);
        coordArray[8] = new Coord(x + 8, y + 17);
        coordArray[9] = new Coord(x + 2, y + 14);
        coordArray[10] = new Coord(x - 2, y + 8);
        coordArray[11] = new Coord(x, y);
    }
    else if(num == 5)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x - 26, y - 21);
        coordArray[2] = new Coord(x - 27, y - 24);
        coordArray[3] = new Coord(x - 26, y - 30);
        coordArray[4] = new Coord(x - 21, y - 34);
        coordArray[5] = new Coord(x - 16, y - 34);
        coordArray[6] = new Coord(x + 12, y - 18);
        coordArray[7] = new Coord(x + 15, y - 10);
        coordArray[8] = new Coord(x + 13, y - 3);
        coordArray[9] = new Coord(x + 7, y + 1);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 6)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x - 17, y - 46);
        coordArray[2] = new Coord(x - 17, y - 50);
        coordArray[3] = new Coord(x - 13, y - 56);
        coordArray[4] = new Coord(x - 6, y - 56);
        coordArray[5] = new Coord(x - 3, y - 54);
        coordArray[6] = new Coord(x + 15, y - 11);
        coordArray[7] = new Coord(x + 15, y - 4);
        coordArray[8] = new Coord(x + 11, y + 2);
        coordArray[9] = new Coord(x + 4, y + 2);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 7)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x - 12, y - 54);
        coordArray[2] = new Coord(x - 10, y - 58);
        coordArray[3] = new Coord(x - 5, y - 62);
        coordArray[4] = new Coord(x + 1, y - 61);
        coordArray[5] = new Coord(x + 4, y - 58);
        coordArray[6] = new Coord(x + 18, y - 4);
        coordArray[7] = new Coord(x + 16, y + 1);
        coordArray[8] = new Coord(x + 11, y + 5);
        coordArray[9] = new Coord(x + 5, y + 4);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 8)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x - 5, y - 50);
        coordArray[2] = new Coord(x - 2, y - 54);
        coordArray[3] = new Coord(x + 3, y - 57);
        coordArray[4] = new Coord(x + 9, y - 55);
        coordArray[5] = new Coord(x + 11, y - 52);
        coordArray[6] = new Coord(x + 18, y - 1);
        coordArray[7] = new Coord(x + 14, y + 4);
        coordArray[8] = new Coord(x + 9, y + 6);
        coordArray[9] = new Coord(x + 4, y + 5);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 9)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x, y - 37);
        coordArray[2] = new Coord(x + 3, y - 41);
        coordArray[3] = new Coord(x + 7, y - 43);
        coordArray[4] = new Coord(x + 13, y - 41);
        coordArray[5] = new Coord(x + 15, y - 37);
        coordArray[6] = new Coord(x + 17, y + 1);
        coordArray[7] = new Coord(x + 15, y + 3);
        coordArray[8] = new Coord(x + 10, y + 6);
        coordArray[9] = new Coord(x + 3, y + 4);
        coordArray[10] = new Coord(x, y);
    }
    else if(num == 10)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x + 2, y - 8);
        coordArray[2] = new Coord(x + 6, y - 16);
        coordArray[3] = new Coord(x + 13, y - 23);
        coordArray[4] = new Coord(x + 27, y - 27);
        coordArray[5] = new Coord(x + 37, y - 25);
        coordArray[6] = new Coord(x + 43, y - 23);
        coordArray[7] = new Coord(x + 64, y - 16);
        coordArray[8] = new Coord(x + 69, y - 11);
        coordArray[9] = new Coord(x + 73, y - 3);
        
        coordArray[10] = new Coord(x + 73, y + 10);
        coordArray[11] = new Coord(x + 71, y + 18);
        coordArray[12] = new Coord(x + 57, y + 40);
        coordArray[13] = new Coord(x + 50, y + 46);
        coordArray[14] = new Coord(x + 41, y + 49);
        coordArray[15] = new Coord(x + 34, y + 49);
        coordArray[16] = new Coord(x + 14, y + 43);
        coordArray[17] = new Coord(x + 10, y + 41);
        coordArray[18] = new Coord(x + 6, y + 36);
        coordArray[19] = new Coord(x + 2, y + 29);
        coordArray[20] = new Coord(x, y);
    }
    else if(num == 11)
    {
        coordArray[0] = new Coord(x, y);
        coordArray[1] = new Coord(x - 2, y - 10);
        coordArray[2] = new Coord(x + 1, y - 20);
        coordArray[3] = new Coord(x + 14, y - 31);
        coordArray[4] = new Coord(x + 47, y - 39);
        coordArray[5] = new Coord(x + 55, y - 38);
        coordArray[6] = new Coord(x + 61, y - 34);
        coordArray[7] = new Coord(x + 68, y - 26);
        coordArray[8] = new Coord(x + 72, y - 16);
        coordArray[9] = new Coord(x + 72, y + 13);
        
        coordArray[10] = new Coord(x + 68, y + 22);
        coordArray[11] = new Coord(x + 62, y + 29);
        coordArray[12] = new Coord(x + 60, y + 30);
        coordArray[13] = new Coord(x + 39, y + 36);
        coordArray[14] = new Coord(x + 34, y + 36);
        coordArray[15] = new Coord(x + 20, y + 33);
        coordArray[16] = new Coord(x + 16, y + 29);
        coordArray[17] = new Coord(x, y);
    }
    else if(num == 12)
    {
        coordArray[0] = new Coord(x - 10, y);
        coordArray[1] = new Coord(x + 212, y);
        coordArray[2] = new Coord(x + 212, y + 129);
        coordArray[3] = new Coord(x + 201, y + 130);
        coordArray[4] = new Coord(x + 191, y + 131);
        coordArray[5] = new Coord(x + 174, y + 131);
        coordArray[6] = new Coord(x + 159, y + 129);
        coordArray[7] = new Coord(x + 142, y + 127);
        coordArray[8] = new Coord(x + 133, y + 125);
        coordArray[9] = new Coord(x + 114, y + 120);
        
        coordArray[10] = new Coord(x + 97, y + 113);
        coordArray[11] = new Coord(x + 86, y + 108);
        coordArray[12] = new Coord(x + 72, y + 100);
        coordArray[13] = new Coord(x + 52, y + 87);
        coordArray[14] = new Coord(x + 40, y + 76);
        coordArray[15] = new Coord(x + 29, y + 64);
        coordArray[16] = new Coord(x + 16, y + 48);
        coordArray[17] = new Coord(x + 5, y + 30);
        coordArray[18] = new Coord(x - 10, y);
    }
    return coordArray;
}
 
/**
 * 坐标点对象
 * @author wenxin
 * @create 2013-05-31 18:01:33 pm
 */
var Coord = function(x, y)
{
    this.x = x;
    this.y = y;
}
 
/**
 * 绘画手指
 * @author wenxin
 * @create 2013-05-31 18:01:33 pm
 * @param context 2d画布上下文
 * @param pointArray 坐标点数组
 * @param renderFlag 渲染标记 stroke:绘画边线;fill:填充
 * @param color 渲染颜色
 */
var renderFinger = function(context, pointArray) 
{
    this.context = context;
    this.pointArray = pointArray;
    this.isClick = false;
    this.drawFinger = function(renderFlag, color) 
    {
        if(renderFlag == "stroke")
        {
            this.context.strokeStyle = color;
        }
        else if(renderFlag == "fill")
        {
            this.context.fillStyle = color;
        }
        this.context.lineWidth = 1;
        this.context.beginPath();
        for(var i=0; i<this.pointArray.length; i++)
        {
            if(i == 0)
            {
                this.context.moveTo(this.pointArray[0].x, this.pointArray[0].y);
            }
            else
            {
                this.context.lineTo(this.pointArray[i].x, this.pointArray[i].y);
            }
        }
        if(renderFlag == "stroke")
        {
            this.context.stroke();
        }
        else if(renderFlag == "fill")
        {
            this.context.fill();
        }
    };
};
 
/**
 * 页面加载和重画时渲染手指
 * @author wenxin
 * @create 2013-05-13 15:26:31 pm
 * @param context 2d画布上下文
 * @param num 当前需要渲染的手指编号
 * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 */
function renderInit(context, num, browserFlag)
{
    var fingerId;
    for(var i=0; i<fingerIdArray.length; i++)
    {
        fingerId = eval(fingerIdArray[i]);
        if(fingerId >= DURESS_FINGER_NUM)
        {
            fingerId = fingerId -DURESS_FINGER_NUM;
            if(browserFlag == "html5")
            {
                if(fingerId == num)
                {
                    context.fillStyle = "red";
                    context.fill();
                }
            }
        }
        else
        {
            if(browserFlag == "html5"){
                if(fingerId == num)
                {
                    context.fillStyle = "rgb(122,193,66)";
                    context.fill();
                }
            }
        }
        if(browserFlag == "simple")
        {
            document.getElementById("finger" + fingerId).checked = true;
        }
    }
}
 
/**
 * 显示指纹图像
 * @author wenxin
 * @create 2013-05-18 11:22:31 am
 * @param context 2d画布上下文
 * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 */
function showImage(context, base64FPImg, browserFlag)
{
    var img;
    var imgSrc = "data:image/jpg;base64,"+base64FPImg;
    if(browserFlag == "html5"){
        img = new Image();
        //img.src = sysCfg.rootPath + "/public/html/bmpFile1.jpg";
        img.src = "";
        img.src = imgSrc;
        img.onload=function() {
            // 保存当前的绘图状态
            context.save();
            // 开始创建路径
            context.beginPath();
            // 画一个椭圆
            context.oval(125, 142, 112, 145);
            // 关闭路径
            context.closePath();
            // 剪切路径
            context.clip();
            //将图片画到画布上
            context.drawImage(img, 70, 70, 112, 145);
            //调用restore最后一次存储的状态会被恢复
            context.restore();
        }
    }
    else if(browserFlag == "verification")
    {
        img = new Image();
        img.src = "";
        img.src = imgSrc;
        img.onload=function() {
            // 保存当前的绘图状态
            context.save();
            // 开始创建路径
            context.beginPath();
            // 画一个椭圆
            context.oval(92, 159, 100, 128);
            // 关闭路径
            context.closePath();
            // 剪切路径
            context.clip();
            //将图片画到画布上
            context.drawImage(img, 37, 90, 112, 145);
            //调用restore最后一次存储的状态会被恢复
            context.restore();
        }
    }
    else if(browserFlag == "clearForVerify" || browserFlag == "clearForRegister")
    {
        img = new Image();
        img.src = "";
        img.src = base64FPImg;
        img.onload=function() {
            // 保存当前的绘图状态
            context.save();
            // 开始创建路径
            context.beginPath();
            // 画一个椭圆
            if(browserFlag == "clearForVerify")
            {
                context.oval(91, 160, 112, 145);
            }
            else if(browserFlag == "clearForRegister")
            {
                context.oval(125, 142, 132, 165);
            }
            // 关闭路径
            context.closePath();
            // 剪切路径
            context.clip();
            //将图片画到画布上
            if(browserFlag == "clearForVerify")
            {
                context.drawImage(img, 12, 54, 160, 213);
            }
            else if(browserFlag == "clearForRegister")
            {
                context.drawImage(img, 60, 60, 132, 165);
            }
            //调用restore最后一次存储的状态会被恢复
            context.restore();
        }
    }
    else if(browserFlag == "simple")
    {
        $("#showFPImageDiv").html("<img src="+imgSrc+" width='112' height='145' />");
    }
    else if(browserFlag == "verifySimple")
    {
        $("#showSeachingDiv").show();
        $("#showSeachingDiv").html("&nbsp;&nbsp;<img src=\"/public/images/searching.gif\" width='20' height='20'/></br><label style='color:yellow;align:center;font-size: 14px;'>处理中...</label>");
    }
    else if(browserFlag == "clearForSimple")
    {
        $("#showFPImageDiv").html("");
    }
}
 
/**
 * 绘画手掌
 * @author wenxin
 * @create 2013-06-01 09:01:33 am
 * @param context 2d画布上下文
 * @param pointArray 坐标点数组
 * @param color 渲染颜色
 */
var renderHand = function(context, pointArray) 
{
    this.context = context;
    this.pointArray = pointArray;
    this.isClick = false;
    this.drawHand = function(color) 
    {
        this.context.strokeStyle = color;
        this.context.lineWidth = 1;
        this.context.beginPath();
        for(var i=0; i<this.pointArray.length; i++)
        {
            if(i == 0)
            {
                this.context.moveTo(this.pointArray[0].x, this.pointArray[0].y);
            }
            else
            {
                this.context.lineTo(this.pointArray[i].x, this.pointArray[i].y);
            }
        }
        this.context.stroke();
    };
};
 
/**
 * 检查指纹采集器
 * @author wenxin
 * @create 2013-06-17 20:18:31 pm
 * @param context 2d画布上下文
 * @param paramArray 存放国际化元素的数组
 * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 */
function checkFPReader(context, paramArray, browserFlag)
{
    if(browserFlag == "html5")
    {
        $.ajax( {
            type : "GET",
            url : issOnlineUrl+"/fingerprint/beginCapture?type=1&FakeFunOn=0&random="+getRandomNum(),
            dataType : "json",
            async: false,
            //timeout:1000,
            success : function(result) 
            {
                //返回码
                var ret = null;
                ret = result.ret;
                //接口调用成功返回时
                if(ret == 0)
                {
                    //显示框--采集提示
                    collectTips(context, paramArray[0], "html5");
                }
                else if(ret == -2001)
                {
                    //显示框--采集提示
                    collectTips(context, paramArray[1], "html5");
                }
                else if(ret == -2002)
                {
                    getWebServerInfo(null, null, "1");
                }
                else if(ret == -2005)
                {
                    //显示框--采集提示
                    collectTips(context, paramArray[3], "html5");
                }
                collectFlag = true;
                //取消采集
                cancelRegister();
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) 
            {
                alert("请安装指纹驱动或启动该服务!");
                //messageBox({messageType: "alert", title: "${common_prompt_title}", text: "${base_fp_connectPrompt}"});
            }
        });
    }
    else if(browserFlag == "simple")
    {
        //创建XDomainRequest实例,用于ie8和ie9跨域访问
        var xDomainRequest = new XDomainRequest();
        //如果xDomainRequest存在,则可以使用xDomainRequest函数,否则,说明不是ie浏览器
        if (xDomainRequest) 
        {  
            xDomainRequest.open('GET', issOnlineUrl+"/fingerprint/beginCapture?type=1&FakeFunOn=0&random="+getRandomNum());  
            xDomainRequest.onload = function()
            {
                //获取接口返回值
                var resultData = xDomainRequest.responseText;
                //转化为json对象
                var obj = jQuery.parseJSON(resultData);
                //返回码
                var ret = null;
                if(obj != null && obj.ret != undefined)
                {
                    ret = obj.ret;
                }
                //接口调用成功返回时
                if(ret == 0)
                {
                    //显示框--采集提示
                    collectTips(null, paramArray[0], "simple");
                }
                else if(ret == -2001)
                {
                    //显示框--采集提示
                    collectTips(null, paramArray[1], "simple");
                }
                else if(ret == -2002)
                {
                    getWebServerInfoForSimple(null, null, "1");
                }
                collectFlag = true;
                //取消采集
                cancelRegister();
            };  
            xDomainRequest.onerror = function()
            {
                //用完后,将对象置为空
                xDomainRequest = null;
            };
            xDomainRequest.send(); 
        } 
    }
}
 
/**
 * 显示框--显示采集次数、采集成功、失败等信息
 * @author wenxin
 * @create 2013-05-16 16:56:31 pm
 * @param context 2d画布上下文
 * @param text  显示信息内容
 * @param browserFlag 浏览器标记或比对验证标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 * --verification:指纹验证标记
 */
function collectTips(context, text, browserFlag)
{
    if(browserFlag == "simple")
    {
        $("#showCollInfoDiv").html("<span style='color:rgb(122,193,66); font-size: 12px;word-break: break-all; word-wrap: break-word;'>"+text+"</span>");
    }
    else if(browserFlag == "html5")
    {
        context.fillStyle = bgColor;//bgColor;
        context.fillRect(205, 18, 240, 16);
        
        //文字右对齐
        context.fillStyle = "rgb(122,193,66)";
        context.font ="12px Arial,微软雅黑"; 
        //context.shadowColor = 'white'; 
        //context.shadowBlur = 10; 
        //context.strokeText(text, 230, 30);
        context.textAlign = "end";
        context.fillText(text, 400, 30);
    }
    else if(browserFlag == "verification")
    {
        //#6BA5D7
        context.fillStyle = "#F3F5F0";//#6BA5D7
        context.fillRect(2, 8, 600, 30);
        //获取canvas对象
        var canvas ="";
        if(isComp){
            canvas = document.getElementById("canvasComp");
        }else{
            canvas = document.getElementById("canvas");
        }
//        canvas.width = canvas.width;
        //返回一个文本的度量信息对象metrics
        var metrics = context.measureText(text);
        //文本宽度
        var textWidth = metrics.width;
        //canvas宽度
        canvas != null?canvasWidth = canvas.width:canvasWidth = 450;
        //文本开始x坐标
        var x = textWidth/2 + (canvasWidth - textWidth)/2;
        
        
        //context.fillStyle = bgColor;
        //context.fillRect(0, 18, 445, 16);
        
        //文字右对齐
        context.fillStyle = "rgb(122,193,66)";
        context.font ="24px Arial,微软雅黑"; 
        context.textAlign = "center";
        //自动换行
        autoWordBreak(context,text,canvasWidth,x);
        context.restore();
    }
    else if(browserFlag == "verifyForSimple")
    {
        $("#showCollInfoDiv").html("<span style='color:yellow;align:center;font-size: 18px;word-break: break-all; word-wrap: break-word;'>"+text+"</span>");
    }
}
 
/**
 * 画进度条
 * @author wenxin
 * @create 2013-05-16 16:56:31 pm
 * @param context 2d画布上下文
 * @param x,y,width,height 进度条底框的坐标和宽度、高度
 */
function drawProgressBar(context, collCount)
{
    var x = 300;
    var y = 60;
    var width = 90;
    var height = 20;
    context.fillStyle = bgColor;
    context.fillRect(x, y, width, height);
    if(collCount == 0)
    {
        context.fillStyle = "rgb(175,181,185)";
        context.fillRect(x + 4, y + 2, width - 52, height - 4);
        context.fillRect(x + 46, y + 2, width -52, height - 4);
        context.fillRect(x + 86, y + 2, width - 52, height - 4);
    }
    else if(collCount == 1)
    {
        context.fillStyle = "rgb(122,193,66)";
        context.fillRect(x + 4, y + 2, width - 52, height - 4);
        context.fillStyle = "rgb(175,181,185)";
        context.fillRect(x + 46, y + 2, width - 52, height - 4);
        context.fillRect(x + 86, y + 2, width - 52, height - 4);
    }
    else if(collCount == 2)
    {
        context.fillStyle = "rgb(122,193,66)";
        context.fillRect(x + 4, y + 2, width - 52, height - 4);
        context.fillRect(x + 46, y + 2, width - 52, height - 4);
        context.fillStyle = "rgb(175,181,185)";
        context.fillRect(x + 86, y + 2, width - 52, height - 4);
    }
    else if(collCount == 3)
    {
        context.fillStyle = "rgb(122,193,66)";
        context.fillRect(x + 4, y + 2, width - 52, height - 4);
        context.fillRect(x + 46, y + 2, width - 52, height - 4);
        context.fillRect(x + 86, y + 2, width - 52, height - 4);
    }
}
 
/**
 * 判断当前手指是否在fingerIdArray中,如果在,则说明此手指已经采集指纹
 * @author wenxin
 * @create 2013-05-15 16:26:31 pm
 * @param num 手指编号
 * @param fingerIdArray 存放手指编号的数组
 * @return 返回boolean值 true:num包含在fingerIdArray中;false:没有包含
 */
function isContains(fingerIdArray, num)
{
    var fingerId;
    var isCollected = false;
    for(var j=0; j<fingerIdArray.length; j++)
    {
        fingerId = eval(fingerIdArray[j]);
        if(fingerId >= DURESS_FINGER_NUM)
        {
            fingerId = fingerId -DURESS_FINGER_NUM;
        }
        if(fingerId == num)
        {
            isCollected = true;
        }
    }
    return isCollected;
}
 
/**
 * 清空指纹图像
 * @author wenxin
 * @create 2013-09-05 15:15:11 pm
 */
function clearFPImage(context, browserFlag)
{
    if(browserFlag == "verification")
    {
//        showImage(context, "${base}/base/images/base_fpVerify_clearImage.png", "clearForVerify");
    }
    else if(browserFlag == "register")
    {
        showImage(context, "image/base_fpVerify_clearImage.png", "clearForRegister");
    }
    else if(browserFlag == "verifyForSimple" || browserFlag == "registerForSimple")
    {
        showImage(null, "", "clearForSimple");
    }
}
 
/**
 * 获取指纹模板
 * @author wenxin
 * @create 2013-05-22 19:51:31 pm
 * @param paramArray 存放国际化元素的数组
 * @param flag 判断是登记和验证标记 register:登记;verification:验证
 */
function getFPTemplate(paramArray, flag)
{
    var fpTemplate = "";
    var collectSuccessFlag = false;
    $.ajax( {
        type : "GET",
        url : issOnlineUrl+"/fingerprint/getTemplate?random="+getRandomNum(),
        dataType : "json",
        async: false,
        success : function(result) 
        {
            //返回码
            var ret = null;
            ret = result.ret;
            if(ret == 0)
            {
                fpTemplate = result.data.template;
            }
            //成功
            if(ret == 0)
            {
                collectSuccessFlag = true;
                if(flag == "register")
                {
                    //判断手指是否已经采集指纹
                    var compareRet = "";
                    //如果前面已经录入指纹
                    if(templateDataArray.length > 0)
                    {
                        //发送请求,进行后台指纹比对yls
                        //compareRet = fpComparision(fpTemplate, templateDataArray, paramArray[3]);
                    }
                    if($.trim(compareRet) == "dllNotExist")
                    {
                        //采集完指纹,渲染手指
                        renderAfterColl(globalContext, fpIdNum, bgColor, false);//bgColor判断
                        //显示框--采集提示
                        collectTips(globalContext, "动态库加载失败", "html5");
                    }
                    else
                    {
                        if(compareRet == "noFingerServer")
                        {
                            //采集完指纹,渲染手指
                            renderAfterColl(globalContext, fpIdNum, bgColor, false);//bgColor判断
                            //显示框--采集提示
                            collectTips(globalContext, "未启动比对服务", "html5");
                        }
                        else
                        {
                            //此手指未采集指纹
                            if(compareRet != "ok")
                            {
                                //采集完指纹,渲染手指
                                renderAfterColl(globalContext, fpIdNum, bgColor, true);//bgColor判断
                                //显示框--采集提示
                                collectTips(globalContext, paramArray[0], "html5");
                                //胁迫指纹
                                if(duressFingerFlag)
                                {
                                    //将手指标记保存到数组中
                                    fingerIdArray[fingerIdArray.length] = fpIdNum + DURESS_FINGER_NUM;
                                }
                                else
                                {
                                    //将手指标记保存到数组中
                                    fingerIdArray[fingerIdArray.length] = fpIdNum;
                                }
                                //将指纹模板保存到数组中
                                templateDataArray[templateDataArray.length] = fpTemplate;
                            }
                            else
                            {
                                //采集完指纹,渲染手指
                                renderAfterColl(globalContext, fpIdNum, bgColor, false);//bgColor判断
                                //Please don't repeat input fingerprint!
                                //显示框--采集提示
                                collectTips(globalContext, paramArray[2], "html5");
                            }
                        }
                    }
                }
                else if(flag == "verification")
                {
                    verifyFlag = false;
                    //指纹比对
                    fpComparison(fpTemplate);
                }
            }
            else if(ret == -2003)
            {
                //采集完指纹,渲染手指
                renderAfterColl(globalContext, fpIdNum, bgColor, false);
                //显示框--采集提示
                collectTips(globalContext, paramArray[1], "html5");
            }
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) 
        {
            alert(paramArray[3]);
            //messageBox({messageType: "alert", title: "${common_prompt_title}", text: paramArray[3]});
        }
    });
    return collectSuccessFlag;
}
 
/**
 * 发送请求到后台,进行比对
 * @author wenxin
 * @create 2013-08-05 16:20:31 pm
 * @param fpTemplate 指纹模板
 * @param templateArray 指纹模板数组
 * @param errorMsg ajax请求报错,错误信息
 */
function fpComparision(fpTemplate, templateArray, errorMsg)
{
    var ret = "";
    var templates = templateArray.toString();
    //特殊字符转义
    fpTemplate = transferredMeaning(fpTemplate);
    templates = transferredMeaning(templates);
    $.ajax( {
        type : "POST",
        url : "baseBioVerifyAction!fpComparison.action",
        contentType : "application/x-www-form-urlencoded;charset=UTF-8",
        data : "verifyTemplate="+fpTemplate+"&templates="+templates,
        dataType : "json",
        async: false,
        success : function(result) 
        {
            if(result.ret == "ok")
            {
                ret = "ok";
            }
            if(result.msg == "noFingerServer")
            {
                ret = "noFingerServer";
            }
            if(result.msg == "dllNotExist")
            {
                ret = "dllNotExist";
            }
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) 
        {
            alert("服务器处理数据失败,请重试!错误码:");
            //messageBox({messageType: "alert", title: "${common_prompt_title}", text: "${common_prompt_serverError}"});
        }
    });
    return ret;
}
 
/**
 * 采集完指纹后渲染手指
 * @author wenxin
 * @create 2013-05-18 11:33:31 am
 * @param context 2d画布上下文
 * @param num 当前需要渲染的手指编号
 * @param fillColor 采集完后填充颜色
 * @param successOrNot 采集是否成功--布尔值 true:采集成功;false:采集失败
 */
function renderAfterColl(context, num, fillColor, successOrNot)
{
    var canvas="";
    if(isComp){
        canvas = document.getElementById("canvasComp");
    }else{
        canvas = document.getElementById("canvas");
    }
    var localContext = canvas.getContext("2d");
    var coordArray = new Array();
    //初始化起始坐标,并返回json格式数据 
    var coordJson = initCoordJson();
    //进来页面,点击删除
    if(num == null)
    {
        num = fpIdNum;
    }
    //点击的手指编号和json中num相等
    if(coordJson[num].num == num)
    {
        //初始化坐标数组和绘画手指
        initCoordAndDrawFinger(context, coordArray, coordJson[num].coord.x, coordJson[num].coord.y, num);
    }
    
    //采集成功,填充颜色(红、绿)
    if(successOrNot)
    {
        if(duressFingerFlag)
        {
            localContext.fillStyle = "red";//fillColor
            localContext.fill();
            fpModifyFlag = true;
        }
        else
        {
            localContext.fillStyle = "rgb(122,193,66)";//fillColor
            localContext.fill();
            fpModifyFlag = true;
        }
    }
    else
    {
        //采集失败,填充背景色--消除颜色(黄)
        localContext.fillStyle = fillColor;
        localContext.fill();
    }
}
 
/**
 * 初始化坐标数组和绘画手指--获取当前的context
 * @author wenxin
 * @create 2013-05-31 18:01:33 pm
 * @param context 2d画布上下文
 * @param pointArray 坐标点数组
 * @param x,y 绘画当前手指的起始坐标
 * @param num 手指标记
 */
function initCoordAndDrawFinger(context, coordArray, x, y, num)
{
    coordArray = initCoordArray(coordArray, x, y, num);
    new renderFinger(context, coordArray).drawFinger(strokeStyle, fingerBorderColor);
}
 
/**
 * 点击取消按钮时,触发事件
 * @author wenxin
 * @create 2013-05-15 17:21:13 pm
 * @param "${base_fp_save}":确认保存当前修改吗?
 */
function cancelEvent(saveText, fpCountText)
{
    if(!fpModifyFlag)
    {
        if(collectFlag)
        {
            //取消采集
            cancelRegister();
            //将定时器的递归调用关闭
            clearTimeout(timer);
        }
        //closeWindow();
        close();
    }
    else
    {
        var flag=confirm(saveText);
        if(flag){
            saveFPData(flag, fpCountText);
        }else{
            close();
        }
        
    }
    
}
 
/**
 * 点击取消按钮和关闭页面时,弹出框保存数据
 * cancelEvent()和submitRegister()函数中回调用到
 * @author wenxin
 * @create 2013-05-14 15:11:31 pm
 * @param result 弹出框选择确定还是取消 
 * @param fpCount 指纹数国际化内容
 * @param ${pers_person_templateCount}:指纹数
 */
var saveFPData = function(result, fpCount)
{
    if(collectFlag)
    {
        //取消采集
        cancelRegister();
        //将定时器的递归调用关闭
        clearTimeout(timer);
    }
    if(result)
    {
        storeDataToHtml();
        showFPCount(fpCount);
        //closeWindow();
        close();
    }
    else
    {
        clearImageData();
        //closeWindow();
        close();
    }
}
 
/**
 * 判断指纹数量--页面加载时,没有计算。只是在采集完指纹后计算指纹数量
 * @author wenxin
 * @create 2013-04-22 21:26:31 pm
 */
function showFPCount(text)
{
    var fingerId = $("#fingerId").val();
    if($.trim(fingerId) == "")
    {
        $("#fpCountMessage").text(text + " " + 0);
    }
    else
    {
        fingerId = fingerId.substr(1, fingerId.length - 2);
        var fingerIdArray = new Array();
        fingerIdArray = fingerId.split(",");
        $("#fpCountMessage").text(text + " " + fingerIdArray.length);
    }
}
 
/**
 * 将指纹数据保存到页面
 * @author wenxin
 * @create 2013-05-24 16:12:21 pm
 */
function storeDataToHtml()
{
    //没有手指标记数据
    if(fingerIdArray.length == 0)
    {
        $("#fingerId").val(" ");
    }
    else
    {
        //将手指标记数据保存到页面
        $("#fingerId").val("["+fingerIdArray.toString()+"]");
    }
    //没有指纹模板数据
    if(templateDataArray.length == 0)
    {
        $("#fingerTemplate10").val(" ");
    }
    else
    {
        //将指纹模板数据保存到页面
        $("#fingerTemplate10").val("["+templateDataArray.toString()+"]");
    }
}
 
//关闭窗体
function close(){
    $("#bg").css("display", "none");
    $("#box").css("display", "none");
    $("#comparisonDiv").css("display", "none");
    globalContext="";
}
 
/**
 * 点击已经采集指纹的手指时,弹出框删除数据
 * 删除时的回调函数
 * @author wenxin
 * @create 2013-05-14 17:12:21 pm
 * @param result 弹出框选择确定还是取消 
 * @param context 2d画布上下文
 * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
 */
var delFPData = function(result, context, browserFlag)
{
    var fingerId;
    if(result)
    {
        //将数组中的指定元素删除
        for(var i=0; i<fingerIdArray.length; i++)
        {
            fingerId = eval(fingerIdArray[i]);
            if(fingerId >= DURESS_FINGER_NUM)
            {
                fingerId = fingerId - DURESS_FINGER_NUM;
                if(fingerId == fpIdNum)
                {
                    //fingerIdArray.remove(i);
                    //templateDataArray.remove(i);
                    removeItem(fingerIdArray, i);
                    removeItem(templateDataArray, i);
                }
            }
            else
            {
                if(fingerId == fpIdNum)
                {
                    //fingerIdArray.remove(i);
                    //templateDataArray.remove(i);
                    removeItem(fingerIdArray, i);
                    removeItem(templateDataArray, i);
                }
            }
        }
        if(browserFlag == "simple")
        {
            document.getElementById("finger" + fingerId).checked = false;
        }
        else if(browserFlag == "html5")
        {
            //将手指颜色改变--重画时也要判断
            context.fillStyle = bgColor;
            context.fill();
            if(lastFPIdNum != null && lastFPIdNum != lastFPIdNum)
            {
                //消除原来手指的颜色
                renderAfterColl(globalContext, lastFPIdNum, bgColor, false);
            }
            //消除需要删除的手指颜色
            renderAfterColl(globalContext, fpIdNum, bgColor, false);
        }
        fpModifyFlag = true;
        $("#duressFinger").attr("disabled", false);
        $("#submitButtonId").attr("disabled", false);
    }
    else
    {
        if(browserFlag == "simple")
        {
            document.getElementById("finger" + fpIdNum).checked = true
            collectFlag = true;
        }
        else if(browserFlag == "html5")
        {
            //消除原来手指的颜色--有问题,如果原来手指和现在的一样,有问题
            //renderAfterColl(globalContext, lastFPIdNum, bgColor, false);
        }
    }
}
 
/**
 * 删除数组元素 -- 从dx下标开始,删除一个元素
 * @author wenxin
 * @create 2013-05-15 11:11:31 am
 * @param dx 要删除元素的下标
 */
function removeItem(array, dx)
{  
   array.splice(dx, 1);
}
 
/**
 * 指纹验证
 * @author wenxin
 * @create 2013-06-21 11:09:20 am
 * @param title 页面标题国际化内容
 * @param isDriverInstall 是否安装了驱动
 * @param downloadPrompt 提示安装驱动国际化内容
 */
function fpVerification(title, downloadPrompt, isDriverInstall,context)
{
    //安装驱动
    if(isDriverInstall)
    {
        //支持html5
        if(typeof(Worker) != "undefined")
        {
            //createWindow('base_baseFPVerify.do?random=' + getRandomNum() + '^0^0^465^320^'+title);
            var comparisonDiv=document.getElementById("comparisonDiv");
            var bg=document.getElementById("bg");
            comparisonDiv.style.display="block";//显示内容层,显示覆盖层
            comparisonDiv.style.left=parseInt((document.documentElement.scrollWidth-comparisonDiv.offsetWidth)/2)+document.documentElement.scrollLeft+"px";
            comparisonDiv.style.top=Math.abs(parseInt((document.documentElement.clientHeight-comparisonDiv.offsetHeight)/2))+document.documentElement.scrollTop+"px"; //为内容层设置位置
             bg.style.display="block";
             bg.style.height=document.documentElement.scrollHeight+"px"; 
             isComp= true;
             //开始采集
             //beginCapture(context);
             dataInitComp();
            //关闭页面前,取消采集
            //cancelCaptureBeforeClose("html5");
        }
        else
        {
            createWindow('base_baseFPVerifySimple.do?random=' + getRandomNum() + '^0^0^465^320^' + title);
            //关闭页面前,取消采集
            //cancelCaptureBeforeClose("simple");
        }
    }
    else
    {
        alert(downloadPrompt);
        //messageBox({messageType: "alert", title: "提示", text: downloadPrompt});
    }
}
 
/**
 * 画布文本自动换行
 * @author chenpf
 * @create 2015-03-10 16:56:31 pm
 * @param context 2d画布上下文
 * @param text  显示信息内容
 * @param CWidth 画布宽度
 * @param x 文本X坐标值
 * 
 */
function autoWordBreak(context,text,CWidth,x){
    context.clear();
    var rownum = CWidth / 10;
    var len = strlen(text);
    if (rownum > len)
    {
        context.fillText(text, x, 30);
    }
    else
    {
        var endInd = rownum<text.length?rownum:text.length;
        var beginInd = 0;
        var endTemp=0;
        for (var i = 0; i <= text.length / rownum; i++)
        {
            endTemp = text.substr(beginInd, endInd).lastIndexOf(" ");
            if(endTemp!=-1)
                endInd=beginInd+endTemp;
            context.fillText(text.substr(beginInd, endInd), x, (i + 1) * 30);
            beginInd = endInd+1;
            if(beginInd>=text.length)
                break;
            endInd = beginInd + rownum;
        }
    }
}
 
 
//清除画布内容
CanvasRenderingContext2D.prototype.clear =
      CanvasRenderingContext2D.prototype.clear || function (preserveTransform) {
        if (preserveTransform) {
          this.save();
          this.setTransform(1, 0, 0, 1, 0, 0);
        }
     
        this.clearRect(0, 0, this.canvas.width, this.canvas.height);
     
        if (preserveTransform) {
          this.restore();
        }          
    };
    
    /**
     * 关闭页面前,如果正在进行验证,则先取消采集
     * @author wenxin
     * @create 2013-06-24 19:57:11 pm
     * @param browserFlag 浏览器标记 simple:简易版本,表示是ie浏览器;html5:表示支持html5的浏览器
     */
    function cancelCaptureBeforeClose(browserFlag)
    {
         //关闭页面时,监听关闭的onclick事件
        getCurrentWindow().button("close").attachEvent("onClick", function()
        {
            clearTimeout(verifyTimer);
            if(browserFlag == "html5")
            {
                //正在进行验证,还没有关闭指纹采集
                if(verifyFlag)
                {
                    //取消采集
                    cancelCapture();
                }
                //关闭页面
                closeWindow();
            }
            else if(browserFlag == "simple")
            {
                //alert("cancel capture before close window!");
                //将定时器的递归调用关闭
                clearTimeout(timer);
                //取消采集 
                cancelRegister();
                //此处应该在取消结束后,再关闭窗口
                closeWindow();
            }
        });
    }
    
    /**
     * 表单提交
     * @author wenxin
     * @create 2013-08-05 15:19:11 pm
     */
    function formSubmit(id)
    {
        
        $('#'+id).serialize();
        $('#'+id).ajaxForm(function(data){
            callBackFormSubmit(data);
        });
        $('#'+id).submit(); //表单提交。
    }