mirror of
https://github.com/grocy/grocy.git
synced 2025-08-21 04:43:32 +00:00
Use dynamic barcode types (references #1133)
This commit is contained in:
@@ -536,10 +536,21 @@ var dummyCanvas = document.createElement("canvas");
|
|||||||
$("img.barcode").each(function()
|
$("img.barcode").each(function()
|
||||||
{
|
{
|
||||||
var img = $(this);
|
var img = $(this);
|
||||||
|
var barcode = img.attr("data-barcode").replace(/\D/g, "");
|
||||||
|
|
||||||
|
var barcodeType = "code128";
|
||||||
|
if (barcode.length == 8)
|
||||||
|
{
|
||||||
|
barcodeType = "ean8";
|
||||||
|
}
|
||||||
|
else if (barcode.length == 13)
|
||||||
|
{
|
||||||
|
barcodeType = "ean13";
|
||||||
|
}
|
||||||
|
|
||||||
bwipjs.toCanvas(dummyCanvas, {
|
bwipjs.toCanvas(dummyCanvas, {
|
||||||
bcid: "ean8",
|
bcid: barcodeType,
|
||||||
text: img.attr("data-barcode"),
|
text: barcode,
|
||||||
height: 5,
|
height: 5,
|
||||||
includetext: false
|
includetext: false
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user