diff --git a/index.html b/index.html index da7fb0e..7b1105d 100644 --- a/index.html +++ b/index.html @@ -12,11 +12,16 @@ + + + + + @@ -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; } diff --git a/sticker-print.js b/sticker-print.js index 0e29378..d1786c8 100644 --- a/sticker-print.js +++ b/sticker-print.js @@ -149,8 +149,7 @@ function imageToGRF(imgUrl, options) { }); } -async function createInternalStickerZPL(options) { - const templateName = "sticker-70x35"; +async function createInternalStickerZPL(templateName, options) { const template = TEMPLATES[templateName]; const agencyLogoZPL = await imageToGRF(options.agencyLogoUrl, {