Skip to content

Commit a774ab9

Browse files
authored
Merge pull request #47 from Dynamsoft/_dev
Dev
2 parents 357e94d + a541eba commit a774ab9

33 files changed

Lines changed: 537 additions & 273 deletions

1.hello-world/1.hello-world.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,26 @@
4646
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
4747
*/
4848
scanner.onUniqueRead = (txt, result) => {
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-
*/
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+
*/
5656
await scanner.show();
5757
} catch (ex) {
58-
alert(ex);
59-
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);
6066
}
6167
})();
6268
</script>
6369
</body>
6470

65-
</html>
71+
</html>

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
6464
}
6565
await scanner.show();
6666
} catch (ex) {
67-
alert(ex.message);
68-
throw ex;
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);
6975
}
7076
})();
7177

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ <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
}
5359
})();
5460
})

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ <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
}
6066
})();
6167
</script>

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
5656
} catch (ex) {
5757
document.getElementById('p-loading').innerText = ex;
5858
document.getElementById('ipt-file').disabled = true;
59-
alert(ex);
60-
throw ex;
59+
let errMsg;
60+
if (ex.message.includes("network connection error")) {
61+
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.";
62+
} else {
63+
errMsg = ex.message||ex;
64+
}
65+
console.error(errMsg);
66+
alert(errMsg);
6167
}
6268
})();
6369

@@ -101,8 +107,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
101107
divResults.appendChild(document.createElement('hr'));
102108
divResults.scrollTop = divResults.scrollHeight;
103109
} catch (ex) {
104-
alert(ex);
105-
throw ex;
110+
let errMsg;
111+
if (ex.message.includes("network connection error")) {
112+
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.";
113+
} else {
114+
errMsg = ex.message||ex;
115+
}
116+
console.error(errMsg);
117+
alert(errMsg);
106118
} finally {
107119
pReading.style.display = 'none';
108120
this.value = '';

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-
alert(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() {

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 {

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import {BarcodeReader} from 'dynamsoft-javascript-barcode'
2+
import { BarcodeReader } from 'dynamsoft-javascript-barcode'
33

44
@Component({
55
selector: 'app-img-decode',
@@ -9,7 +9,7 @@ import {BarcodeReader} from 'dynamsoft-javascript-barcode'
99
export class ImgDecodeComponent implements OnInit {
1010
pReader = null;
1111

12-
async ngOnInit(): Promise<void> {}
12+
async ngOnInit(): Promise<void> { }
1313

1414
decodeImg = async (e: any) => {
1515
try {
@@ -18,9 +18,16 @@ export class ImgDecodeComponent implements OnInit {
1818
for (const result of results) {
1919
alert(result.barcodeText);
2020
}
21-
if(!results.length){ alert('No barcode found'); }
21+
if (!results.length) { alert('No barcode found'); }
2222
} catch (ex) {
23-
alert(ex);
23+
let errMsg;
24+
if (ex.message.includes("network connection error")) {
25+
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.";
26+
} else {
27+
errMsg = ex.message||ex;
28+
}
29+
console.error(errMsg);
30+
alert(errMsg);
2431
}
2532
e.target.value = '';
2633
}

1.hello-world/4.read-video-react/src/components/HelloWorld/HelloWorld.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ class HelloWorld extends React.Component {
1818
try {
1919
await BarcodeReader.loadWasm();
2020
} catch (ex) {
21-
alert(ex);
22-
throw ex;
21+
let errMsg;
22+
if (ex.message.includes("network connection error")) {
23+
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.";
24+
} else {
25+
errMsg = ex.message||ex;
26+
}
27+
console.error(errMsg);
28+
alert(errMsg);
2329
}
2430
}
2531

@@ -36,14 +42,14 @@ class HelloWorld extends React.Component {
3642
bShowImgDecode: true
3743
});
3844
}
39-
45+
4046
render() {
4147
return (
4248
<div className="helloWorld">
4349
<h1>Hello World for React<img src={reactLogo} className="App-logo" alt="logo" /></h1>
4450
<div className="btn-group">
45-
<button style={{marginRight: '10px', backgroundColor: this.state.bShowScanner ? 'rgb(255,174,55)' : 'white'}} onClick={this.showScanner}>Video Decode</button>
46-
<button style={{backgroundColor: this.state.bShowImgDecode ? 'rgb(255,174,55)' : 'white'}} onClick={this.showImgDecode}>Image Decode</button>
51+
<button style={{ marginRight: '10px', backgroundColor: this.state.bShowScanner ? 'rgb(255,174,55)' : 'white' }} onClick={this.showScanner}>Video Decode</button>
52+
<button style={{ backgroundColor: this.state.bShowImgDecode ? 'rgb(255,174,55)' : 'white' }} onClick={this.showImgDecode}>Image Decode</button>
4753
</div>
4854
<div className="container">
4955
{this.state.bShowScanner ? (<VideoDecode></VideoDecode>) : ""}

1.hello-world/4.read-video-react/src/components/ImgDecode/ImgDecode.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ export default class ImgDecode extends Component {
1212
try {
1313
const reader = await (this.pReader = this.pReader || BarcodeReader.createInstance());
1414
let results = await reader.decode(e.target.files[0]);
15-
for(let result of results){
15+
for (let result of results) {
1616
alert(result.barcodeText);
1717
}
18-
if(!results.length){ alert('No barcode found'); }
19-
} catch(ex) {
20-
alert(ex);
18+
if (!results.length) { alert('No barcode found'); }
19+
} catch (ex) {
20+
let errMsg;
21+
if (ex.message.includes("network connection error")) {
22+
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.";
23+
} else {
24+
errMsg = ex.message||ex;
25+
}
26+
console.error(errMsg);
27+
alert(errMsg);
2128
}
2229
e.target.value = '';
2330
}
@@ -31,7 +38,7 @@ export default class ImgDecode extends Component {
3138

3239
render() {
3340
return (
34-
<div className="ImgDecode"><input type="file" onChange={this.decodeImg}/></div>
41+
<div className="ImgDecode"><input type="file" onChange={this.decodeImg} /></div>
3542
)
3643
}
3744
}

0 commit comments

Comments
 (0)