27 lines
711 B
JavaScript
27 lines
711 B
JavaScript
import QRCode from "qrcode";
|
|
import JsBarcode from "jsbarcode";
|
|
|
|
async function renderLabels() {
|
|
const template = document.querySelector("#labelTemplate");
|
|
|
|
const URL_BASE = "https://inv.claremontmakerspace.org/";
|
|
const assetTag = "TSMS00001";
|
|
const assetName = "Laptop1";
|
|
|
|
let clone = document.importNode(template.content, true);
|
|
|
|
let qrcode = await QRCode.toDataURL(URL_BASE + assetTag, { margin: 0 });
|
|
clone.querySelector(".qrcode").src = qrcode;
|
|
|
|
JsBarcode(clone.querySelector(".barcode"), assetTag, {
|
|
displayValue: false,
|
|
margin: 0
|
|
});
|
|
|
|
clone.querySelector(".name").textContent = assetName;
|
|
|
|
document.body.appendChild(clone);
|
|
}
|
|
|
|
window.addEventListener("load", renderLabels);
|