Skip to content

Commit ff53589

Browse files
committed
review a little
1 parent 633bf0c commit ff53589

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
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">
99
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
10-
<!--
11-
This sample makes use of the library hosted by the CDN jsDelivr. If you would rather use the
12-
library offline. Please see the guide on how to host the library:
13-
https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=latest&utm_source=github#host-the-library-yourself-recommended
14-
-->
1510
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
1611
</head>
1712

@@ -30,13 +25,18 @@ <h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
3025

3126
// Dynamsoft.DBR.BarcodeReader.license = "YOUR-ORGANIZATION-ID or YOUR-HANDSHAKECODE or AN-OFFLINE-LICENSE or ANY-OTHER-TYPE-OF-SUPPORTED-LICENSE-STRING";
3227

28+
29+
30+
31+
32+
3333
let pScanner = null;
3434
document.getElementById('btn-show-scanner').onclick = async function() {
3535
try {
3636
const scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
3737
/*
3838
* onFrameRead is triggered after the library finishes reading a frame.
39-
* There can be one or multiple barcodes on each frame.
39+
* There can be multiple barcodes on one frame.
4040
*/
4141
scanner.onFrameRead = results => {
4242
console.log("Barcodes on one frame:");

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
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-
<!--
11-
This sample makes use of the library hosted by the CDN jsDelivr. If you would rather use the
12-
library offline. Please see the guide on how to host the library:
13-
https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=latest&utm_source=github#host-the-library-yourself-recommended
14-
-->
1510
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
1611
</head>
1712

@@ -20,12 +15,12 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
2015
<input id="ipt-file" type="file" style="margin-bottom: 2vh;" accept="image/png,image/jpeg,image/bmp,image/gif">
2116
<input type="text" id="result" title="Double click to clear!" readonly="true" class="latest-result" placeholder="The Last Read Barcode">
2217
<div id="UIElement">
23-
<img id="imgToRead" alt="Image to read" hidden /><br />
24-
<span id='lib-load' style='font-size:x-large' hidden>Loading Library...</span>
25-
<span id='reading' style='font-size:x-large;max-height: 10%;' hidden>Reading Barcodes...</span>
18+
<img id="imgToRead" alt="Image to read" hidden /><br>
19+
<span id='lib-load' style='font-size:1.5em'>Loading Library...</span>
20+
<span id='reading' style='font-size:1.5em;display:none;'>Reading Barcodes...</span>
2621
</div>
2722
<div>
28-
<span style="float:left">All Results:</span><br />
23+
<span>All Results:</span><br>
2924
<div id="results"></div>
3025
</div>
3126
<script>
@@ -40,25 +35,31 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
4035

4136
// Dynamsoft.DBR.BarcodeReader.license = "YOUR-ORGANIZATION-ID or YOUR-HANDSHAKECODE or AN-OFFLINE-LICENSE or ANY-OTHER-TYPE-OF-SUPPORTED-LICENSE-STRING";
4237

43-
// reader for decoding pictures
44-
let pReader = null;
45-
window.onload = async function() {
46-
// Load the library on page load to speed things up.
38+
39+
40+
41+
// Load the library on page load to speed things up.
42+
(async()=>{
4743
try {
4844
await Dynamsoft.DBR.BarcodeReader.loadWasm();
45+
document.getElementById('lib-load').style.display = 'none';
4946
} catch (ex) {
5047
alert(ex.message);
5148
throw ex;
5249
}
53-
};
50+
})();
51+
52+
53+
54+
55+
// reader for decoding pictures
56+
let pReader = null;
5457
document.getElementById('ipt-file').addEventListener('change', async function() {
5558
try {
5659
document.getElementById("imgToRead").hidden = true;
57-
document.getElementById('lib-load').hidden = false;
5860
pReader = pReader || Dynamsoft.DBR.BarcodeReader.createInstance();
5961
let reader = await pReader;
60-
document.getElementById('lib-load').hidden = true;
61-
document.getElementById('reading').hidden = false;
62+
document.getElementById('reading').style.display = '';
6263
for (let i = 0; i < this.files.length; ++i) {
6364
// In our case, there will only be one file here (no 'multiple' attribute)
6465
let file = this.files[i];
@@ -97,7 +98,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
9798
}
9899
document.getElementById('results').scrollTop = document.getElementById('results').scrollHeight;
99100
}
100-
document.getElementById('reading').hidden = true;
101+
document.getElementById('reading').style.display = 'none';
101102
} catch (ex) {
102103
alert(ex.message);
103104
throw ex;

0 commit comments

Comments
 (0)