@regulaforensics/cordova-plugin-document-reader-api 6.4.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,11 +17,18 @@
17
17
  <allow-intent href="mailto:*" />
18
18
  <allow-intent href="geo:*" />
19
19
  <platform name="android">
20
+ <preference name="GradlePluginKotlinEnabled" value="true" />
21
+ <preference name="GradlePluginKotlinCodeStyle" value="official" />
22
+ <preference name="GradlePluginKotlinVersion" value="1.7.10" />
23
+ <preference name="android-minSdkVersion" value="21" />
24
+ <preference name="android-targetSdkVersion" value="33" />
20
25
  <preference name="AndroidXEnabled" value="true" />
21
26
  <allow-intent href="market:*" />
22
27
  <config-file parent="/*" target="AndroidManifest.xml">
23
28
  <uses-permission android:name="android.permission.NFC" />
24
29
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
30
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
31
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
25
32
  </config-file>
26
33
  </platform>
27
34
  <platform name="ios">
@@ -13,11 +13,11 @@
13
13
  "author": "Regula Forensics Inc.",
14
14
  "license": "commercial",
15
15
  "dependencies": {
16
- "cordova-android": "^9.0.0",
17
- "cordova-ios": "^6.1.1",
16
+ "cordova-android": "^10.1.1",
17
+ "cordova-ios": "^6.2.0",
18
18
  "cordova-plugin-add-swift-support": "^2.0.2",
19
- "@regulaforensics/cordova-plugin-document-reader-api": "^6.4.0",
20
- "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "^6.4.0",
19
+ "@regulaforensics/cordova-plugin-document-reader-api": "6.6.0",
20
+ "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "6.6.0",
21
21
  "cordova-plugin-file": "^6.0.2",
22
22
  "cordova-plugin-image-picker": "^1.1.3",
23
23
  "cordova-plugin-android-permissions": "1.1.0",
@@ -47,4 +47,4 @@
47
47
  "devDependencies": {
48
48
  "cordova-plugin-whitelist": "^1.3.4"
49
49
  }
50
- }
50
+ }
@@ -1,115 +1,113 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
-
4
- <head>
5
- <meta http-equiv="Content-Security-Policy"
6
- content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
7
- <meta name="format-detection" content="telephone=no">
8
- <meta name="msapplication-tap-highlight" content="no">
9
- <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
10
- <link rel="stylesheet" type="text/css" href="css/index.css">
11
- <title>Document Reader</title>
12
- </head>
13
-
14
- <body>
15
- <div id="rfidUI" style="text-align: center; background-color: #F5FCFF; height: 100%; width:100%; display: none;">
16
- <div style="position: absolute; top: 50%; left: 50%; width:100%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); ">
17
- <p id="rfidUIHeader">Reading RFID</p>
18
- <p id="rfidDescription">Place your phone on top of the NFC tag</p>
19
- <progress id="rfidProgress" value="0" max="100"></progress>
20
- <br><br><br>
21
- <button id="cancelButton">X</button>
22
- </div>
23
- </div>
24
- <div id="mainUI" style="
25
- text-align: center;
26
- background-color: #F5FCFF;
27
- height: 100%;">
28
- <div id="deviceready" style="position: absolute; top: 10px; width: 100%; text-align: center;">
29
- <p class="event listening">Connecting to Device</p>
30
- <p id="status" class="event received">Ready</p>
31
- </div>
32
- <div style="padding: 5px">
33
- <div style="align-items:center; text-align: center;display: inline-block;"><br><br>
34
- <p style="margin-bottom: 5px">Portrait</p>
35
- <img style="height: 133px; width: 100px" src="img/portrait.png" resizeMode="contain"
36
- id="portraitImage"/>
3
+ <head>
4
+ <meta http-equiv="Content-Security-Policy"
5
+ content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
6
+ <meta name="format-detection" content="telephone=no">
7
+ <meta name="msapplication-tap-highlight" content="no">
8
+ <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
9
+ <link rel="stylesheet" type="text/css" href="css/index.css">
10
+ <title>Document Reader</title>
11
+ </head>
12
+
13
+ <body>
14
+ <div id="rfidUI" style="text-align: center; background-color: #F5FCFF; height: 100%; width:100%; display: none;">
15
+ <div style="position: absolute; top: 50%; left: 50%; width:100%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); ">
16
+ <p id="rfidUIHeader">Reading RFID</p>
17
+ <p id="rfidDescription">Place your phone on top of the NFC tag</p>
18
+ <progress id="rfidProgress" value="0" max="100"></progress>
19
+ <br><br><br>
20
+ <button id="cancelButton">X</button>
21
+ </div>
37
22
  </div>
38
- <div style="align-items: center; text-align: center; display: inline-block;"><br><br>
39
- <p style="margin-bottom: 5px">Document</p>
40
- <img style="height: 133px;" src="img/id.png" resizeMode="contain" id="documentImage"/>
23
+ <div id="mainUI" style="text-align: center;background-color: #F5FCFF;height: 100%;">
24
+ <div style="padding: 5px">
25
+ <div id="deviceready" style="padding-top: 12px; width: 100%; text-align: center;">
26
+ <p class="event listening">Connecting to Device</p>
27
+ <p id="status" class="event received">Ready</p>
28
+ </div>
29
+ <div style="align-items:center; text-align: center;display: inline-block;"><br><br>
30
+ <p style="margin-bottom: 5px">Portrait</p>
31
+ <img style="height: 133px; width: 100px" src="img/portrait.png" resizeMode="contain"
32
+ id="portraitImage"/>
33
+ </div>
34
+ <div style="align-items: center; text-align: center; display: inline-block;"><br><br>
35
+ <p style="margin-bottom: 5px">Document</p>
36
+ <img style="height: 133px;" src="img/id.png" resizeMode="contain" id="documentImage"/>
37
+ </div>
38
+ </div>
39
+
40
+ <div>
41
+ <div id="scenariosRadioGroup"
42
+ style="position: absolute; bottom: 130px; top: 300px; left: 75px; width:225px; padding: 5px; text-align:left; overflow: auto"/>
43
+ </div>
44
+
45
+ <div style="position: absolute; bottom: 0px; width: 100%;">
46
+ <div id="rfidDiv" style="flex-direction: row; padding: 5px">
47
+ <input id="rfidCheckbox" type="checkbox" name="rfid" disabled><span
48
+ id="rfidCheckboxText"
49
+ style="color: lightgrey"> Process rfid reading(unavailable)</span><br>
50
+ </div>
51
+ <div id="encryptionDiv" style="flex-direction: row; padding: 5px">
52
+ <input id="encryptionCheckbox" type="checkbox" name="rfid" disabled><span
53
+ id="encryptionCheckboxText"
54
+ style="color: lightgrey"> Data encryption(unavailable)</span><br>
55
+ </div>
56
+ <div style="flex-direction: row; padding: 10px">
57
+ <button id="showScannerButton" style="margin-right: 20px">scan doc</button>
58
+ <button id="showImagePicker" style="margin-left: 20px">scan image</button>
59
+ </div>
60
+ </div>
41
61
  </div>
42
- </div>
43
-
44
- <div>
45
- <div id="scenariosRadioGroup"
46
- style="position: absolute; bottom: 140px; top: 225px; left: 75px; width:225px; padding: 5px; text-align:left; overflow: auto"/>
47
- </div>
48
-
49
- <div style="position: absolute; bottom: 10px; width: 100%; text-align: center; align-items: center">
50
- <div id="rfidDiv" style="flex-direction: row; padding: 5px">
51
- <input id="rfidCheckbox" type="checkbox" name="rfid" disabled><span
52
- id="rfidCheckboxText"
53
- style="color: lightgrey"> Process rfid reading(unavailable)</span><br>
54
- </div>
55
- <div id="encryptionDiv" style="flex-direction: row; padding: 5px">
56
- <input id="encryptionCheckbox" type="checkbox" name="rfid" disabled><span
57
- id="encryptionCheckboxText"
58
- style="color: lightgrey"> Data encryption(unavailable)</span><br>
59
- </div>
60
- <div style="flex-direction: row; padding: 10px">
61
- <button id="showScannerButton" style="margin-right: 20px">scan doc</button>
62
- <button id="showImagePicker" style="margin-left: 20px">scan image</button>
63
- </div>
64
- </div>
65
- </div>
66
- <script type="text/javascript" src="cordova.js"></script>
67
- <script type="text/javascript" src="js/index.js"></script>
68
- <style type="text/css">
69
- button {
70
- width: 40%;
71
- -moz-box-shadow: inset 0px -3px 7px 0px #29bbff;
72
- -webkit-box-shadow: inset 0px -3px 7px 0px #29bbff;
73
- box-shadow: inset 0px -3px 7px 0px #29bbff;
74
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #2dabf9), color-stop(1, #0688fa));
75
- background: -moz-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
76
- background: -webkit-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
77
- background: -o-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
78
- background: -ms-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
79
- background: linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%);
80
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2dabf9', endColorstr='#0688fa', GradientType=0);
81
- background-color: #2dabf9;
82
- -moz-border-radius: 3px;
83
- -webkit-border-radius: 3px;
84
- border-radius: 3px;
85
- border: 1px solid #0b0e07;
86
- display: inline-block;
87
- cursor: pointer;
88
- color: #ffffff;
89
- font-family: Arial;
90
- font-size: 15px;
91
- padding: 9px 23px;
92
- text-decoration: none;
93
- text-shadow: 0px 1px 0px #263666;
94
- }
95
-
96
- button:hover {
97
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0688fa), color-stop(1, #2dabf9));
98
- background: -moz-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
99
- background: -webkit-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
100
- background: -o-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
101
- background: -ms-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
102
- background: linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%);
103
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0688fa', endColorstr='#2dabf9', GradientType=0);
104
- background-color: #0688fa;
105
- }
106
-
107
- button:active {
108
- position: relative;
109
- top: 1px;
110
- }
111
-
112
- </style>
113
- </body>
114
-
115
- </html>
62
+
63
+ <script type="text/javascript" src="cordova.js"></script>
64
+ <script type="text/javascript" src="js/index.js"></script>
65
+
66
+ <style type="text/css">
67
+ button {
68
+ width: 40%;
69
+ -moz-box-shadow: inset 0px -3px 7px 0px #29bbff;
70
+ -webkit-box-shadow: inset 0px -3px 7px 0px #29bbff;
71
+ box-shadow: inset 0px -3px 7px 0px #29bbff;
72
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #2dabf9), color-stop(1, #0688fa));
73
+ background: -moz-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
74
+ background: -webkit-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
75
+ background: -o-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
76
+ background: -ms-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
77
+ background: linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%);
78
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2dabf9', endColorstr='#0688fa', GradientType=0);
79
+ background-color: #2dabf9;
80
+ -moz-border-radius: 3px;
81
+ -webkit-border-radius: 3px;
82
+ border-radius: 3px;
83
+ border: 1px solid #0b0e07;
84
+ display: inline-block;
85
+ cursor: pointer;
86
+ color: #ffffff;
87
+ font-family: Arial;
88
+ font-size: 15px;
89
+ padding: 9px 23px;
90
+ text-decoration: none;
91
+ text-shadow: 0px 1px 0px #263666;
92
+ }
93
+
94
+ button:hover {
95
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0688fa), color-stop(1, #2dabf9));
96
+ background: -moz-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
97
+ background: -webkit-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
98
+ background: -o-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
99
+ background: -ms-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
100
+ background: linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%);
101
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0688fa', endColorstr='#2dabf9', GradientType=0);
102
+ background-color: #0688fa;
103
+ }
104
+
105
+ button:active {
106
+ position: relative;
107
+ top: 1px;
108
+ }
109
+
110
+ </style>
111
+ </body>
112
+
113
+ </html>
@@ -1,9 +1,9 @@
1
1
  var app = {
2
- initialize: function() {
2
+ initialize: function () {
3
3
  document.addEventListener('deviceready', this.onDeviceReady.bind(this), false)
4
4
  },
5
5
 
6
- onDeviceReady: function() {
6
+ onDeviceReady: function () {
7
7
  this.receivedEvent('deviceready')
8
8
  document.getElementById("status").innerHTML = "loading......"
9
9
  document.getElementById("status").style.backgroundColor = "grey"
@@ -14,13 +14,14 @@ var app = {
14
14
  var doRfid = false
15
15
  var encryption = false
16
16
  const ENCRYPTED_RESULT_SERVICE = "https://api.regulaforensics.com/api/process"
17
+ var isReadingRfidCustomUi = false
17
18
  var isReadingRfid = false
18
19
  var rfidUIHeader = "Reading RFID"
19
20
  var rfidUIHeaderColor = "black"
20
21
  var rfidDescription = "Place your phone on top of the NFC tag"
21
22
  var rfidProgress = -1
22
- document.getElementById("rfidUI").style.display = isReadingRfid ? "" : "none"
23
- document.getElementById("mainUI").style.display = !isReadingRfid ? "" : "none"
23
+ document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
24
+ document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
24
25
  document.getElementById("rfidUIHeader").innerHTML = rfidUIHeader
25
26
  document.getElementById("rfidUIHeader").style.color = rfidUIHeaderColor
26
27
  document.getElementById("rfidDescription").innerHTML = rfidDescription
@@ -35,7 +36,7 @@ var app = {
35
36
  input.value = DocumentReaderScenario.fromJson(typeof scenarios[index] === "string" ? JSON.parse(scenarios[index]) : scenarios[index]).name
36
37
  if (index == 0)
37
38
  input.checked = true
38
- input.onclick = function() { DocumentReader.setConfig({ processParams: { scenario: this.value } }, function(m) {}, function(e) {}) }
39
+ input.onclick = function () { DocumentReader.setConfig({ processParams: { scenario: this.value } }, function (m) { }, function (e) { }) }
39
40
  input.style.display = "inline-block"
40
41
  document.getElementById("scenariosRadioGroup").appendChild(input)
41
42
  var label = document.createElement("span")
@@ -43,7 +44,7 @@ var app = {
43
44
  label.style.display = "inline-block"
44
45
  label.style.width = "200px"
45
46
  label.radioButton = input
46
- label.onclick = function() { this.radioButton.click() }
47
+ label.onclick = function () { this.radioButton.click() }
47
48
  document.getElementById("scenariosRadioGroup").appendChild(label)
48
49
  document.getElementById("scenariosRadioGroup").appendChild(document.createElement("br"))
49
50
  }
@@ -51,25 +52,25 @@ var app = {
51
52
  document.getElementById("rfidCheckbox").disabled = false
52
53
  document.getElementById("rfidCheckboxText").style.color = "black"
53
54
  document.getElementById("rfidCheckboxText").innerHTML = " Process rfid reading"
54
- document.getElementById("rfidCheckboxText").onclick = function() { document.getElementById("rfidCheckbox").click() }
55
- document.getElementById("rfidCheckbox").onchange = function() { doRfid = this.checked }
55
+ document.getElementById("rfidCheckboxText").onclick = function () { document.getElementById("rfidCheckbox").click() }
56
+ document.getElementById("rfidCheckbox").onchange = function () { doRfid = this.checked }
56
57
  }
57
58
  document.getElementById("encryptionCheckbox").disabled = false
58
59
  document.getElementById("encryptionCheckboxText").style.color = "black"
59
60
  document.getElementById("encryptionCheckboxText").innerHTML = " Data encryption"
60
- document.getElementById("encryptionCheckboxText").onclick = function() { document.getElementById("encryptionCheckbox").click() }
61
- document.getElementById("encryptionCheckbox").onchange = function() { encryption = this.checked }
61
+ document.getElementById("encryptionCheckboxText").onclick = function () { document.getElementById("encryptionCheckbox").click() }
62
+ document.getElementById("encryptionCheckbox").onchange = function () { encryption = this.checked }
62
63
  }
63
64
 
64
65
  function scan() {
65
- DocumentReader.showScanner(function(m) {
66
+ DocumentReader.showScanner(function (m) {
66
67
  handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m)))
67
- }, function(e) {})
68
+ }, function (e) { })
68
69
  }
69
70
 
70
71
  function recognizeAndroid() {
71
72
  var permissions = cordova.plugins.permissions
72
- permissions.checkPermission(permissions.READ_EXTERNAL_STORAGE, function(status) {
73
+ permissions.checkPermission(permissions.READ_EXTERNAL_STORAGE, function (status) {
73
74
  if (status.hasPermission)
74
75
  recognize()
75
76
  else {
@@ -85,11 +86,11 @@ var app = {
85
86
 
86
87
  function stopRfid() {
87
88
  hideRfidUI()
88
- DocumentReader.stopRFIDReader(function(e) {}, function(e) {})
89
+ DocumentReader.stopRFIDReader(function (e) { }, function (e) { })
89
90
  }
90
91
 
91
92
  function recognize() {
92
- window.imagePicker.getPictures(function(results) {
93
+ window.imagePicker.getPictures(function (results) {
93
94
  if (results.length > 0) {
94
95
  clearResults()
95
96
  document.getElementById("status").innerHTML = "copying image......"
@@ -97,46 +98,50 @@ var app = {
97
98
  }
98
99
  var images = []
99
100
  for (var index in results)
100
- readFile(results[index], function(base64) {
101
+ readFile(results[index], function (base64) {
101
102
  document.getElementById("status").innerHTML = "processing image......"
102
103
  document.getElementById("status").style.backgroundColor = "grey"
103
104
  images.push(base64)
104
105
  if (images.length === results.length)
105
- DocumentReader.recognizeImages(images, function(m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function(e) {})
106
+ DocumentReader.recognizeImages(images, function (m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function (e) { })
106
107
  })
107
- }, function(e) {}, { maximumImagesCount: 10 })
108
+ }, function (e) { }, { maximumImagesCount: 10 })
108
109
  }
109
110
 
110
111
  function handleCompletion(completion) {
111
- if (isReadingRfid && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
112
+ if (isReadingRfidCustomUi && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
112
113
  hideRfidUI()
113
- if (isReadingRfid && completion.action === Enum.DocReaderAction.NOTIFICATION)
114
+ if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
114
115
  updateRfidUI(completion.results.documentReaderNotification)
115
116
  if (completion.action === Enum.DocReaderAction.COMPLETE)
116
- if (isReadingRfid)
117
+ if (isReadingRfidCustomUi)
117
118
  if (completion.results.rfidResult !== 1)
118
119
  restartRfidUI()
119
120
  else {
120
121
  hideRfidUI()
121
122
  displayResults(completion.results)
122
123
  }
123
- else
124
+ else
125
+ handleResults(completion.results)
126
+ if (completion.action === Enum.DocReaderAction.TIMEOUT)
124
127
  handleResults(completion.results)
128
+ if(completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR)
129
+ isReadingRfid = false
125
130
  }
126
131
 
127
132
  function showRfidUI() {
128
133
  // show animation
129
- isReadingRfid = true
130
- document.getElementById("rfidUI").style.display = isReadingRfid ? "" : "none"
131
- document.getElementById("mainUI").style.display = !isReadingRfid ? "" : "none"
134
+ isReadingRfidCustomUi = true
135
+ document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
136
+ document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
132
137
  }
133
138
 
134
139
  function hideRfidUI() {
135
140
  // show animation
136
141
  restartRfidUI()
137
- isReadingRfid = false
138
- document.getElementById("rfidUI").style.display = isReadingRfid ? "" : "none"
139
- document.getElementById("mainUI").style.display = !isReadingRfid ? "" : "none"
142
+ isReadingRfidCustomUi = false
143
+ document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
144
+ document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
140
145
  rfidUIHeader = "Reading RFID"
141
146
  document.getElementById("rfidUIHeader").innerHTML = rfidUIHeader
142
147
  rfidUIHeaderColor = "black"
@@ -166,21 +171,21 @@ var app = {
166
171
  rfidProgress = results.value
167
172
  document.getElementById("rfidProgress").value = rfidProgress
168
173
  if (window.cordova.platformId === 'ios')
169
- DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + results.value + "%", function(e) {}, function(e) {})
174
+ DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + results.value + "%", function (e) { }, function (e) { })
170
175
  }
171
176
 
172
177
  function customRFID() {
173
178
  showRfidUI()
174
- DocumentReader.readRFID(function(m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function(e) {})
179
+ DocumentReader.readRFID(function (m) { handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m))) }, function (e) { })
175
180
  }
176
181
 
177
182
  function usualRFID() {
178
- doRfid = false
183
+ isReadingRfid = true
179
184
  var notification = "rfidNotificationCompletionEvent"
180
185
  var paCert = "paCertificateCompletionEvent"
181
186
  var taCert = "taCertificateCompletionEvent"
182
187
  var taSig = "taSignatureCompletionEvent"
183
- DocumentReader.startRFIDReader(function(m) {
188
+ DocumentReader.startRFIDReader(function (m) {
184
189
  if (m.substring(0, notification.length) === notification) {
185
190
  m = m.substring(notification.length, m.length)
186
191
  console.log(notification + ": " + m)
@@ -195,48 +200,41 @@ var app = {
195
200
  console.log(taSig + ": " + m)
196
201
  } else
197
202
  handleCompletion(DocumentReader.DocumentReaderCompletion.fromJson(JSON.parse(m)))
198
- }, function(e) {})
203
+ }, function (e) { })
199
204
  }
200
205
 
201
206
  function handleResults(results) {
202
207
  clearResults()
203
- if (doRfid && results != null && results.chipPage != 0) {
204
- accessKey = results.getTextFieldValueByType(DocumentReader.Enum.eVisualFieldType.FT_MRZ_STRINGS)
205
- if (accessKey != null && accessKey != "") {
206
- accessKey = accessKey.replace(/^/g, '').replace(/\n/g, '')
207
- DocumentReader.setRfidScenario({ mrz: accessKey, pacePasswordType: DocumentReader.Enum.eRFID_Password_Type.PPT_MRZ }, function(m) {}, function(e) {})
208
- } else {
209
- accessKey = results.getTextFieldValueByType(DocumentReader.Enum.eVisualFieldType.FT_CARD_ACCESS_NUMBER)
210
- if (accessKey != null && accessKey != "")
211
- DocumentReader.setRfidScenario({ password: accessKey, pacePasswordType: DocumentReader.Enum.eRFID_Password_Type.PPT_CAN }, function(m) {}, function(e) {})
212
- }
208
+ if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
213
209
  //customRFID()
214
210
  usualRFID()
215
- } else
216
- if (encryption) {
217
- var input = JSON.parse(results.rawResult)
218
- var processParam = {
219
- alreadyCropped: true,
220
- scenario: "FullProcess"
221
- }
222
- var body = {
223
- List: input["ContainerList"]["List"],
224
- processParam: processParam
225
- }
226
- postRequest(body)
227
- } else
228
- displayResults(results)
211
+ } else {
212
+ isReadingRfid = false
213
+ if (encryption) {
214
+ var input = JSON.parse(results.rawResult)
215
+ var processParam = {
216
+ alreadyCropped: true,
217
+ scenario: "FullProcess"
218
+ }
219
+ var body = {
220
+ List: input["ContainerList"]["List"],
221
+ processParam: processParam
222
+ }
223
+ postRequest(body)
224
+ } else
225
+ displayResults(results)
226
+ }
229
227
  }
230
228
 
231
229
  function postRequest(body) {
232
230
  document.getElementById("status").innerHTML = "Getting results from server......"
233
231
  document.getElementById("status").style.backgroundColor = "grey"
234
232
  http.setDataSerializer('utf8')
235
- http.post(ENCRYPTED_RESULT_SERVICE, JSON.stringify(body), { "content-type": "application/json; utf-8" }, function(response) {
236
- DocumentReader.parseCoreResults(response.data, function(m) {
237
- displayResults(DocumentReader.DocumentReaderResults.fromJson(JSON.parse(m)))
238
- }, function(e) {})
239
- }, function(response) {
233
+ http.post(ENCRYPTED_RESULT_SERVICE, JSON.stringify(body), { "content-type": "application/json; utf-8" }, function (response) {
234
+ DocumentReader.parseCoreResults(response.data, function (m) {
235
+ displayResults(DocumentReaderResults.fromJson(JSON.parse(m)))
236
+ }, function (e) { })
237
+ }, function (response) {
240
238
  console.error(response.error)
241
239
  document.getElementById("status").innerHTML = "Something went wrong!"
242
240
  document.getElementById("status").style.backgroundColor = "red"
@@ -259,8 +257,8 @@ var app = {
259
257
  }
260
258
 
261
259
  function addCertificates() {
262
- window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/certificates/", function(fileSystem) {
263
- fileSystem.createReader().readEntries(function(entries) {
260
+ window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/certificates/", function (fileSystem) {
261
+ fileSystem.createReader().readEntries(function (entries) {
264
262
  for (var i in entries) {
265
263
  var item = entries[i]
266
264
  if (item.isFile) {
@@ -268,44 +266,47 @@ var app = {
268
266
  var pkdResourceType = 0
269
267
  if (findExt.length > 0)
270
268
  pkdResourceType = Enum.PKDResourceType.getType(findExt[findExt.length - 1].toLowerCase())
271
- readFile("www/certificates/" + item.name, function(file, resType) {
269
+ readFile("www/certificates/" + item.name, function (file, resType) {
272
270
  resType = resType[0]
273
271
  var certificates = []
274
272
  certificates.push({
275
273
  'binaryData': file,
276
274
  'resourceType': resType
277
275
  })
278
- DocumentReader.addPKDCertificates(certificates, function(s) {
276
+ DocumentReader.addPKDCertificates(certificates, function (s) {
279
277
  console.log("certificate added")
280
- }, function(e) { console.log(e) })
278
+ }, function (e) { console.log(e) })
281
279
  }, pkdResourceType)
282
280
  }
283
281
  }
284
- }, function(err) { console.log(err) })
285
- }, function(err) { console.log(err) })
282
+ }, function (err) { console.log(err) })
283
+ }, function (err) { console.log(err) })
286
284
  }
287
285
 
288
286
  function readFile(path, callback, ...items) {
289
287
  if (path.substring(0, 8) !== "file:///")
290
288
  path = cordova.file.applicationDirectory + path
291
- window.resolveLocalFileSystemURL(path, function(fileEntry) {
292
- fileEntry.file(function(file) {
289
+ window.resolveLocalFileSystemURL(path, function (fileEntry) {
290
+ fileEntry.file(function (file) {
293
291
  var reader = new FileReader()
294
- reader.onloadend = function(e) {
292
+ reader.onloadend = function (e) {
295
293
  callback(this.result.substring(this.result.indexOf(',') + 1), items)
296
294
  }
297
295
  reader.readAsDataURL(file)
298
296
  })
299
- }, function(e) { console.log(JSON.stringify(e)) })
297
+ }, function (e) { console.log(JSON.stringify(e)) })
300
298
  }
301
299
 
302
- readFile("www/regula.license", function(license) {
303
- DocumentReader.prepareDatabase("Full", function(message) {
300
+ readFile("www/regula.license", function (license) {
301
+ DocumentReader.prepareDatabase("Full", function (message) {
304
302
  if (message != "database prepared")
305
303
  document.getElementById("status").innerHTML = "Downloading database: " + message + "%"
306
304
  else {
307
305
  document.getElementById("status").innerHTML = "Loading......"
308
- DocumentReader.initializeReader(license, function(message) {
306
+ DocumentReader.initializeReader({
307
+ license: license,
308
+ delayedNNLoad: true
309
+ }, function (message) {
309
310
  document.getElementById("status").innerHTML = "Ready"
310
311
  document.getElementById("status").style.backgroundColor = "green"
311
312
  document.getElementById("showScannerButton").addEventListener("click", scan)
@@ -326,23 +327,23 @@ var app = {
326
327
  scenario: "Mrz",
327
328
  doRfid: false,
328
329
  },
329
- }, function(m) {}, function(e) {})
330
- DocumentReader.getAvailableScenarios(function(s) {
331
- DocumentReader.isRFIDAvailableForUse(function(r) { postInitialize(JSON.parse(s), r) }, function(e) {})
332
- }, function(e) {})
333
- DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA, function(r) {}, function(e) {})
334
- // addCertificates()
335
- }, function(error) {
330
+ }, function (m) { }, function (e) { })
331
+ DocumentReader.getAvailableScenarios(function (s) {
332
+ DocumentReader.isRFIDAvailableForUse(function (r) { postInitialize(JSON.parse(s), r) }, function (e) { })
333
+ }, function (e) { })
334
+ DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA, function (r) { }, function (e) { })
335
+ // addCertificates()
336
+ }, function (error) {
336
337
  console.log(error)
337
338
  document.getElementById("status").innerHTML = error
338
339
  document.getElementById("status").style.backgroundColor = "red"
339
340
  })
340
341
  }
341
- }, function(e) { console.log(e) })
342
+ }, function (e) { console.log(e) })
342
343
  })
343
344
  },
344
345
 
345
- receivedEvent: function(id) {
346
+ receivedEvent: function (id) {
346
347
  var parentElement = document.getElementById(id)
347
348
  var listeningElement = parentElement.querySelector('.listening')
348
349
  var receivedElement = parentElement.querySelector('.received')