mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-11-14 08:53:49 +00:00
passing in data object repeatedly
This commit is contained in:
parent
3e2ef80ad3
commit
cea3e7303c
@ -18,9 +18,9 @@
|
|||||||
interface SubmitData {
|
interface SubmitData {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
w: number;
|
width: number;
|
||||||
h: number;
|
height: number;
|
||||||
u: boolean;
|
update: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
let imageURL: string | null;
|
let imageURL: string | null;
|
||||||
@ -28,8 +28,8 @@
|
|||||||
let uploadStarted = false,
|
let uploadStarted = false,
|
||||||
submitData: SubmitData;
|
submitData: SubmitData;
|
||||||
|
|
||||||
async function updateMatrix() {
|
async function updateMatrix(data: SubmitData) {
|
||||||
await fetch('/api/redirect?endpoint=update');
|
if (data.update) await fetch('/api/redirect?endpoint=update');
|
||||||
clearInterval(uploadData.interval);
|
clearInterval(uploadData.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +68,8 @@
|
|||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
// Set the canvas dimensions
|
// Set the canvas dimensions
|
||||||
canvas.width = data.w;
|
canvas.width = data.width;
|
||||||
canvas.height = data.h;
|
canvas.height = data.height;
|
||||||
|
|
||||||
// Draw the image onto the canvas, resizing it to fit the canvas
|
// Draw the image onto the canvas, resizing it to fit the canvas
|
||||||
context?.drawImage(img, 0, 0, canvas.width, canvas.height);
|
context?.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||||
@ -109,9 +109,9 @@
|
|||||||
submitData = {
|
submitData = {
|
||||||
x: parseInt(fdata.get('x')?.toString() ?? '0'),
|
x: parseInt(fdata.get('x')?.toString() ?? '0'),
|
||||||
y: parseInt(fdata.get('y')?.toString() ?? '0'),
|
y: parseInt(fdata.get('y')?.toString() ?? '0'),
|
||||||
w: parseInt(fdata.get('w')?.toString() ?? matrix.width.toString()),
|
width: parseInt(fdata.get('w')?.toString() ?? matrix.width.toString()),
|
||||||
h: parseInt(fdata.get('h')?.toString() ?? matrix.height.toString()),
|
height: parseInt(fdata.get('h')?.toString() ?? matrix.height.toString()),
|
||||||
u: fdata.get('update') ? true : false
|
update: fdata.get('update') ? true : false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time upload by saving date
|
// Time upload by saving date
|
||||||
@ -244,23 +244,13 @@
|
|||||||
<p>Placing image . . .</p>
|
<p>Placing image . . .</p>
|
||||||
<p>{uploadData.elapsed} seconds elapsed.</p>
|
<p>{uploadData.elapsed} seconds elapsed.</p>
|
||||||
{:then}
|
{:then}
|
||||||
{#if submitData.u}
|
{#await updateMatrix(submitData)}
|
||||||
{#await updateMatrix()}
|
<p>Updating matrix . . .</p>
|
||||||
<p>Updating matrix . . .</p>
|
<p>{uploadData.elapsed} seconds elapsed.</p>
|
||||||
<p>{uploadData.elapsed} seconds elapsed.</p>
|
{:then}
|
||||||
{:then}
|
|
||||||
<p>Done!</p>
|
|
||||||
<p>{uploadData.elapsed} seconds elapsed.</p>
|
|
||||||
{/await}
|
|
||||||
{:else}
|
|
||||||
<p>Done!</p>
|
<p>Done!</p>
|
||||||
<p>
|
<p>{uploadData.elapsed} seconds elapsed.</p>
|
||||||
{(() => {
|
{/await}
|
||||||
clearInterval(uploadData.interval);
|
|
||||||
return uploadData.elapsed;
|
|
||||||
})()} seconds elapsed.
|
|
||||||
</p>
|
|
||||||
{/if}
|
|
||||||
{/await}
|
{/await}
|
||||||
{/await}
|
{/await}
|
||||||
{/await}
|
{/await}
|
||||||
|
Loading…
Reference in New Issue
Block a user