working web ui

This commit is contained in:
Robin Appelman 2025-10-06 21:54:21 +02:00
commit 88e6fa3244
2 changed files with 21 additions and 1 deletions

View file

@ -4,6 +4,8 @@ const preview = document.getElementById('preview');
const renderCtx = preview.getContext("2d");
const elementsTableBody = elementsTable.getElementsByTagName('tbody')[0];
const addButton = document.getElementById('add');
/** @type HTMLInputElement printButton */
const printButton = document.getElementById('print');
const widthInput = document.getElementById('canvas-width');
const widthUnit = document.getElementById('canvas-width-unit');
@ -128,7 +130,21 @@ const resize = () => {
render()
};
const print = () => {
printButton.disabled = true;
preview.toBlob(blob => {
blob.arrayBuffer().then(png => fetch(apiRoot + '/print', {
method: 'PUT',
body: png,
}))
.then(() => {
printButton.disabled = false;
});
}, 'image/png');
};
addButton.addEventListener('click', addElement);
printButton.addEventListener('click', print);
widthInput.addEventListener('input', resize);
widthUnit.addEventListener('change', () => {