Add comments and createInternalStickerZPL() param
This commit is contained in:
@ -12,11 +12,16 @@
|
|||||||
<script type="text/javascript" src="lib/zpl-image/pako.js"></script>
|
<script type="text/javascript" src="lib/zpl-image/pako.js"></script>
|
||||||
<script type="text/javascript" src="lib/zpl-image/zpl-image.js"></script>
|
<script type="text/javascript" src="lib/zpl-image/zpl-image.js"></script>
|
||||||
|
|
||||||
|
<!-- js libs for BrowserPrinter only - not used for Web API printing -->
|
||||||
<script type="text/javascript" src="lib/zebra-browser-print/BrowserPrint-3.1.250.min.js"></script>
|
<script type="text/javascript" src="lib/zebra-browser-print/BrowserPrint-3.1.250.min.js"></script>
|
||||||
<script type="text/javascript" src="lib/zebra-browser-print/BrowserPrint-Zebra-1.1.250.min.js"></script>
|
<script type="text/javascript" src="lib/zebra-browser-print/BrowserPrint-Zebra-1.1.250.min.js"></script>
|
||||||
|
<!-- end -->
|
||||||
|
|
||||||
<script src="./sticker-print.js"></script>
|
<script src="./sticker-print.js"></script>
|
||||||
|
|
||||||
|
<!-- js libs for BrowserPrinter only - not used for Web API printing -->
|
||||||
<script src="./browser-print-api.js"></script>
|
<script src="./browser-print-api.js"></script>
|
||||||
|
<!-- end -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -46,6 +51,7 @@
|
|||||||
const ZEBRA_VENDOR_ID = 0xA5F;
|
const ZEBRA_VENDOR_ID = 0xA5F;
|
||||||
|
|
||||||
function createHooks() {
|
function createHooks() {
|
||||||
|
// print using BrowserPrint
|
||||||
document.querySelector("button.browser-printer-print").addEventListener("click", async (e) => {
|
document.querySelector("button.browser-printer-print").addEventListener("click", async (e) => {
|
||||||
const availableDevices = await getAvailablePrinters();
|
const availableDevices = await getAvailablePrinters();
|
||||||
if (!availableDevices) {
|
if (!availableDevices) {
|
||||||
@ -60,6 +66,7 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// print using Web API
|
||||||
document.querySelector("button.web-api-print").addEventListener("click", async (e) => {
|
document.querySelector("button.web-api-print").addEventListener("click", async (e) => {
|
||||||
const device = await navigator.usb.requestDevice({ filters: [{ vendorId: ZEBRA_VENDOR_ID }] });
|
const device = await navigator.usb.requestDevice({ filters: [{ vendorId: ZEBRA_VENDOR_ID }] });
|
||||||
await device.open();
|
await device.open();
|
||||||
@ -83,7 +90,7 @@
|
|||||||
masterSystemId: "master-system-id",
|
masterSystemId: "master-system-id",
|
||||||
extMasterSystemId: "ext-msid",
|
extMasterSystemId: "ext-msid",
|
||||||
};
|
};
|
||||||
const zpl = await createInternalStickerZPL(options);
|
const zpl = await createInternalStickerZPL("sticker-70x35", options);
|
||||||
document.querySelector(`textarea[name="zpl"]`).value = zpl;
|
document.querySelector(`textarea[name="zpl"]`).value = zpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,8 +149,7 @@ function imageToGRF(imgUrl, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createInternalStickerZPL(options) {
|
async function createInternalStickerZPL(templateName, options) {
|
||||||
const templateName = "sticker-70x35";
|
|
||||||
const template = TEMPLATES[templateName];
|
const template = TEMPLATES[templateName];
|
||||||
|
|
||||||
const agencyLogoZPL = await imageToGRF(options.agencyLogoUrl, {
|
const agencyLogoZPL = await imageToGRF(options.agencyLogoUrl, {
|
||||||
|
|||||||
Reference in New Issue
Block a user