Skip to content

Commit e228221

Browse files
committed
some updates
1 parent 935347e commit e228221

File tree

7 files changed

+45
-32
lines changed

7 files changed

+45
-32
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</head>
1111

1212
<body>
13+
Loading...
1314
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
1415
<script>
1516
/** LICENSE ALERT - README
@@ -28,17 +29,17 @@
2829
window.onload = async function() {
2930
try {
3031
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
31-
/*
32-
* onFrameRead is triggered after the library finishes reading a frame.
33-
* There can be multiple barcodes on one frame.
32+
/**
33+
* onFrameRead is triggered after the library finishes reading a frame image.
34+
* There can be multiple barcodes on one image.
3435
*/
3536
scanner.onFrameRead = results => {
3637
console.log("Barcodes on one frame:");
3738
for (let result of results) {
3839
console.log(result.barcodeFormatString + ": " + result.barcodeText);
3940
}
4041
};
41-
/*
42+
/**
4243
* onUniqueRead is triggered only when a 'new' barcode is found.
4344
* The amount of time that the library 'remembers' a barcode is defined by
4445
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
@@ -47,6 +48,10 @@
4748
alert(txt);
4849
console.log("Unique Code Found: ", result);
4950
}
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+
*/
5055
await scanner.show();
5156
} catch (ex) {
5257
throw ex;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<body>
1414
<h1 style="font-size: 1.5em;">Hello World for PWA</h1>
15-
<button id='readBarcode'>Read Barcode via Camera</button>
15+
Loading...
1616
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
1717
<script>
1818
/** LICENSE ALERT - README
@@ -30,7 +30,7 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
3030

3131
let pScanner = null;
3232
let latestResult = null;
33-
document.getElementById('readBarcode').onclick = async function() {
33+
window.onload = async function() {
3434
Notification.requestPermission().then((result) => {
3535
if (result === 'granted') {
3636
startNotificationLoop();
@@ -46,7 +46,6 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
4646
};
4747
scanner.onUniqueRead = (txt, result) => {
4848
latestResult = txt;
49-
alert(txt, result);
5049
}
5150
await scanner.show();
5251
} catch (ex) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<body>
1212
<h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
13-
<button id="readBarcode">show scanner</button>
13+
Loading...
1414
<script src="https://cdn.jsdelivr.net/npm/requirejs@2.3.6/require.js"></script>
1515
<script>
1616
requirejs(['https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js'], function({
@@ -32,7 +32,7 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
3232

3333
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/";
3434
let pScanner = null;
35-
document.getElementById('readBarcode').onclick = async function() {
35+
window.onload = async function() {
3636
try {
3737
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
3838
scanner.onFrameRead = results => {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</head>
1111

1212
<body>
13-
<h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
14-
<button id="btn-show-scanner">Show Barcode Scanner</button>
13+
<h1 style="font-size: 1.5em;">Hello World for ES6</h1>
14+
Loading...
1515
<script type="module">
1616
import { BarcodeReader, BarcodeScanner } from 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.mjs';
1717
/** LICENSE ALERT - README
@@ -30,7 +30,7 @@ <h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
3030
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/";
3131

3232
let pScanner = null;
33-
document.getElementById('btn-show-scanner').addEventListener('click', async () => {
33+
window.onload = async () => {
3434
try {
3535
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
3636
/*
@@ -57,7 +57,7 @@ <h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
5757
alert(ex.message);
5858
throw ex;
5959
}
60-
});
60+
};
6161
</script>
6262
</body>
6363

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@
1212
<body>
1313
<div style="width:80vw;margin:0 auto;">
1414
<h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
15-
<input id="ipt-file" type="file" accept="image/png,image/jpeg,image/bmp,image/gif">
15+
<input id="ipt-file" type="file" accept="image/png,image/jpeg,image/bmp,image/gif" disabled="disabled">
1616
<input id="ipt-readonly-last-result" title="Double click to clear!" readonly placeholder="The Last Read Barcode" style="width:80vw;margin-top:20px;">
17-
<p id='p-loading' style='font-size:1.5em'>Loading Library...</p>
17+
<p id='p-loading' style='font-size:1.5em'>Loading...</p>
1818
<p id='p-reading' style='font-size:1.5em;display:none;'>Reading Barcodes...</p>
1919
<div id="div-cvs-container" style="width:80vw;height:40vh;margin-top:20px;display:flex;justify-content:center;"></div>
2020
<p>All Results:</p>
2121
<div id="div-results" style="width:80vw;height:15vh;padding:16px;overflow-y:auto;border: 1px dashed grey;"></div>
2222
</div>
2323
<style>
24-
.sp-resultText { color: #cE5E04 }
25-
#div-cvs-container canvas { border: solid 1px gray; }
24+
.sp-resultText {
25+
color: #cE5E04
26+
}
27+
28+
#div-cvs-container canvas {
29+
border: solid 1px gray;
30+
}
2631
</style>
2732
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.0.0/dist/dbr.js"></script>
2833
<script>
@@ -43,9 +48,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
4348
(async() => {
4449
try {
4550
await Dynamsoft.DBR.BarcodeReader.loadWasm();
46-
document.getElementById('p-loading').style.display = 'none';
51+
document.getElementById('p-loading').innerText = "Library loaded and ready!"
52+
document.getElementById('ipt-file').disabled = false;
53+
setTimeout(function() {
54+
document.getElementById('p-loading').style.display = 'none';
55+
}, 1000);
4756
} catch (ex) {
48-
alert(ex.message);
57+
document.getElementById('p-loading').innerText = ex;
58+
document.getElementById('ipt-file').disabled = true;
4959
throw ex;
5060
}
5161
})();
@@ -70,7 +80,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
7080
// show image
7181
divCvsContainer.innerHTML = '';
7282
divCvsContainer.appendChild(reader.getOriginalImageInACanvas());
73-
83+
7484
// show results
7585
divResults.appendChild(createEl('h3', file.name + ": "));
7686
if (0 === results.length) {
@@ -90,7 +100,6 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
90100
divResults.appendChild(document.createElement('hr'));
91101
divResults.scrollTop = divResults.scrollHeight;
92102
} catch (ex) {
93-
alert(ex.message);
94103
throw ex;
95104
} finally {
96105
pReading.style.display = 'none';
@@ -105,7 +114,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
105114
function createEl(type, txt, className) {
106115
const el = document.createElement(type);
107116
el.textContent = txt;
108-
if (className){
117+
if (className) {
109118
el.className = className;
110119
}
111120
return el;

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository contains multiple samples that demonstrates how to use the [Dyna
66

77
Get the basic features of the library working with plain/native JavaScript or within a framework like [Angular](https://angular.io/), [React](https://reactjs.org/) or [Vue](https://vuejs.org/), etc.
88

9-
* **Simplest Implementation**: Minimum necessary JavaScript code to get the BarcodeScanner (video) up and running.
9+
* **Hello World**: Minimum necessary JavaScript code to get the BarcodeScanner (video) up and running.
1010
* **Read an Existing Image**: Decode barcodes using images that are stored locally, whether on mobile or desktop.
1111
* **Hello World in Angular**: Decode video stream in an Angular Application from a USB-connected or built-in camera (mobile or desktop).
1212
* **Hello World in React**: Decode video stream in a React Application from a USB-connected or built-in camera (mobile or desktop).
@@ -22,9 +22,9 @@ Get the basic features of the library working with plain/native JavaScript or wi
2222
## Customize Camera UI
2323

2424
* **Use the Default Camera UI**: Show the default camera UI to decode video stream from a USB-connected or built-in camera (mobile or desktop).
25-
* **Hide Built-in Controllers**: Hide built-in UI elements (camera selection, resolution selection, etc.) and show only the video stream.
26-
* **Use External Controllers**: Use custom controllers to manipulate the Camera UI.
27-
* **Enlarge the Video Stream**: Enlarge the video stream temporarily to read a barcode.
25+
* **Hide Display Controls**: Hide built-in UI elements (camera selection, resolution selection, etc.) and show only the video stream.
26+
* **Set up External Controls**: Use custom controllers to manipulate the Camera UI.
27+
* **Changing Size of Video Viewer**: Enlarge the video stream temporarily to read a barcode.
2828
* **Customize the Camera UI**: Show the custom camera UI to decode video stream from a USB-connected or built-in camera (mobile or desktop).
2929

3030
## Parameter Settings
@@ -48,4 +48,6 @@ Use cases of the library.
4848

4949
* **Debug**: Collect the actual image frames for debugging purposes.
5050

51-
If you have any questions with these samples, feel free to submit an issue or [contact us](https://www.dynamsoft.com/company/contact/).
51+
## Support
52+
53+
If you have any questions, feel free to contact Dynamsoft support via [email](mailto:support@dynamsoft.com) or [live chat](https://www.dynamsoft.com/barcode-reader/overview/) via the "Let's Chat" button.

index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ <h3>Barcode Reader Samples</h3>
1919
<div class="file">Hello World</div>
2020
<div class="children">
2121
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Minimum necessary JavaScript code to get
22-
the BarcodeScanner (video) up and running." class="button title" href="1.hello-world/1.hello-world.html">Simplest
23-
Implementation</a><span id="icon001" class="tooltipIcon"></span>
22+
the BarcodeScanner (video) up and running." class="button title" href="1.hello-world/1.hello-world.html">Hello World</a><span id="icon001" class="tooltipIcon"></span>
2423
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/master/1.hello-world/1.hello-world.html" title="Check code on GitHub"></a>
2524
</div>
2625
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode barcodes
@@ -45,7 +44,6 @@ <h3>Barcode Reader Samples</h3>
4544
<span id="icon004" class="tooltipIcon"></span>
4645
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/master/1.hello-world/4.read-video-react" title="Check code on GitHub"></a>
4746
</div>
48-
4947
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode video stream in a Vue 2
5048
Application from a USB-connected or built-in camera (mobile or desktop)." class="button title" href="1.hello-world/5.read-video-vue/dist/">
5149
Hello World in
@@ -119,12 +117,12 @@ <h3>Barcode Reader Samples</h3>
119117
PWA</a><span id="icon010" class="tooltipIcon"></span>
120118
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/master/1.hello-world/10.read-video-pwa" title="Check code on GitHub"></a>
121119
</div>
122-
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode video stream from a USB-connected or built-in camera (mobile or desktop) in a web application that uses RequireJS." class="button title" target="_blank" href="https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-requirejs.html">Hello
120+
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode video stream from a USB-connected or built-in camera (mobile or desktop) in a web application that uses RequireJS." class="button title" href="1.hello-world/11.read-video-requirejs.html">Hello
123121
World with
124122
RequireJS</a><span id="icon011" class="tooltipIcon"></span>
125123
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/master/1.hello-world/11.hello-world-requirejs.html" title="Check code on GitHub"></a>
126124
</div>
127-
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode video stream from a USB-connected or built-in camera (mobile or desktop) in a web application that uses ES6." class="button title" target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/1.hello-world/12.read-video-es6.html">Hello
125+
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Decode video stream from a USB-connected or built-in camera (mobile or desktop) in a web application that uses ES6." class="button title" href="1.hello-world/12.read-video-es6.html">Hello
128126
World with
129127
ES6</a><span id="icon012" class="tooltipIcon"></span>
130128
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/master/1.hello-world/12.read-video-es6.html" title="Check code on GitHub"></a>

0 commit comments

Comments
 (0)