Skip to content

Commit 95173b5

Browse files
committed
Updated sample pages and releases for dl_barcode v2 and dl_keyboard v2
1 parent 1ce51ed commit 95173b5

28 files changed

Lines changed: 1258 additions & 740 deletions

index.html

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,66 @@
22

33
<!DOCTYPE html>
44
<html>
5+
56
<head>
6-
<title>Javascript SDK Sample Apps</title>
7-
<link rel="icon" type="image/x-icon" href="samples/res/favicon.ico">
7+
<title>Byron's Javascript SDK Sample Apps</title>
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<link rel="icon" type="image/x-icon" href="samples/res/favicon.ico">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
11+
<link rel="stylesheet" type="text/css" href="samples/styles/index.css">
12+
<link rel="stylesheet" type="text/css" href="samples/styles/styles.css">
813
</head>
914

10-
<body style = "font-family: Helvetica, sans-serif; font-size:6vw; color:#002592;">
11-
<!-- Header -->
12-
<p><img src="samples/res/logo.jpg" alt="Datalogic" style="width:80vw"></p>
13-
<h2 style = "font-size:7vw">Javascript SDK Samples</h2>
14-
<p style = "color:black; font-size:4vw">
15-
The following web apps demonstrate different aspects of the Datalogic Javascript SDK exposed by Datalogic Enterprise Browser.
16-
</p>
17-
<br>
18-
19-
<!-- Barcode scanning sample -->
20-
<p>
21-
<a href="samples/barcode.html"><b>Barcode Scanning</b></a>
22-
</p>
23-
24-
<!-- Scanning configuration sample -->
25-
<p>
26-
<a href="samples/config.html"><b>Scanning Configuration</b></a>
27-
</p>
28-
29-
<!-- Trigger configuration sample -->
30-
<p>
31-
<a href="samples/trigger.html"><b>Trigger Configuration</b></a>
32-
</p>
33-
34-
<!-- Use the Camera-->
35-
<p>
36-
<a href="samples/camera.html"><b>Camera</b></a>
37-
</p>
38-
39-
<!-- Trigger Location -->
40-
<p>
41-
<a href="samples/location.html"><b>Location</b></a>
42-
</p>
43-
44-
<!-- Use the Microphone -->
45-
<p>
46-
<a href="samples/microphone.html"><b>Microphone</b></a>
47-
</p>
15+
<body>
16+
<header>
17+
<img class="logo" src="samples/res/logo.jpg" alt="Datalogic">
18+
<center>
19+
<h2>Javascript SDK Samples</h2>
20+
<p class="description">
21+
The following web apps demonstrate different aspects of the Datalogic Javascript SDK exposed by
22+
Datalogic Enterprise Browser
23+
</p>
24+
</center>
25+
</header>
26+
27+
<div class="test-pages">
28+
<!-- Barcode scanning sample -->
29+
<div id="barcode-scanning" class="card">
30+
<img class="card-icon" src="samples/res/barcode-scanner.svg" alt="Avatar">
31+
<a class="test-page-link" href="samples/barcode.html">Barcode Scanning</a>
32+
</div>
33+
34+
<!-- Scanning configuration sample -->
35+
<div id="scanning-configuration" class="card">
36+
<img class="card-icon" src="samples/res/settings.svg" alt="Avatar">
37+
<a class="test-page-link" href="samples/config.html">Scanning Configuration</a>
38+
</div>
39+
40+
<!-- Trigger configuration sample -->
41+
<div id="trigger-configuration" class="card">
42+
<img class="card-icon" src="samples/res/settings.svg" alt="Avatar">
43+
<a class="test-page-link" href="samples/trigger.html">Trigger Configuration</a>
44+
</div>
45+
46+
<!-- Use the Camera-->
47+
<div id="camera" class="card">
48+
<img class="card-icon" src="samples/res/camera.svg" alt="Avatar">
49+
<a class="test-page-link" href="samples/camera.html">Camera</a>
50+
</div>
51+
52+
<!-- Trigger Location -->
53+
<div id="location" class="card">
54+
<img class="card-icon" src="samples/res/location.svg" alt="Avatar">
55+
<a class="test-page-link" href="samples/location.html">Location</a>
56+
</div>
57+
58+
<!-- Use the Microphone -->
59+
<div id="microphone" class="card">
60+
<img class="card-icon" src="samples/res/microphone.svg" alt="Avatar">
61+
<a class="test-page-link" href="samples/microphone.html">Microphone</a>
62+
</div>
63+
64+
</div>
4865
</body>
49-
</html>
66+
67+
</html>

lib/dl_barcode.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
// Interface for barcode functions.
22

3-
const DL_BARCODE_MGR_VER = 1;
3+
const DL_BARCODE_MGR_VER = 2;
44

55
class DLBcdMgr {
6+
7+
/**
8+
* Private method to return an instance of DLBarcodeMgr.
9+
* @returns {DLBcdMgr} An instance of DLBcdMgr.
10+
* @throws {ReferenceError} If _DLBarcodeMgr is not injected by Datalogic Enterprise Browser.
11+
*/
12+
#getDLBarcodeMgr() {
13+
try {
14+
return _DLBarcodeMgr;
15+
} catch(e) {
16+
throw ReferenceError("_DLBarcodeMgr has not been injected by Datalogic Enterprise Browser");
17+
}
18+
}
19+
620
/**
721
* Private method to return the appropriate type.
822
* @param {string} text A String with a prefixed type and value.
@@ -39,7 +53,7 @@ class DLBcdMgr {
3953
* @returns {any} The current value of the given id.
4054
*/
4155
getProperty(id) {
42-
return this.#getType(_DLBarcodeMgr.getProperty(id));
56+
return this.#getType(this.#getDLBarcodeMgr().getProperty(id));
4357
}
4458

4559
/**
@@ -50,10 +64,17 @@ class DLBcdMgr {
5064
*/
5165
setProperty(id, value) {
5266
if (typeof value === "string") {
53-
return _DLBarcodeMgr.setPropertyString(id, value);
67+
return this.#getDLBarcodeMgr().setPropertyString(id, value);
68+
}
69+
else if (typeof value === "boolean") {
70+
if (value) {
71+
return this.#getDLBarcodeMgr().setPropertyInt(id, 1);
72+
} else {
73+
return this.#getDLBarcodeMgr().setPropertyInt(id, 0);
74+
}
5475
}
5576
else {
56-
return _DLBarcodeMgr.setPropertyInt(id, value);
77+
return this.#getDLBarcodeMgr().setPropertyInt(id, value);
5778
}
5879
}
5980

@@ -83,7 +104,7 @@ class DLBcdMgr {
83104
* @returns {boolean} True if property is available.
84105
*/
85106
isAvailable(id) {
86-
return _DLBarcodeMgr.isAvailable(id);
107+
return this.#getDLBarcodeMgr().isAvailable(id);
87108
}
88109

89110
/**
@@ -92,7 +113,7 @@ class DLBcdMgr {
92113
* @returns {any} The minimum value of the property.
93114
*/
94115
getMin(id) {
95-
return this.#getType(_DLBarcodeMgr.getMin(id));
116+
return this.#getType(this.#getDLBarcodeMgr().getMin(id));
96117
}
97118

98119
/**
@@ -101,15 +122,15 @@ class DLBcdMgr {
101122
* @returns {any} The maximum value of the property.
102123
*/
103124
getMax(id) {
104-
return this.#getType(_DLBarcodeMgr.getMax(id));
125+
return this.#getType(this.#getDLBarcodeMgr().getMax(id));
105126
}
106127

107128
/**
108129
* Commit decode properties to be saved in a persistent way across system reboot.
109130
* @returns {boolean} True if barcode properties have been successfully committed.
110131
*/
111132
commitProperties() {
112-
return _DLBarcodeMgr.commitProperties();
133+
return this.#getDLBarcodeMgr().commitProperties();
113134
}
114135

115136
/**
@@ -118,35 +139,35 @@ class DLBcdMgr {
118139
* @returns {boolean} True if all symbologies have been successfully enabled/disabled.
119140
*/
120141
enableAllSymbologies(enable) {
121-
return _DLBarcodeMgr.enableAllSymbologies(enable);
142+
return this.#getDLBarcodeMgr().enableAllSymbologies(enable);
122143
}
123144

124145
/**
125146
* Set decode properties to system defaults.
126147
* @returns {boolean} True if all decode properties have been successfully set to default values.
127148
*/
128149
setDefaults() {
129-
return _DLBarcodeMgr.setDefaults();
150+
return this.#getDLBarcodeMgr().setDefaults();
130151
}
131152

132153
/**
133154
* Checks if the Scanner Service is correctly initialized.
134155
* @returns {boolean} True if the Scanner Service is correctly initialized.
135156
*/
136157
isInitialized() {
137-
return _DLBarcodeMgr.isInitialized();
158+
return this.#getDLBarcodeMgr().isInitialized();
138159
}
139160

140161
/**
141-
* Attach a callback function to the scan event.
162+
* Attach a callback function to the scan event.
142163
* @param {(scan: {id: number, rawData: string, text: string}) => void} callback function to be called when a scan event occurs. Scan results passed as an argument with the following parameters:
143164
* * id - Represents the scanned symbology. Name of symbology can be retrieved from the {@link SymIds} object.
144165
* * rawData - Byte data from the scan.
145166
* * text - The readable text of the barcode scanned.
146167
* @returns {boolean} True if a scan listener has been successfully added.
147168
*/
148169
onScan(callback) {
149-
let success = _DLBarcodeMgr.addReadListener();
170+
let success = this.#getDLBarcodeMgr().addReadListener();
150171
window.addEventListener('scan', function(event) {
151172
callback(event.detail.scan);
152173
});
@@ -158,7 +179,7 @@ class DLBcdMgr {
158179
* @returns {boolean} True if the read listener has been successfully removed.
159180
*/
160181
ignoreScan() {
161-
return _DLBarcodeMgr.removeReadListener();
182+
return this.#getDLBarcodeMgr().removeReadListener();
162183
}
163184

164185
/**
@@ -167,7 +188,7 @@ class DLBcdMgr {
167188
* @returns {boolean} True if a timeout listener has been successfully added.
168189
*/
169190
onTimeout(callback) {
170-
let success = _DLBarcodeMgr.addTimeoutListener();
191+
let success = this.#getDLBarcodeMgr().addTimeoutListener();
171192
window.addEventListener('timeout', callback);
172193
return success;
173194
}
@@ -177,7 +198,7 @@ class DLBcdMgr {
177198
* @returns {boolean} True if the timeout listener has been successfully removed.
178199
*/
179200
ignoreTimeout() {
180-
return _DLBarcodeMgr.removeTimeoutListener();
201+
return this.#getDLBarcodeMgr().removeTimeoutListener();
181202
}
182203

183204
/**
@@ -187,10 +208,10 @@ class DLBcdMgr {
187208
*/
188209
startDecode(timeout) {
189210
if (typeof timeout === 'undefined') {
190-
return _DLBarcodeMgr.startDecode(5000);
211+
return this.#getDLBarcodeMgr().startDecode(5000);
191212
}
192213
else {
193-
return _DLBarcodeMgr.startDecode(timeout);
214+
return this.#getDLBarcodeMgr().startDecode(timeout);
194215
}
195216
}
196217

@@ -199,7 +220,7 @@ class DLBcdMgr {
199220
* @returns {boolean} True if decoding has successfully stopped, or the scanner is not actively decoding.
200221
*/
201222
stopDecode() {
202-
return _DLBarcodeMgr.stopDecode();
223+
return this.#getDLBarcodeMgr().stopDecode();
203224
}
204225
};
205226

lib/dl_keyboard.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
// Interface for keyboard functions.
22

3-
const DL_KEYBOARD_MGR_VER = 1;
3+
const DL_KEYBOARD_MGR_VER = 2;
44

55
class DLKbdMgr {
6+
/**
7+
* Private method to return an instance of DLKeyboardMgr.
8+
* @returns {DLKbdMgr} An instance of DLKbdMgr.
9+
* @throws {ReferenceError} If _DLKeyboardMgr is not injected by Datalogic Enterprise Browser.
10+
*/
11+
#getDLKeybardMgr() {
12+
try {
13+
return _DLKeyboardMgr;
14+
} catch(e) {
15+
throw ReferenceError("_DLKeyboardMgr has not been injected by Datalogic Enterprise Browser");
16+
}
17+
}
18+
619
/**
720
* Enable/disable all triggers on the device.
821
* @param {boolean} enable Enable/disable all triggers.
922
* @returns {boolean} True if all triggers on the device have been successfully enabled/disabled.
1023
*/
1124
enableTriggers(enable) {
12-
return _DLKeyboardMgr.enableTriggers(enable);
25+
return this.#getDLKeybardMgr().enableTriggers(enable);
1326
}
1427
}
1528

0 commit comments

Comments
 (0)