-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (29 loc) · 983 Bytes
/
Copy pathscript.js
File metadata and controls
33 lines (29 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import "./pos-terminal.js";
import { BARCODE_VALUE, createBarcodeSvg } from "./barcode.js";
function paintReceipt(canvas) {
window.ReceiptArt?.draw(
canvas.getContext("2d"),
canvas.width,
canvas.height,
{
seed: Number(canvas.dataset.seed) || 1,
style: canvas.dataset.style || undefined,
chrome: canvas.dataset.chrome !== "false",
},
);
}
document.querySelectorAll("canvas[data-art]").forEach(paintReceipt);
document.querySelectorAll("[data-barcode]").forEach((barcode) => {
barcode.innerHTML = createBarcodeSvg(barcode.dataset.barcode || BARCODE_VALUE);
});
// Retire the scroll cue as soon as the page moves; it is only there to say
// there is more below.
const scrollCue = document.querySelector(".scroll-cue");
if (scrollCue) {
const update = () => {
if (window.scrollY > 60) scrollCue.dataset.hidden = "";
else delete scrollCue.dataset.hidden;
};
update();
addEventListener("scroll", update, { passive: true });
}