mirror of
https://codeberg.org/icewind/ptouch-api.git
synced 2026-06-03 19:04:08 +02:00
working web ui
This commit is contained in:
parent
71cf4dbcb2
commit
88e6fa3244
2 changed files with 21 additions and 1 deletions
16
web/label.js
16
web/label.js
|
|
@ -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', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue