@regulaforensics/document-reader 8.3.242-beta → 8.3.246-beta
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.
- package/README.md +2 -3
- package/RNDocumentReader.podspec +1 -1
- package/examples/capacitor/package.json +1 -1
- package/examples/capacitor/src/extra/bt_device.tsx +2 -2
- package/examples/capacitor/src/extra/custom_rfid.tsx +8 -8
- package/examples/capacitor/src/main.tsx +24 -27
- package/examples/ionic/package.json +1 -1
- package/examples/ionic/src/extra/{bt_device.ts → bt_device.tsx} +2 -2
- package/examples/ionic/src/extra/{custom_rfid.ts → custom_rfid.tsx} +8 -8
- package/examples/ionic/src/{main.ts → main.tsx} +24 -27
- package/examples/ionic/tsconfig.json +3 -2
- package/examples/react_native/index.tsx +2 -1
- package/examples/react_native/package.json +1 -1
- package/examples/react_native/src/extra/bt_device.tsx +2 -3
- package/examples/react_native/src/extra/custom_rfid.tsx +8 -9
- package/examples/react_native/src/main.tsx +24 -28
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/examples/cordova/.vscode/launch.json +0 -28
- package/examples/cordova/.vscode/typings/cordova/cordova.d.ts +0 -80
- package/examples/cordova/README.md +0 -22
- package/examples/cordova/config.xml +0 -33
- package/examples/cordova/package-lock.json +0 -1772
- package/examples/cordova/package.json +0 -33
- package/examples/cordova/scripts/android.sh +0 -8
- package/examples/cordova/scripts/bundle.sh +0 -4
- package/examples/cordova/scripts/ios.sh +0 -8
- package/examples/cordova/scripts/setup.sh +0 -8
- package/examples/cordova/www/bootstrap.js +0 -30
- package/examples/cordova/www/images/document.png +0 -0
- package/examples/cordova/www/images/logo.png +0 -0
- package/examples/cordova/www/images/portrait.png +0 -0
- package/examples/cordova/www/index.html +0 -6
- package/examples/cordova/www/index.js +0 -30
- package/examples/cordova/www/src/extra/bt_device.js +0 -32
- package/examples/cordova/www/src/extra/custom_rfid.js +0 -60
- package/examples/cordova/www/src/main.css +0 -134
- package/examples/cordova/www/src/main.html +0 -38
- package/examples/cordova/www/src/main.js +0 -173
- /package/examples/ionic/{index.ts → index.tsx} +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "document-reader",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"setup": "scripts/setup.sh",
|
|
5
|
-
"ios": "scripts/ios.sh",
|
|
6
|
-
"android": "scripts/android.sh"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@regulaforensics/document-reader": "8.3.242-beta",
|
|
10
|
-
"@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
|
|
11
|
-
"@regulaforensics/document-reader-btdevice": "8.3.10-beta",
|
|
12
|
-
"cordova-ios": "7.1.1",
|
|
13
|
-
"cordova-android": "13.0.0",
|
|
14
|
-
"cordova-plugin-file": "8.1.3",
|
|
15
|
-
"cordova-plugin-camera": "8.0.0",
|
|
16
|
-
"cordova-plugin-dialogs": "2.0.2",
|
|
17
|
-
"esbuild": "0.25.8"
|
|
18
|
-
},
|
|
19
|
-
"cordova": {
|
|
20
|
-
"plugins": {
|
|
21
|
-
"@regulaforensics/document-reader": {},
|
|
22
|
-
"@regulaforensics/document-reader-core-fullauthrfid": {},
|
|
23
|
-
"@regulaforensics/document-reader-btdevice": {},
|
|
24
|
-
"cordova-plugin-file": {},
|
|
25
|
-
"cordova-plugin-camera": {},
|
|
26
|
-
"cordova-plugin-dialogs": {}
|
|
27
|
-
},
|
|
28
|
-
"platforms": [
|
|
29
|
-
"android",
|
|
30
|
-
"ios"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
document.addEventListener('deviceready', () => {
|
|
2
|
-
// imports
|
|
3
|
-
window.DocumentReader = DocumentReaderPlugin.DocumentReader
|
|
4
|
-
DocReaderAction = DocumentReaderPlugin.DocReaderAction
|
|
5
|
-
FieldType = DocumentReaderPlugin.FieldType
|
|
6
|
-
GraphicFieldType = DocumentReaderPlugin.GraphicFieldType
|
|
7
|
-
InitConfig = DocumentReaderPlugin.InitConfig
|
|
8
|
-
RecognizeConfig = DocumentReaderPlugin.RecognizeConfig
|
|
9
|
-
ResultType = DocumentReaderPlugin.ResultType
|
|
10
|
-
RFIDConfig = DocumentReaderPlugin.RFIDConfig
|
|
11
|
-
ScannerConfig = DocumentReaderPlugin.ScannerConfig
|
|
12
|
-
Scenario = DocumentReaderPlugin.Scenario
|
|
13
|
-
RFIDDataFileType = DocumentReaderPlugin.RFIDDataFileType
|
|
14
|
-
RFIDNotificationCodes = DocumentReaderPlugin.RFIDNotificationCodes
|
|
15
|
-
|
|
16
|
-
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + 'www/src/main.html', (fileEntry) => {
|
|
17
|
-
fileEntry.file((file) => {
|
|
18
|
-
const reader = new FileReader()
|
|
19
|
-
reader.onloadend = async function () {
|
|
20
|
-
document.getElementById('content').innerHTML = this.result
|
|
21
|
-
|
|
22
|
-
const script = document.createElement('script')
|
|
23
|
-
script.src = 'bundle.js'
|
|
24
|
-
script.onload = () => document.dispatchEvent(new CustomEvent("ready"))
|
|
25
|
-
document.body.appendChild(script)
|
|
26
|
-
}
|
|
27
|
-
reader.readAsText(file)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
})
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { main } from './src/main.js'
|
|
2
|
-
|
|
3
|
-
export async function loadAsset(path) {
|
|
4
|
-
path = cordova.file.applicationDirectory + "www/" + path
|
|
5
|
-
return new Promise((resolve, _) => {
|
|
6
|
-
window.resolveLocalFileSystemURL(path, (fileEntry) => {
|
|
7
|
-
fileEntry.file((file) => {
|
|
8
|
-
var reader = new FileReader()
|
|
9
|
-
reader.onloadend = function (_) { resolve(this.result) }
|
|
10
|
-
reader.readAsDataURL(file)
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function pickImage() {
|
|
17
|
-
return new Promise((resolve, _) => {
|
|
18
|
-
navigator.camera.getPicture(
|
|
19
|
-
(imageData) => resolve(imageData),
|
|
20
|
-
(_) => resolve(null),
|
|
21
|
-
{
|
|
22
|
-
destinationType: Camera.DestinationType.DATA_URL,
|
|
23
|
-
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
24
|
-
mediaType: Camera.MediaType.PICTURE
|
|
25
|
-
}
|
|
26
|
-
)
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
document.addEventListener('ready', main)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { handleException, init, setStatus } from "../main.js"
|
|
2
|
-
|
|
3
|
-
export const useBtDevice = false
|
|
4
|
-
export const btDeviceName = "Regula 0000"
|
|
5
|
-
|
|
6
|
-
export function setupBTDevice() {
|
|
7
|
-
var connectButton = document.getElementById("connect")
|
|
8
|
-
connectButton.style.display = "flex"
|
|
9
|
-
connectButton.onclick = () => connect()
|
|
10
|
-
setStatus("Connect to a bluetooth device")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function connect() {
|
|
14
|
-
setStatus("Searching for devices...")
|
|
15
|
-
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
16
|
-
await init()
|
|
17
|
-
DocumentReader.instance.functionality.useAuthenticator = true
|
|
18
|
-
document.getElementById("bt-device").style.display = "none"
|
|
19
|
-
} else
|
|
20
|
-
setStatus("Failed to connect")
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function initializeWithBTDevice() {
|
|
24
|
-
setStatus("Initializing...")
|
|
25
|
-
|
|
26
|
-
var initConfig = InitConfig.withBleDevice()
|
|
27
|
-
initConfig.delayedNNLoad = true
|
|
28
|
-
var [success, error] = await DocumentReader.instance.initialize(initConfig)
|
|
29
|
-
|
|
30
|
-
handleException(error)
|
|
31
|
-
return success
|
|
32
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { displayResults, setStatus } from "../main.js"
|
|
2
|
-
|
|
3
|
-
export const useRfidSelfHostedUI = false
|
|
4
|
-
|
|
5
|
-
export function rfidSelfHostedUI() {
|
|
6
|
-
var config = RFIDConfig.withoutUI((action, results, _) => {
|
|
7
|
-
if (DocReaderAction.stopped(action)) stop()
|
|
8
|
-
if (DocReaderAction.finished(action)) displayResults(results)
|
|
9
|
-
if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
config.onProgress = async (notification) => {
|
|
13
|
-
if (notification.progress == 1) return
|
|
14
|
-
if (notification.notificationCode == RFIDNotificationCodes.PCSC_READING_DATAGROUP)
|
|
15
|
-
setDescription(await RFIDDataFileType.getTranslation(notification.dataFileType))
|
|
16
|
-
setStatus("Reading RFID")
|
|
17
|
-
setProgress(notification.progress)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setup()
|
|
21
|
-
DocumentReader.instance.rfid(config)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function setup() {
|
|
25
|
-
setStatus("Reading RFID")
|
|
26
|
-
setDescription("Place your phone on top of the NFC tag")
|
|
27
|
-
setProgress(-1)
|
|
28
|
-
currentProgress = -1
|
|
29
|
-
setShowing(true)
|
|
30
|
-
document.getElementById("cancel-rfid").onclick = () => stop()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function stop() {
|
|
34
|
-
DocumentReader.instance.stopRFIDReader()
|
|
35
|
-
displayResults(null)
|
|
36
|
-
setShowing(false)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function setDescription(data) {
|
|
40
|
-
document.getElementById("rfid-description").innerHTML = data
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var currentProgress = -1
|
|
44
|
-
function setProgress(next) {
|
|
45
|
-
var progress = document.getElementById("progress")
|
|
46
|
-
// make progress bar look better
|
|
47
|
-
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
48
|
-
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
49
|
-
if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
|
|
50
|
-
if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
|
|
51
|
-
else progress.style.transition = 'width 0.5s' // smoothly increase progress
|
|
52
|
-
|
|
53
|
-
progress.style.width = next + "%"
|
|
54
|
-
currentProgress = next
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function setShowing(data) {
|
|
58
|
-
document.getElementById("main").style.display = data ? "none" : "flex"
|
|
59
|
-
document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
|
|
60
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body {
|
|
3
|
-
margin: 0;
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 99vh;
|
|
6
|
-
display: flex;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.column {
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-direction: column;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
width: 100%;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.row {
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: row;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.header {
|
|
27
|
-
text-align: center;
|
|
28
|
-
padding-top: 80px;
|
|
29
|
-
margin-top: -10px;
|
|
30
|
-
background-color: rgba(0, 0, 0, 0.03);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.title {
|
|
34
|
-
font-weight: 600;
|
|
35
|
-
font-size: 18px;
|
|
36
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.divider {
|
|
40
|
-
height: 1px;
|
|
41
|
-
background-color: rgba(0, 0, 0, 0.075);
|
|
42
|
-
margin-top: 13px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.scroll {
|
|
46
|
-
flex-grow: 1;
|
|
47
|
-
overflow-y: auto;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.no-scroll {
|
|
51
|
-
flex-grow: 1;
|
|
52
|
-
overflow-y: hidden;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.button {
|
|
56
|
-
width: 175px;
|
|
57
|
-
height: 40px;
|
|
58
|
-
margin: 5px;
|
|
59
|
-
margin-top: 10px;
|
|
60
|
-
background-color: #4285F4;
|
|
61
|
-
color: white;
|
|
62
|
-
border: none;
|
|
63
|
-
padding: 10px 20px;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
font-size: 16px;
|
|
66
|
-
border-radius: 100px;
|
|
67
|
-
cursor: pointer;
|
|
68
|
-
transition: all 0.3s ease;
|
|
69
|
-
user-select: none;
|
|
70
|
-
-webkit-user-select: none;
|
|
71
|
-
-moz-user-select: none;
|
|
72
|
-
-ms-user-select: none;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.button:active {
|
|
76
|
-
position: relative;
|
|
77
|
-
top: 1px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.text-button {
|
|
81
|
-
background: none;
|
|
82
|
-
border: none;
|
|
83
|
-
color: #2196f3;
|
|
84
|
-
font-size: 20px;
|
|
85
|
-
font-weight: bold;
|
|
86
|
-
padding: 5px;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.text-button:active {
|
|
90
|
-
position: relative;
|
|
91
|
-
top: 1px;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.radio {
|
|
95
|
-
align-items: baseline;
|
|
96
|
-
padding: 15px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
input[type="checkbox"] {
|
|
100
|
-
width: 20px;
|
|
101
|
-
height: 20px;
|
|
102
|
-
border: 2px solid black;
|
|
103
|
-
background-color: white;
|
|
104
|
-
display: inline-block;
|
|
105
|
-
position: relative;
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
input[type="text"] {
|
|
110
|
-
width: 173px;
|
|
111
|
-
height: 40px;
|
|
112
|
-
font-size: 15px;
|
|
113
|
-
margin: 5px;
|
|
114
|
-
border-radius: 100px;
|
|
115
|
-
padding-left: 10px;
|
|
116
|
-
padding-right: 10px;
|
|
117
|
-
margin-top: 10px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.progress-bar {
|
|
121
|
-
width: 75%;
|
|
122
|
-
padding: 3px;
|
|
123
|
-
margin-top: 40px;
|
|
124
|
-
background-color: #eee;
|
|
125
|
-
border-radius: 8px;
|
|
126
|
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
#progress {
|
|
130
|
-
width: 0%;
|
|
131
|
-
height: 20px;
|
|
132
|
-
background-color: #4285F4;
|
|
133
|
-
border-radius: 5px;
|
|
134
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<div class="column" style="height: 100%">
|
|
2
|
-
<div class="column header">
|
|
3
|
-
<span id="status" class="title">Loading...</span>
|
|
4
|
-
<div class="column divider"></div>
|
|
5
|
-
</div>
|
|
6
|
-
<div id="main" class="column no-scroll">
|
|
7
|
-
<div class="row">
|
|
8
|
-
<div class="column" style="padding: 5px;">
|
|
9
|
-
<p>Portrait</p>
|
|
10
|
-
<img id="portrait-image" src="images/portrait.png" height="160px" width="120px">
|
|
11
|
-
</div>
|
|
12
|
-
<div class="column" style="padding: 5px;">
|
|
13
|
-
<p>Document image</p>
|
|
14
|
-
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
18
|
-
<div id="scenarios" class="scroll"></div>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
21
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
22
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row">
|
|
25
|
-
<button id="scan" class="button">Scan document</button>
|
|
26
|
-
<button id="recognize" class="button">Scan image</button>
|
|
27
|
-
</div>
|
|
28
|
-
<button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
|
|
29
|
-
<div style="padding-top: 20px;"></div>
|
|
30
|
-
</div>
|
|
31
|
-
<div id="custom-rfid" class="column no-scroll" style="display: none;">
|
|
32
|
-
<span id="rfid-description" style="font-size: 22px">Place your phone on top of the NFC tag</span>
|
|
33
|
-
<div class="progress-bar">
|
|
34
|
-
<div id="progress"></div>
|
|
35
|
-
</div>
|
|
36
|
-
<button id="cancel-rfid" class="text-button" style="margin-top: 50px;">X</button>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { loadAsset, pickImage } from '../index.js'
|
|
2
|
-
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device.js'
|
|
3
|
-
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid.js'
|
|
4
|
-
|
|
5
|
-
var documentReader = DocumentReader.instance
|
|
6
|
-
var selectedScenario
|
|
7
|
-
var doRfid = false
|
|
8
|
-
var isReadingRfid = false
|
|
9
|
-
|
|
10
|
-
export async function init() {
|
|
11
|
-
if (!await initialize()) return
|
|
12
|
-
setScenarios(documentReader.availableScenarios)
|
|
13
|
-
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
14
|
-
setStatus("Ready")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function scan() {
|
|
18
|
-
if (!await documentReader.isReady()) return
|
|
19
|
-
clearResults()
|
|
20
|
-
documentReader.startScanner(
|
|
21
|
-
ScannerConfig.withScenario(selectedScenario),
|
|
22
|
-
handleCompletion,
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function recognize() {
|
|
27
|
-
if (!await documentReader.isReady()) return
|
|
28
|
-
var image = await pickImage()
|
|
29
|
-
if (image == null) return
|
|
30
|
-
|
|
31
|
-
clearResults()
|
|
32
|
-
documentReader.recognize(
|
|
33
|
-
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
34
|
-
handleCompletion,
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function handleCompletion(action, results, error) {
|
|
39
|
-
handleException(error)
|
|
40
|
-
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
41
|
-
displayResults(results)
|
|
42
|
-
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
43
|
-
isReadingRfid = true
|
|
44
|
-
readRfid()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export async function displayResults(results) {
|
|
49
|
-
isReadingRfid = false
|
|
50
|
-
clearResults()
|
|
51
|
-
if (results == null) return
|
|
52
|
-
|
|
53
|
-
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
54
|
-
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
55
|
-
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
56
|
-
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
57
|
-
|
|
58
|
-
setStatus(name)
|
|
59
|
-
setPortrait(portrait)
|
|
60
|
-
setDocImage(docImage)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var readRfid = () => {
|
|
64
|
-
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function shouldRfid(results) {
|
|
68
|
-
return doRfid &&
|
|
69
|
-
!isReadingRfid &&
|
|
70
|
-
results != null && results.chipPage != 0
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var initialize = async () => {
|
|
74
|
-
setStatus("Initializing...")
|
|
75
|
-
|
|
76
|
-
var license = await loadAsset("regula.license")
|
|
77
|
-
var initConfig = new InitConfig(license)
|
|
78
|
-
var [success, error] = await documentReader.initialize(initConfig)
|
|
79
|
-
|
|
80
|
-
handleException(error)
|
|
81
|
-
return success
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function handleException(error) {
|
|
85
|
-
if (error != null) {
|
|
86
|
-
setStatus(error.message)
|
|
87
|
-
console.log(error.code + ": " + error.message)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// --------------------------------------------------------------------------------------------------------------------
|
|
92
|
-
|
|
93
|
-
var documentUIImage
|
|
94
|
-
var portraitUIImage
|
|
95
|
-
export function main() {
|
|
96
|
-
documentUIImage = document.getElementById("document-image")
|
|
97
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
98
|
-
document.getElementById("scan").onclick = () => scan()
|
|
99
|
-
document.getElementById("recognize").onclick = () => recognize()
|
|
100
|
-
|
|
101
|
-
// custom rfid
|
|
102
|
-
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
103
|
-
|
|
104
|
-
// bt device
|
|
105
|
-
if (!useBtDevice) init()
|
|
106
|
-
else {
|
|
107
|
-
setupBTDevice()
|
|
108
|
-
initialize = initializeWithBTDevice
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function setStatus(data) {
|
|
113
|
-
if (data != null)
|
|
114
|
-
document.getElementById("status").innerHTML = data
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function setPortrait(data) {
|
|
118
|
-
if (data != null)
|
|
119
|
-
portraitUIImage.src = "data:image/png;base64," + data
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function setDocImage(data) {
|
|
123
|
-
if (data != null)
|
|
124
|
-
documentUIImage.src = "data:image/png;base64," + data
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function clearResults() {
|
|
128
|
-
setStatus("Ready")
|
|
129
|
-
portraitUIImage.src = "images/portrait.png"
|
|
130
|
-
documentUIImage.src = "images/document.png"
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function setCanRfid(data) {
|
|
134
|
-
var checkbox // implicitly any, since cordova sample is pure js
|
|
135
|
-
checkbox = document.getElementById('rfid-checkbox')
|
|
136
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
137
|
-
if (data) {
|
|
138
|
-
checkbox.disabled = false
|
|
139
|
-
checkboxDescription.innerHTML = "Process rfid reading"
|
|
140
|
-
var onclick = () => {
|
|
141
|
-
doRfid = !doRfid
|
|
142
|
-
checkbox.checked = doRfid
|
|
143
|
-
}
|
|
144
|
-
checkbox.onclick = onclick
|
|
145
|
-
checkboxDescription.onclick = onclick
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function setScenarios(data) {
|
|
150
|
-
selectedScenario = Scenario.MRZ
|
|
151
|
-
var scenariosContainer = document.getElementById("scenarios")
|
|
152
|
-
|
|
153
|
-
data.forEach(scenario => {
|
|
154
|
-
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
155
|
-
var scenarioElement = `<div class="row radio">
|
|
156
|
-
<input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
|
|
157
|
-
<span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
|
|
158
|
-
</div>`
|
|
159
|
-
scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
data.forEach(scenario => {
|
|
163
|
-
var element
|
|
164
|
-
element = document.getElementById(scenario.name)
|
|
165
|
-
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
166
|
-
var onclick = () => {
|
|
167
|
-
selectedScenario = scenario.name
|
|
168
|
-
element.checked = true
|
|
169
|
-
}
|
|
170
|
-
element.onclick = onclick
|
|
171
|
-
elementCaption.onclick = onclick
|
|
172
|
-
})
|
|
173
|
-
}
|
|
File without changes
|