Add comments and createInternalStickerZPL() param

This commit is contained in:
Eden Kirin
2023-08-18 11:22:44 +02:00
parent 71506f60c2
commit ce10a8faa0
2 changed files with 9 additions and 3 deletions

View File

@ -12,11 +12,16 @@
<script type="text/javascript" src="lib/zpl-image/pako.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-Zebra-1.1.250.min.js"></script>
<!-- end -->
<script src="./sticker-print.js"></script>
<!-- js libs for BrowserPrinter only - not used for Web API printing -->
<script src="./browser-print-api.js"></script>
<!-- end -->
</head>
<body>
@ -46,6 +51,7 @@
const ZEBRA_VENDOR_ID = 0xA5F;
function createHooks() {
// print using BrowserPrint
document.querySelector("button.browser-printer-print").addEventListener("click", async (e) => {
const availableDevices = await getAvailablePrinters();
if (!availableDevices) {
@ -60,6 +66,7 @@
})
});
// print using Web API
document.querySelector("button.web-api-print").addEventListener("click", async (e) => {
const device = await navigator.usb.requestDevice({ filters: [{ vendorId: ZEBRA_VENDOR_ID }] });
await device.open();
@ -83,7 +90,7 @@
masterSystemId: "master-system-id",
extMasterSystemId: "ext-msid",
};
const zpl = await createInternalStickerZPL(options);
const zpl = await createInternalStickerZPL("sticker-70x35", options);
document.querySelector(`textarea[name="zpl"]`).value = zpl;
}