Skip to content

Commit 8ac57f7

Browse files
committed
Merge branch '_dev'
2 parents 86bf17e + 596530a commit 8ac57f7

File tree

58 files changed

+749
-1043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+749
-1043
lines changed

1.hello-world/1.minimum-code.html

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
77
<meta name="description" content="Quickly read barcodes with Dynamsoft Barcode Reader from a live camera stream.">
88
<meta name="keywords" content="camera based barcode reading">
9+
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/1.hello-world/1.hello-world.html">
910
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
1011
</head>
1112

1213
<body>
1314
Loading...
14-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
15+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/dbr.js"></script>
1516
<script>
1617
/** LICENSE ALERT - README
1718
* To use the library, you need to first specify a license key using the API "license" as shown below.
@@ -22,11 +23,11 @@
2223
/**
2324
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
2425
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
25-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
26+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
2627
* LICENSE ALERT - THE END
2728
*/
2829

29-
window.onload = async function() {
30+
(async function() {
3031
try {
3132
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
3233
/**
@@ -45,19 +46,26 @@
4546
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
4647
*/
4748
scanner.onUniqueRead = (txt, result) => {
48-
alert(txt);
49-
console.log("Unique Code Found: ", result);
50-
}
51-
/**
52-
* show() opens the camera and shows the video stream on the page.
53-
* After that, the library starts to scan the frame images continuously.
54-
*/
49+
alert(txt);
50+
console.log("Unique Code Found: ", result);
51+
}
52+
/**
53+
* show() opens the camera and shows the video stream on the page.
54+
* After that, the library starts to scan the frame images continuously.
55+
*/
5556
await scanner.show();
5657
} catch (ex) {
57-
throw ex;
58+
let errMsg;
59+
if (ex.message.includes("network connection error")) {
60+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
61+
} else {
62+
errMsg = ex.message||ex;
63+
}
64+
console.error(errMsg);
65+
alert(errMsg);
5866
}
59-
};
67+
})();
6068
</script>
6169
</body>
6270

63-
</html>
71+
</html>

1.hello-world/10.read-video-pwa/helloworld-pwa.html

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
<meta name="description" content="Read barcodes from camera with Dynamsoft Barcode Reader in a PWA application.">
88
<meta name="keywords" content="read barcode from camera in PWA">
99
<title>Dynamsoft Barcode Reader PWA Sample - Hello World (Decoding via Camera)</title>
10+
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/1.hello-world/10.read-video-pwa/helloworld-pwa.html">
1011
<link rel="manifest" href="./helloworld-pwa.json">
1112
</head>
1213

1314
<body>
1415
<h1 style="font-size: 1.5em;">Hello World for PWA</h1>
1516
Loading...
16-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
17+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/dbr.js"></script>
1718
<script>
1819
/** LICENSE ALERT - README
1920
* To use the library, you need to first specify a license key using the API "license" as shown below.
@@ -24,13 +25,27 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
2425
/**
2526
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
2627
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
27-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
28+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
2829
* LICENSE ALERT - THE END
2930
*/
3031

3132
let pScanner = null;
3233
let latestResult = null;
33-
window.onload = async function() {
34+
35+
function startNotificationLoop() {
36+
if (latestResult != null) {
37+
const title = "New Barcode Found!";
38+
const notifBody = `Barcode Text: ${latestResult}.`;
39+
const options = {
40+
body: notifBody,
41+
};
42+
new Notification(title, options);
43+
latestResult = null;
44+
}
45+
setTimeout(startNotificationLoop, 100);
46+
}
47+
48+
(async function() {
3449
Notification.requestPermission().then((result) => {
3550
if (result === 'granted') {
3651
startNotificationLoop();
@@ -49,27 +64,21 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
4964
}
5065
await scanner.show();
5166
} catch (ex) {
52-
alert(ex.message);
53-
throw ex;
54-
}
55-
};
56-
57-
function startNotificationLoop() {
58-
if (latestResult != null) {
59-
const title = "New Barcode Found!";
60-
const notifBody = `Barcode Text: ${latestResult}.`;
61-
const options = {
62-
body: notifBody,
63-
};
64-
new Notification(title, options);
65-
latestResult = null;
67+
let errMsg;
68+
if (ex.message.includes("network connection error")) {
69+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
70+
} else {
71+
errMsg = ex.message||ex;
72+
}
73+
console.error(errMsg);
74+
alert(errMsg);
6675
}
67-
setTimeout(startNotificationLoop, 100);
68-
}
76+
})();
77+
6978
if ('serviceWorker' in navigator) {
7079
navigator.serviceWorker.register('./service-worker.js');
7180
};
7281
</script>
7382
</body>
7483

75-
</html>
84+
</html>

1.hello-world/11.read-video-requirejs.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
1313
Loading...
1414
<script src="https://cdn.jsdelivr.net/npm/requirejs@2.3.6/require.js"></script>
1515
<script>
16-
requirejs(['https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js'], function({
16+
requirejs(['https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/dbr.js'], function({
1717
BarcodeReader,
1818
BarcodeScanner
1919
}) {
@@ -26,13 +26,13 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
2626
/**
2727
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
2828
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
29-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
29+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
3030
* LICENSE ALERT - THE END
3131
*/
3232

33-
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/";
33+
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/";
3434
let pScanner = null;
35-
window.onload = async function() {
35+
(async function() {
3636
try {
3737
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
3838
scanner.onFrameRead = results => {
@@ -47,12 +47,18 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
4747
}
4848
await scanner.show();
4949
} catch (ex) {
50-
alert(ex.message);
51-
throw ex;
50+
let errMsg;
51+
if (ex.message.includes("network connection error")) {
52+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
53+
} else {
54+
errMsg = ex.message||ex;
55+
}
56+
console.error(errMsg);
57+
alert(errMsg);
5258
}
53-
};
59+
})();
5460
})
5561
</script>
5662
</body>
5763

58-
</html>
64+
</html>

1.hello-world/12.read-video-es6.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
77
<meta name="description" content="Quickly read barcodes with Dynamsoft Barcode Reader from a live camera stream.">
88
<meta name="keywords" content="camera based barcode reading">
9-
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
9+
<title>Dynamsoft Barcode Reader Sample - Hello World (Read Video)</title>
1010
</head>
1111

1212
<body>
1313
<h1 style="font-size: 1.5em;">Hello World for ES6</h1>
1414
Loading...
1515
<script type="module">
16-
import { BarcodeReader, BarcodeScanner } from 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.mjs';
16+
import { BarcodeReader, BarcodeScanner } from 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/dbr.mjs';
1717
/** LICENSE ALERT - README
1818
* To use the library, you need to first specify a license key using the API "license" as shown below.
1919
*/
@@ -23,14 +23,14 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
2323
/**
2424
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
2525
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
26-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
26+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
2727
* LICENSE ALERT - THE END
2828
*/
2929

30-
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/";
30+
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/";
3131

3232
let pScanner = null;
33-
window.onload = async () => {
33+
(async () => {
3434
try {
3535
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
3636
/*
@@ -54,11 +54,17 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
5454
}
5555
await scanner.show();
5656
} catch (ex) {
57-
alert(ex.message);
58-
throw ex;
57+
let errMsg;
58+
if (ex.message.includes("network connection error")) {
59+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
60+
} else {
61+
errMsg = ex.message||ex;
62+
}
63+
console.error(errMsg);
64+
alert(errMsg);
5965
}
60-
};
66+
})();
6167
</script>
6268
</body>
6369

64-
</html>
70+
</html>

1.hello-world/2.read-an-image.html

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="description" content="Read barcodes from images in no time with Dynamsoft Barcode Reader. With this online demo, you can choose a file to scan the barcodes on them.">
88
<meta name="keywords" content="read barcode from still images">
99
<title>Dynamsoft Barcode Reader Sample - Read an Image</title>
10+
<link rel=“canonical” href=”https://demo.dynamsoft.com/Samples/DBR/JS/1.hello-world/2.read-an-image.html”/>
1011
</head>
1112

1213
<body>
@@ -29,7 +30,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
2930
border: solid 1px gray;
3031
}
3132
</style>
32-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
33+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/dbr.js"></script>
3334
<script>
3435
/** LICENSE ALERT - README
3536
* To use the library, you need to first specify a license key using the API "license" as shown below.
@@ -40,7 +41,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
4041
/**
4142
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
4243
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
43-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
44+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
4445
* LICENSE ALERT - THE END
4546
*/
4647

@@ -56,7 +57,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
5657
} catch (ex) {
5758
document.getElementById('p-loading').innerText = ex;
5859
document.getElementById('ipt-file').disabled = true;
59-
throw ex;
60+
let errMsg;
61+
if (ex.message.includes("network connection error")) {
62+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
63+
} else {
64+
errMsg = ex.message||ex;
65+
}
66+
console.error(errMsg);
67+
alert(errMsg);
6068
}
6169
})();
6270

@@ -100,7 +108,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
100108
divResults.appendChild(document.createElement('hr'));
101109
divResults.scrollTop = divResults.scrollHeight;
102110
} catch (ex) {
103-
throw ex;
111+
let errMsg;
112+
if (ex.message.includes("network connection error")) {
113+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
114+
} else {
115+
errMsg = ex.message||ex;
116+
}
117+
console.error(errMsg);
118+
alert(errMsg);
104119
} finally {
105120
pReading.style.display = 'none';
106121
this.value = '';
@@ -122,4 +137,4 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
122137
</script>
123138
</body>
124139

125-
</html>
140+
</html>

1.hello-world/3.read-video-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@angular/platform-browser": "~11.2.5",
2020
"@angular/platform-browser-dynamic": "~11.2.5",
2121
"@angular/router": "~11.2.5",
22-
"dynamsoft-javascript-barcode": "9.0.0",
22+
"dynamsoft-javascript-barcode": "9.0.2",
2323
"rxjs": "~6.6.0",
2424
"tslib": "^2.0.0",
2525
"zone.js": "~0.11.3"

1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ export class VideoDecodeComponent implements OnInit {
2222
};
2323
await scanner.open();
2424
} catch (ex) {
25-
console.error(ex);
25+
let errMsg;
26+
if (ex.message.includes("network connection error")) {
27+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
28+
} else {
29+
errMsg = ex.message||ex;
30+
}
31+
console.error(errMsg);
32+
alert(errMsg);
2633
}
2734
}
2835
async ngOnDestroy() {
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { BarcodeReader } from 'dynamsoft-javascript-barcode';
22

3-
/** LICENSE ALERT - README
3+
/** LICENSE ALERT - README
44
* To use the library, you need to first specify a license key using the API "license" as shown below.
55
*/
66

77
BarcodeReader.license = 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9';
8-
9-
/**
10-
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
8+
9+
/**
10+
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
1111
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
12-
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.0&utm_source=github#specify-the-license or contact support@dynamsoft.com.
13-
* LICENSE ALERT - THE END
12+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.0.2&utm_source=github#specify-the-license or contact support@dynamsoft.com.
13+
* LICENSE ALERT - THE END
1414
*/
1515

16-
BarcodeReader.engineResourcePath = 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/';
16+
BarcodeReader.engineResourcePath = 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.2/dist/';

1.hello-world/3.read-video-angular/src/app/hello-world/hello-world.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ export class HelloWorldComponent implements OnInit {
1515
try {
1616
await BarcodeScanner.loadWasm();
1717
} catch (ex) {
18-
alert(ex.message);
18+
let errMsg;
19+
if (ex.message.includes("network connection error")) {
20+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
21+
} else {
22+
errMsg = ex.message||ex;
23+
}
24+
console.error(errMsg);
25+
alert(errMsg);
1926
}
2027
}
2128
showScanner(): void {

0 commit comments

Comments
 (0)