Skip to content

Commit 931b1c2

Browse files
authored
Merge pull request #104 from Dynamsoft/_dev
8.8.3
2 parents de3126a + a86b95c commit 931b1c2

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

README.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ The complete code of the "Hello World" example is shown below
6565
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.js"></script>
6666
<script>
6767
// initializes and uses the library
68-
let pScanner = null;
6968
(async () => {
70-
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
69+
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
7170
scanner.onFrameRead = results => {
7271
if (results.length > 0) console.log(results);
7372
};
@@ -138,7 +137,7 @@ The simplest way to include the library is to use either the [jsDelivr](https://
138137
<script src="https://unpkg.com/[email protected]/dist/dbr.js"></script>
139138
```
140139

141-
#### Host the library yourself (recommended)
140+
#### Host the library yourself
142141

143142
Besides using the CDN, you can also download the library and host its files on your own website / server before including it in your application.
144143

@@ -163,7 +162,7 @@ The following shows a few ways to download the library.
163162
Depending on how you downloaded the library and where you put it. You can typically include it like this:
164163

165164
``` html
166-
<script src="/DBR-JS-8.8.3/dist/dbr.js"></script>
165+
<script src="/dbr-js-8.8.3/dist/dbr.js"></script>
167166
```
168167

169168
or
@@ -227,14 +226,27 @@ You can use one of two classes ( `BarcodeScanner` and `BarcodeReader` ) to inter
227226
To use the library, we first create a `BarcodeScanner` object.
228227

229228
``` javascript
230-
let scanner = null, pScanner = null;
229+
let scanner = null;
231230
try {
232-
scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
231+
scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
233232
} catch (ex) {
234233
console.error(ex);
235234
}
236235
```
237236

237+
When creating a `BarcodeScanner` object within a function which may be called more than once, it's best to use a "helper" variable to avoid double creation such as `pScanner` in the following code
238+
239+
``` javascript
240+
let scanner = null, pScanner = null;
241+
function createBarcodeScanner(){
242+
try {
243+
scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
244+
} catch (ex) {
245+
console.error(ex);
246+
}
247+
}
248+
```
249+
238250
*Note*:
239251

240252
* The creation of an object consists of two parallel tasks: one is to download and compile the "engine", the other is to fetch a license from Dynamsoft License Server (assuming an online license is used).
@@ -333,9 +345,8 @@ The built-in UI of the `BarcodeScanner` object is defined in the file `dist/dbr.
333345
<video class="dbrScanner-video" playsinline="true" style="width:100%;height:100%;position:absolute;left:0;top:0;"></video>
334346
</div>
335347
<script>
336-
let pScanner = null;
337348
(async()=>{
338-
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
349+
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
339350
await scanner.setUIElement(document.getElementById('div-video-container'));
340351
scanner.onFrameRead = results => {console.log(results);};
341352
scanner.onUnduplicatedRead = (txt, result) => {alert(txt);};
@@ -383,15 +394,12 @@ See also [UI customization samples](https://www.dynamsoft.com/barcode-reader/pro
383394

384395
Interested to test it further? Read on to learn how to request a 30-day free trial.
385396

386-
## Requesting A Trial
387-
388-
From version 8.2.5 of the library, if no license is specified, a [7-day free license](https://www.dynamsoft.com/license-server/docs/about/terms.html?ver=latest#public-trial-license?utm_source=github) will be used by default.
397+
## Requesting a Trial
389398

390-
> Network connection is required for the 7-day free license to work.
399+
You can request a 30-day free trial via the [customer portal](https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js). Or you can [contact our support team](https://www.dynamsoft.com/company/contact/?utm_source=github) to get a free trial license.
391400

392-
After that, if you want to evaluate the library further, you can [register for a Dynamsoft account](https://www.dynamsoft.com/api-common/Regist/Regist?utm_source=github) (if you haven't already done so) and request a 30-day trial in the [customer portal](https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js).
401+
Since v8.2.5, a 7-day free license is used by default if no license specified. Network connection is required for the default license to work.
393402

394-
* If you like, you can also [contact our support team](https://www.dynamsoft.com/company/contact/?utm_source=github) to get a trial license.
395403

396404
## System Requirements
397405

@@ -416,7 +424,7 @@ The following table is a list of supported browsers based on the above requireme
416424

417425
<sup>1</sup> iOS 14.3+ is required for camera video streaming in Chrome and Firefox or Apps using webviews.
418426

419-
<sup>2</sup> On Edge, due to strict Same-origin policy, you must host the library files on the same domain as your web page.
427+
<sup>2</sup> On legacy Edge (v16 ~ v78), due to strict Same-origin policy, you must host the library files on the same domain as your web page.
420428

421429
<sup>3</sup> Safari 11.2.2 ~ 11.2.6 are not supported.
422430

@@ -429,7 +437,7 @@ Apart from the browsers, the operating systems may impose some limitations of th
429437
Once you have downloaded the library, you can locate the "dist" directory and copy it to your server (usually as part of your website / web application). The following shows some of the files in this directory:
430438

431439
* `dbr.js` // The main library file
432-
* `dbr.browser.mjs` // For using the library as a module (`<script type="module">`)
440+
* `dbr.mjs` // For using the library as a module (`<script type="module">`)
433441
* `dbr.scanner.html` // Defines the default scanner UI
434442
* `dbr-<version>.worker.js` // Defines the worker thread for barcode reading
435443
* `dbr-<version>.wasm.js` // Compact edition of the library (.js)
@@ -445,9 +453,9 @@ Once you have downloaded the library, you can locate the "dist" directory and co
445453
446454
Different types of webservers are configured differently, for example:
447455
448-
+ [Apache](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess)
456+
+ [Apache](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess#media_types_and_character_encodings)
449457
+ [IIS](https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/mimemap)
450-
+ [NGINX](https://developer.mozilla.org/en-US/NGINX_configuration_snippets)
458+
+ [NGINX](https://www.nginx.com/resources/wiki/start/topics/examples/full/#mime-types)
451459
452460
* Enable HTTPS
453461
@@ -534,9 +542,8 @@ The following shows how to display these images on the page
534542
```
535543

536544
```javascript
537-
let pScanner = null;
538545
(async () => {
539-
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
546+
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
540547
/* The default of `_bUseWebgl` is true which means the intermediate result for
541548
IRT_ORIGINAL_IMAGE will be one that has been preprocessed by WebGL */
542549
scanner._bUseWebgl = false;

0 commit comments

Comments
 (0)