|
|
@ -39,7 +39,6 @@
|
|
|
|
<ul>
|
|
|
|
<ul>
|
|
|
|
<li>Use static image as source</li>
|
|
|
|
<li>Use static image as source</li>
|
|
|
|
<li>Configuring EAN-Reader</li>
|
|
|
|
<li>Configuring EAN-Reader</li>
|
|
|
|
<li>Use custom mount-point (Query-Selector)</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<div class="source-code">
|
|
|
|
<div class="source-code">
|
|
|
@ -53,21 +52,23 @@ var App = {
|
|
|
|
init: function() {
|
|
|
|
init: function() {
|
|
|
|
this.attachListeners();
|
|
|
|
this.attachListeners();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
decode: function(src) {
|
|
|
|
decode: function(file) {
|
|
|
|
Quagga
|
|
|
|
Quagga.fromImage({
|
|
|
|
.decoder({readers: ['ean_reader']})
|
|
|
|
constraints: {src: file, width: 800, height: 800},
|
|
|
|
.locator({patchSize: 'medium'})
|
|
|
|
decoder: {readers: ['ean_reader']},
|
|
|
|
.fromImage(src, {size: 800})
|
|
|
|
})
|
|
|
|
.toPromise()
|
|
|
|
.then(function(scanner) {
|
|
|
|
.then(function(result) {
|
|
|
|
return scanner.detect();
|
|
|
|
document.querySelector('input.isbn').value = result.codeResult.code;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(function(result) {
|
|
|
|
.catch(function() {
|
|
|
|
document.querySelector('input.isbn').value = result.codeResult.code;
|
|
|
|
document.querySelector('input.isbn').value = "Not Found";
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(function() {
|
|
|
|
.then(function() {
|
|
|
|
document.querySelector('input.isbn').value = "Not Found";
|
|
|
|
this.attachListeners();
|
|
|
|
})
|
|
|
|
}.bind(this));
|
|
|
|
.then(function() {
|
|
|
|
|
|
|
|
this.attachListeners();
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
attachListeners: function() {
|
|
|
|
attachListeners: function() {
|
|
|
|
var self = this,
|
|
|
|
var self = this,
|
|
|
@ -84,7 +85,7 @@ var App = {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
fileInput.removeEventListener("change", onChange);
|
|
|
|
fileInput.removeEventListener("change", onChange);
|
|
|
|
if (e.target.files && e.target.files.length) {
|
|
|
|
if (e.target.files && e.target.files.length) {
|
|
|
|
self.decode(URL.createObjectURL(e.target.files[0]));
|
|
|
|
self.decode(e.target.files[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|