Skip to content

Commit e144ccb

Browse files
committed
improve result format judgement;
1 parent afe6225 commit e144ccb

11 files changed

+25
-13
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
scanner.onFrameRead = results => {
3838
console.log("Barcodes on one frame:");
3939
for (let result of results) {
40-
console.log(result.barcodeFormatString + ": " + result.barcodeText);
40+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
41+
console.log(format + ": " + result.barcodeText);
4142
}
4243
};
4344
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
5656
scanner.onFrameRead = results => {
5757
console.log("Barcodes on one frame:");
5858
for (let result of results) {
59-
console.log(result.barcodeFormatString + ": " + result.barcodeText);
59+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
60+
console.log(format + ": " + result.barcodeText);
6061
}
6162
};
6263
scanner.onUniqueRead = (txt, result) => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
3838
scanner.onFrameRead = results => {
3939
console.log("Barcodes on one frame:");
4040
for (let result of results) {
41-
console.log(result.barcodeFormatString + ": " + result.barcodeText);
41+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
42+
console.log(format + ": " + result.barcodeText);
4243
}
4344
};
4445
scanner.onUniqueRead = (txt, result) => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
4040
scanner.onFrameRead = results => {
4141
console.log("Barcodes on one frame:");
4242
for (let result of results) {
43-
console.log(result.barcodeFormatString + ": " + result.barcodeText);
43+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
44+
console.log(format + ": " + result.barcodeText);
4445
}
4546
};
4647
/*

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
9595
divResults.appendChild(createEl('p', "No Barcode Found!"));
9696
}
9797
for (let result of results) {
98-
iptReadonlyLastResult.value = result.barcodeFormatString + ": " + result.barcodeText; // show last txt result
98+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
99+
iptReadonlyLastResult.value = format + ": " + result.barcodeText; // show last txt result
99100
const p = document.createElement('p');
100-
p.appendChild(createEl('span', result.barcodeFormatString + ": "));
101+
p.appendChild(createEl('span', format + ": "));
101102
p.appendChild(createEl('span', result.barcodeText, "sp-resultText"));
102103
divResults.appendChild(p);
103104
if (result.barcodeText.indexOf("Attention(exceptionCode") != -1) {

2.ui-tweaking/1.read-video-show-result.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ <h1 style="font-size: 1.5em;">Use the Default Built-in UI</h1>
6969
scanner.onFrameRead = (_results) => {
7070
for (let result of _results) {
7171
let newElements = [];
72-
newElements.push(createASpan(result.barcodeFormatString + ": "));
72+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
73+
newElements.push(createASpan(format + ": "));
7374
newElements.push(createASpan(result.barcodeText, "resultText"));
7475
newElements.push(document.createElement('br'));
7576
if (result.barcodeText.indexOf("Attention(exceptionCode") != -1) {
@@ -83,7 +84,8 @@ <h1 style="font-size: 1.5em;">Use the Default Built-in UI</h1>
8384
}
8485
};
8586
scanner.onUniqueRead = (txt, result) => {
86-
document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
87+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
88+
document.getElementById('result').value = format + ": " + txt;
8789
document.getElementById('result').focus();
8890
setTimeout(() => {
8991
document.getElementById('result').blur();

2.ui-tweaking/2.read-video-no-extra-control.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ <h1 style="font-size: 1.5em;">Hide UI Controls</h1>
6161
try {
6262
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
6363
scanner.onUniqueRead = (txt, result) => {
64-
document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
64+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
65+
document.getElementById('result').value = format + ": " + txt;
6566
document.getElementById('result').focus();
6667
setTimeout(() => {
6768
document.getElementById('result').blur();

2.ui-tweaking/3.read-video-with-external-control.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ <h1 style="font-size: 1.5em;">Customized UI</h1>
123123
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
124124
await scanner.setUIElement(document.getElementById('div-ui-container'));
125125
scanner.onUniqueRead = (txt, result) => {
126-
document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
126+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
127+
document.getElementById('result').value = format + ": " + txt;
127128
document.getElementById('result').focus();
128129
setTimeout(() => {
129130
document.getElementById('result').blur();

2.ui-tweaking/4.difference-video-size.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ <h1 style="font-size: 1.5em;">Enlarge the Video Stream</h1>
8686
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
8787
await scanner.setUIElement(document.getElementById('div-ui-container'));
8888
scanner.onUniqueRead = (txt, result) => {
89-
document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
89+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
90+
document.getElementById('result').value = format + ": " + txt;
9091
if (fitPage.hidden)
9192
exitFullPage();
9293
document.getElementById('result').focus();

2.ui-tweaking/5.read-video-with-custom-default-ui.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ <h1>Customized Default UI</h1>
9090
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
9191
document.getElementById('UIElement').appendChild(scanner.getUIElement());
9292
scanner.onUniqueRead = (txt, result) => {
93-
document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
93+
const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
94+
document.getElementById('result').value = format + ": " + txt;
9495
document.getElementById('result').focus();
9596
setTimeout(() => {
9697
document.getElementById('result').blur();

0 commit comments

Comments
 (0)