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