Skip to content
Merged

Dev #47

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions 1.hello-world/1.hello-world.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,26 @@
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
*/
scanner.onUniqueRead = (txt, result) => {
alert(txt);
console.log("Unique Code Found: ", result);
}
/**
* show() opens the camera and shows the video stream on the page.
* After that, the library starts to scan the frame images continuously.
*/
alert(txt);
console.log("Unique Code Found: ", result);
}
/**
* show() opens the camera and shows the video stream on the page.
* After that, the library starts to scan the frame images continuously.
*/
await scanner.show();
} catch (ex) {
alert(ex);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
})();
</script>
</body>

</html>
</html>
10 changes: 8 additions & 2 deletions 1.hello-world/10.read-video-pwa/helloworld-pwa.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
}
await scanner.show();
} catch (ex) {
alert(ex.message);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
})();

Expand Down
10 changes: 8 additions & 2 deletions 1.hello-world/11.read-video-requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
}
await scanner.show();
} catch (ex) {
alert(ex.message);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
})();
})
Expand Down
10 changes: 8 additions & 2 deletions 1.hello-world/12.read-video-es6.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
}
await scanner.show();
} catch (ex) {
alert(ex.message);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
})();
</script>
Expand Down
20 changes: 16 additions & 4 deletions 1.hello-world/2.read-an-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
} catch (ex) {
document.getElementById('p-loading').innerText = ex;
document.getElementById('ipt-file').disabled = true;
alert(ex);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
})();

Expand Down Expand Up @@ -101,8 +107,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
divResults.appendChild(document.createElement('hr'));
divResults.scrollTop = divResults.scrollHeight;
} catch (ex) {
alert(ex);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
} finally {
pReading.style.display = 'none';
this.value = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ export class VideoDecodeComponent implements OnInit {
};
await scanner.open();
} catch (ex) {
alert(ex);
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
}
async ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ export class HelloWorldComponent implements OnInit {
try {
await BarcodeScanner.loadWasm();
} catch (ex) {
alert(ex.message);
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
}
showScanner(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import {BarcodeReader} from 'dynamsoft-javascript-barcode'
import { BarcodeReader } from 'dynamsoft-javascript-barcode'

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

async ngOnInit(): Promise<void> {}
async ngOnInit(): Promise<void> { }

decodeImg = async (e: any) => {
try {
Expand All @@ -18,9 +18,16 @@ export class ImgDecodeComponent implements OnInit {
for (const result of results) {
alert(result.barcodeText);
}
if(!results.length){ alert('No barcode found'); }
if (!results.length) { alert('No barcode found'); }
} catch (ex) {
alert(ex);
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
e.target.value = '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class HelloWorld extends React.Component {
try {
await BarcodeReader.loadWasm();
} catch (ex) {
alert(ex);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
}

Expand All @@ -36,14 +42,14 @@ class HelloWorld extends React.Component {
bShowImgDecode: true
});
}

render() {
return (
<div className="helloWorld">
<h1>Hello World for React<img src={reactLogo} className="App-logo" alt="logo" /></h1>
<div className="btn-group">
<button style={{marginRight: '10px', backgroundColor: this.state.bShowScanner ? 'rgb(255,174,55)' : 'white'}} onClick={this.showScanner}>Video Decode</button>
<button style={{backgroundColor: this.state.bShowImgDecode ? 'rgb(255,174,55)' : 'white'}} onClick={this.showImgDecode}>Image Decode</button>
<button style={{ marginRight: '10px', backgroundColor: this.state.bShowScanner ? 'rgb(255,174,55)' : 'white' }} onClick={this.showScanner}>Video Decode</button>
<button style={{ backgroundColor: this.state.bShowImgDecode ? 'rgb(255,174,55)' : 'white' }} onClick={this.showImgDecode}>Image Decode</button>
</div>
<div className="container">
{this.state.bShowScanner ? (<VideoDecode></VideoDecode>) : ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ export default class ImgDecode extends Component {
try {
const reader = await (this.pReader = this.pReader || BarcodeReader.createInstance());
let results = await reader.decode(e.target.files[0]);
for(let result of results){
for (let result of results) {
alert(result.barcodeText);
}
if(!results.length){ alert('No barcode found'); }
} catch(ex) {
alert(ex);
if (!results.length) { alert('No barcode found'); }
} catch (ex) {
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
e.target.value = '';
}
Expand All @@ -31,7 +38,7 @@ export default class ImgDecode extends Component {

render() {
return (
<div className="ImgDecode"><input type="file" onChange={this.decodeImg}/></div>
<div className="ImgDecode"><input type="file" onChange={this.decodeImg} /></div>
)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions 1.hello-world/5.read-video-vue/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<div class="helloWorld">
<h1>Hello World for Vue<img class="applogo" alt="Vue logo" src="../assets/logo.png" /></h1>
<div class="btn-group">
<button :style="{marginRight: '10px', backgroundColor: bShowScanner ? 'rgb(255,174,55)' : 'white'}" @click="showScanner">Video Decode</button>
<button :style="{backgroundColor: bShowImgDecode ? 'rgb(255,174,55)' : 'white'}" @click="showImgDecode">Image Decode</button>
<button :style="{ marginRight: '10px', backgroundColor: bShowScanner ? 'rgb(255,174,55)' : 'white' }"
@click="showScanner">Video Decode</button>
<button :style="{ backgroundColor: bShowImgDecode ? 'rgb(255,174,55)' : 'white' }" @click="showImgDecode">Image
Decode</button>
</div>
<div class="container">
<VideoDecode v-if="bShowScanner"></VideoDecode>
Expand Down Expand Up @@ -31,8 +33,14 @@ export default {
try {
await BarcodeReader.loadWasm();
} catch (ex) {
alert(ex.message);
throw ex;
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
},
components: {
Expand Down Expand Up @@ -61,15 +69,19 @@ ul {
list-style-type: none;
padding: 0;
}

li {
margin: 0 10px;
}

a {
color: #42b983;
}

.applogo {
height: 25px;
}

.helloWorld {
display: flex;
flex-direction: column;
Expand Down
33 changes: 20 additions & 13 deletions 1.hello-world/5.read-video-vue/src/components/ImgDecode.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="ImgDecode"><input type="file" @change="decodeImg"/></div>
<div class="ImgDecode"><input type="file" @change="decodeImg" /></div>
</template>

<script>
Expand All @@ -16,12 +16,19 @@ export default {
try {
const reader = await (this.pReader = this.pReader || BarcodeReader.createInstance());
let results = await reader.decode(e.target.files[0]);
for(let result of results){
for (let result of results) {
alert(result.barcodeText);
}
if(!results.length){ alert('No barcode found'); }
} catch(ex) {
alert(ex);
if (!results.length) { alert('No barcode found'); }
} catch (ex) {
let errMsg;
if (ex.message.includes("network connection error")) {
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.";
} else {
errMsg = ex.message||ex;
}
console.error(errMsg);
alert(errMsg);
}
e.target.value = '';
}
Expand All @@ -36,12 +43,12 @@ export default {
</script>

<style scoped>
.ImgDecode {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 90%;
border: 1px solid black
}
.ImgDecode {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 90%;
border: 1px solid black
}
</style>
Loading