From 9fae6eb7c7a8b1bb128cb6be46253fc31faa830b Mon Sep 17 00:00:00 2001
From: Cube <877211593@qq.com>
Date: Fri, 26 Aug 2022 10:30:45 +0800
Subject: [PATCH 1/2] improve result format judgement;
---
1.hello-world/1.hello-world.html | 3 ++-
1.hello-world/10.read-video-pwa/helloworld-pwa.html | 3 ++-
1.hello-world/11.read-video-requirejs.html | 3 ++-
1.hello-world/12.read-video-es6.html | 3 ++-
1.hello-world/2.read-an-image.html | 5 +++--
2.ui-tweaking/1.read-video-show-result.html | 6 ++++--
2.ui-tweaking/2.read-video-no-extra-control.html | 3 ++-
2.ui-tweaking/3.read-video-with-external-control.html | 3 ++-
2.ui-tweaking/4.difference-video-size.html | 3 ++-
2.ui-tweaking/5.read-video-with-custom-default-ui.html | 3 ++-
3.settings/initScanner.js | 3 ++-
11 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/1.hello-world/1.hello-world.html b/1.hello-world/1.hello-world.html
index 0a07f920..9b6208d3 100644
--- a/1.hello-world/1.hello-world.html
+++ b/1.hello-world/1.hello-world.html
@@ -37,7 +37,8 @@
scanner.onFrameRead = results => {
console.log("Barcodes on one frame:");
for (let result of results) {
- console.log(result.barcodeFormatString + ": " + result.barcodeText);
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ console.log(format + ": " + result.barcodeText);
}
};
/**
diff --git a/1.hello-world/10.read-video-pwa/helloworld-pwa.html b/1.hello-world/10.read-video-pwa/helloworld-pwa.html
index fb676658..9f63cc67 100644
--- a/1.hello-world/10.read-video-pwa/helloworld-pwa.html
+++ b/1.hello-world/10.read-video-pwa/helloworld-pwa.html
@@ -56,7 +56,8 @@
Hello World for PWA
scanner.onFrameRead = results => {
console.log("Barcodes on one frame:");
for (let result of results) {
- console.log(result.barcodeFormatString + ": " + result.barcodeText);
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ console.log(format + ": " + result.barcodeText);
}
};
scanner.onUniqueRead = (txt, result) => {
diff --git a/1.hello-world/11.read-video-requirejs.html b/1.hello-world/11.read-video-requirejs.html
index 8d4d5c4c..3b9fa50e 100644
--- a/1.hello-world/11.read-video-requirejs.html
+++ b/1.hello-world/11.read-video-requirejs.html
@@ -38,7 +38,8 @@ Hello World for RequireJS
scanner.onFrameRead = results => {
console.log("Barcodes on one frame:");
for (let result of results) {
- console.log(result.barcodeFormatString + ": " + result.barcodeText);
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ console.log(format + ": " + result.barcodeText);
}
};
scanner.onUniqueRead = (txt, result) => {
diff --git a/1.hello-world/12.read-video-es6.html b/1.hello-world/12.read-video-es6.html
index f4c59a3b..17e10d90 100644
--- a/1.hello-world/12.read-video-es6.html
+++ b/1.hello-world/12.read-video-es6.html
@@ -40,7 +40,8 @@ Hello World for ES6
scanner.onFrameRead = results => {
console.log("Barcodes on one frame:");
for (let result of results) {
- console.log(result.barcodeFormatString + ": " + result.barcodeText);
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ console.log(format + ": " + result.barcodeText);
}
};
/*
diff --git a/1.hello-world/2.read-an-image.html b/1.hello-world/2.read-an-image.html
index 36ce465a..fc9dff2f 100644
--- a/1.hello-world/2.read-an-image.html
+++ b/1.hello-world/2.read-an-image.html
@@ -95,9 +95,10 @@ Read Barcode from Images
divResults.appendChild(createEl('p', "No Barcode Found!"));
}
for (let result of results) {
- iptReadonlyLastResult.value = result.barcodeFormatString + ": " + result.barcodeText; // show last txt result
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ iptReadonlyLastResult.value = format + ": " + result.barcodeText; // show last txt result
const p = document.createElement('p');
- p.appendChild(createEl('span', result.barcodeFormatString + ": "));
+ p.appendChild(createEl('span', format + ": "));
p.appendChild(createEl('span', result.barcodeText, "sp-resultText"));
divResults.appendChild(p);
if (result.barcodeText.indexOf("Attention(exceptionCode") != -1) {
diff --git a/2.ui-tweaking/1.read-video-show-result.html b/2.ui-tweaking/1.read-video-show-result.html
index 8a90d8cb..4d42af1d 100644
--- a/2.ui-tweaking/1.read-video-show-result.html
+++ b/2.ui-tweaking/1.read-video-show-result.html
@@ -69,7 +69,8 @@ Use the Default Built-in UI
scanner.onFrameRead = (_results) => {
for (let result of _results) {
let newElements = [];
- newElements.push(createASpan(result.barcodeFormatString + ": "));
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ newElements.push(createASpan(format + ": "));
newElements.push(createASpan(result.barcodeText, "resultText"));
newElements.push(document.createElement('br'));
if (result.barcodeText.indexOf("Attention(exceptionCode") != -1) {
@@ -83,7 +84,8 @@ Use the Default Built-in UI
}
};
scanner.onUniqueRead = (txt, result) => {
- document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ document.getElementById('result').value = format + ": " + txt;
document.getElementById('result').focus();
setTimeout(() => {
document.getElementById('result').blur();
diff --git a/2.ui-tweaking/2.read-video-no-extra-control.html b/2.ui-tweaking/2.read-video-no-extra-control.html
index 426136a8..245a8ae9 100644
--- a/2.ui-tweaking/2.read-video-no-extra-control.html
+++ b/2.ui-tweaking/2.read-video-no-extra-control.html
@@ -61,7 +61,8 @@ Hide UI Controls
try {
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
scanner.onUniqueRead = (txt, result) => {
- document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ document.getElementById('result').value = format + ": " + txt;
document.getElementById('result').focus();
setTimeout(() => {
document.getElementById('result').blur();
diff --git a/2.ui-tweaking/3.read-video-with-external-control.html b/2.ui-tweaking/3.read-video-with-external-control.html
index 65c32420..4082470c 100644
--- a/2.ui-tweaking/3.read-video-with-external-control.html
+++ b/2.ui-tweaking/3.read-video-with-external-control.html
@@ -123,7 +123,8 @@ Customized UI
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
await scanner.setUIElement(document.getElementById('div-ui-container'));
scanner.onUniqueRead = (txt, result) => {
- document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ document.getElementById('result').value = format + ": " + txt;
document.getElementById('result').focus();
setTimeout(() => {
document.getElementById('result').blur();
diff --git a/2.ui-tweaking/4.difference-video-size.html b/2.ui-tweaking/4.difference-video-size.html
index d21ede15..ef591a2c 100644
--- a/2.ui-tweaking/4.difference-video-size.html
+++ b/2.ui-tweaking/4.difference-video-size.html
@@ -86,7 +86,8 @@ Enlarge the Video Stream
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
await scanner.setUIElement(document.getElementById('div-ui-container'));
scanner.onUniqueRead = (txt, result) => {
- document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ document.getElementById('result').value = format + ": " + txt;
if (fitPage.hidden)
exitFullPage();
document.getElementById('result').focus();
diff --git a/2.ui-tweaking/5.read-video-with-custom-default-ui.html b/2.ui-tweaking/5.read-video-with-custom-default-ui.html
index fa7e1504..2fad2d5c 100644
--- a/2.ui-tweaking/5.read-video-with-custom-default-ui.html
+++ b/2.ui-tweaking/5.read-video-with-custom-default-ui.html
@@ -90,7 +90,8 @@ Customized Default UI
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
document.getElementById('UIElement').appendChild(scanner.getUIElement());
scanner.onUniqueRead = (txt, result) => {
- document.getElementById('result').value = result.barcodeFormatString + ": " + txt;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ document.getElementById('result').value = format + ": " + txt;
document.getElementById('result').focus();
setTimeout(() => {
document.getElementById('result').blur();
diff --git a/3.settings/initScanner.js b/3.settings/initScanner.js
index 2a42a43c..28c0f9c3 100644
--- a/3.settings/initScanner.js
+++ b/3.settings/initScanner.js
@@ -78,7 +78,8 @@ async function startReading() {
let scanner = await pScanner;
scanner.onFrameRead = (_results) => {
for (let result of _results) {
- resultBox.value = result.barcodeFormatString + ": " + result.barcodeText;
+ const format = result.barcodeFormat ? result.barcodeFormatString : result.barcodeFormatString_2;
+ resultBox.value = format + ": " + result.barcodeText;
}
};
await scanner.show();
From d8e2fae682a0109ee5c04ea7ef3aeacd8b515ae1 Mon Sep 17 00:00:00 2001
From: Cube <877211593@qq.com>
Date: Tue, 20 Sep 2022 14:39:14 +0800
Subject: [PATCH 2/2] update css;
---
.../src/components/VideoDecode/VideoDecode.css | 2 +-
.../src/app/barcode-scanner/barcode-scanner.component.css | 2 +-
.../src/components/VideoDecode/VideoDecode.css | 2 +-
1.hello-world/5.read-video-vue/src/components/VideoDecode.vue | 1 +
1.hello-world/6.read-video-vue3/src/components/VideoDecode.vue | 1 +
1.hello-world/7.read-video-nextjs/styles/BarcodeScanner.css | 2 +-
1.hello-world/8.read-video-nuxtjs/components/VideoDecode.vue | 1 +
7 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/1.hello-world/13.read-video-react-ts/src/components/VideoDecode/VideoDecode.css b/1.hello-world/13.read-video-react-ts/src/components/VideoDecode/VideoDecode.css
index c41cd2f2..3bac7c0e 100644
--- a/1.hello-world/13.read-video-react-ts/src/components/VideoDecode/VideoDecode.css
+++ b/1.hello-world/13.read-video-react-ts/src/components/VideoDecode/VideoDecode.css
@@ -1,5 +1,5 @@
.component-barcode-scanner{width:100%;height:100%;/* min-width:640px; */min-height:480px;background:#eee;position:relative;resize:both;}
-.dce-bg-loading{animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
+.dce-bg-loading{display:none;animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-bg-camera{display:none;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-video-container{position:absolute;left:0;top:0;width:100%;height:100%;}
.dce-scanarea{width:100%;height:100%;position:absolute;left:0;top:0;}
diff --git a/1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.css b/1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.css
index b7a3b2e4..8e7f05bc 100644
--- a/1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.css
+++ b/1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.css
@@ -1,5 +1,5 @@
.component-barcode-scanner{width:100%;height:100%;/* min-width:640px; */min-height:480px;background:#eee;position:relative;resize:both;}
-.dce-bg-loading{animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
+.dce-bg-loading{display:none;animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-bg-camera{display:none;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-video-container{position:absolute;left:0;top:0;width:100%;height:100%;}
.dce-scanarea{width:100%;height:100%;position:absolute;left:0;top:0;}
diff --git a/1.hello-world/4.read-video-react/src/components/VideoDecode/VideoDecode.css b/1.hello-world/4.read-video-react/src/components/VideoDecode/VideoDecode.css
index c41cd2f2..3bac7c0e 100644
--- a/1.hello-world/4.read-video-react/src/components/VideoDecode/VideoDecode.css
+++ b/1.hello-world/4.read-video-react/src/components/VideoDecode/VideoDecode.css
@@ -1,5 +1,5 @@
.component-barcode-scanner{width:100%;height:100%;/* min-width:640px; */min-height:480px;background:#eee;position:relative;resize:both;}
-.dce-bg-loading{animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
+.dce-bg-loading{display:none;animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-bg-camera{display:none;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-video-container{position:absolute;left:0;top:0;width:100%;height:100%;}
.dce-scanarea{width:100%;height:100%;position:absolute;left:0;top:0;}
diff --git a/1.hello-world/5.read-video-vue/src/components/VideoDecode.vue b/1.hello-world/5.read-video-vue/src/components/VideoDecode.vue
index 4affda6b..62eddc66 100644
--- a/1.hello-world/5.read-video-vue/src/components/VideoDecode.vue
+++ b/1.hello-world/5.read-video-vue/src/components/VideoDecode.vue
@@ -117,6 +117,7 @@ export default {
}
.dce-bg-loading {
+ display: none;
animation: 1s linear infinite dce-rotate;
width: 40%;
height: 40%;
diff --git a/1.hello-world/6.read-video-vue3/src/components/VideoDecode.vue b/1.hello-world/6.read-video-vue3/src/components/VideoDecode.vue
index b71dcc84..584715ad 100644
--- a/1.hello-world/6.read-video-vue3/src/components/VideoDecode.vue
+++ b/1.hello-world/6.read-video-vue3/src/components/VideoDecode.vue
@@ -121,6 +121,7 @@ export default {
}
.dce-bg-loading {
+ display: none;
animation: 1s linear infinite dce-rotate;
width: 40%;
height: 40%;
diff --git a/1.hello-world/7.read-video-nextjs/styles/BarcodeScanner.css b/1.hello-world/7.read-video-nextjs/styles/BarcodeScanner.css
index c41cd2f2..3bac7c0e 100644
--- a/1.hello-world/7.read-video-nextjs/styles/BarcodeScanner.css
+++ b/1.hello-world/7.read-video-nextjs/styles/BarcodeScanner.css
@@ -1,5 +1,5 @@
.component-barcode-scanner{width:100%;height:100%;/* min-width:640px; */min-height:480px;background:#eee;position:relative;resize:both;}
-.dce-bg-loading{animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
+.dce-bg-loading{display:none;animation:1s linear infinite dce-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-bg-camera{display:none;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
.dce-video-container{position:absolute;left:0;top:0;width:100%;height:100%;}
.dce-scanarea{width:100%;height:100%;position:absolute;left:0;top:0;}
diff --git a/1.hello-world/8.read-video-nuxtjs/components/VideoDecode.vue b/1.hello-world/8.read-video-nuxtjs/components/VideoDecode.vue
index 23d8de94..506a60b6 100644
--- a/1.hello-world/8.read-video-nuxtjs/components/VideoDecode.vue
+++ b/1.hello-world/8.read-video-nuxtjs/components/VideoDecode.vue
@@ -117,6 +117,7 @@ export default {
}
.dce-bg-loading {
+ display: none;
animation: 1s linear infinite dce-rotate;
width: 40%;
height: 40%;