Improved versions of the examples-pages. Now including the possibility to switch between Code128 and EAN.
parent
5e4c3aeb55
commit
d806d48b0f
File diff suppressed because one or more lines are too long
@ -1,28 +1,44 @@
|
||||
$(function() {
|
||||
Quagga.init({
|
||||
inputStream : {
|
||||
name : "Live",
|
||||
type : "LiveStream"
|
||||
var App = {
|
||||
init : function() {
|
||||
Quagga.init({
|
||||
inputStream : {
|
||||
name : "Live",
|
||||
type : "LiveStream"
|
||||
},
|
||||
decoder : {
|
||||
readers : ["code_128_reader"]
|
||||
},
|
||||
readyFunc : function() {
|
||||
App.attachListeners();
|
||||
Quagga.start();
|
||||
}
|
||||
});
|
||||
},
|
||||
decoder : {
|
||||
readers : ['code_128_reader']
|
||||
attachListeners : function() {
|
||||
$(".controls .reader-group").on("change", "input", function(e) {
|
||||
e.preventDefault();
|
||||
Quagga.setReaders([e.target.value + "_reader"]);
|
||||
});
|
||||
},
|
||||
readyFunc : function() {
|
||||
Quagga.start();
|
||||
}
|
||||
});
|
||||
detachListeners : function() {
|
||||
$(".controls .reader-group").off("change", "input");
|
||||
},
|
||||
lastResult : null
|
||||
};
|
||||
|
||||
App.init();
|
||||
|
||||
Quagga.onDetected(function(result) {
|
||||
Quagga.stop();
|
||||
var $node = null, canvas = Quagga.canvas.dom.image;
|
||||
if (App.lastResult !== result) {
|
||||
App.lastResult = result;
|
||||
var $node = null, canvas = Quagga.canvas.dom.image;
|
||||
|
||||
$node = $('<li><div class="thumbnail"><div class="imgWrapper"><img /></div><div class="caption"><h4 class="code"></h4></div></div></li>');
|
||||
$node.find("img").attr("src", canvas.toDataURL());
|
||||
$node.find("h4.code").html(result);
|
||||
$("#result_strip ul.thumbnails").prepend($node);
|
||||
});
|
||||
|
||||
$(".controls").on("click", "button.next", function(e) {
|
||||
Quagga.start();
|
||||
$node = $('<li><div class="thumbnail"><div class="imgWrapper"><img /></div><div class="caption"><h4 class="code"></h4></div></div></li>');
|
||||
$node.find("img").attr("src", canvas.toDataURL());
|
||||
$node.find("h4.code").html(result);
|
||||
$("#result_strip ul.thumbnails").prepend($node);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue