Scanning Barcodes in JS
We use QuaggaJS to read barcodes.
The user's camera
If your platform supports the getUserMedia API call, you can try the real-time locating and decoding features. Simply allow the page to access your web-cam and point it to a barcode.
HTML
<div data-fd-control='scanner'
data-fd-startonload='true'
data-fd-callback='onScan'>
</div>
JavaScript
FD.Page.onScan = function (data) {
const canvas = this.getCanvas();
const $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(data.value);
$("#result_strip ul.thumbnails").prepend($node);
};