diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 823be57..7efde4c 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -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 @@
Placing image . . .
{uploadData.elapsed} seconds elapsed.
{:then} - {#if submitData.u} - {#await updateMatrix()} -Updating matrix . . .
-{uploadData.elapsed} seconds elapsed.
- {:then} -Done!
-{uploadData.elapsed} seconds elapsed.
- {/await} - {:else} + {#await updateMatrix(submitData)} +Updating matrix . . .
+{uploadData.elapsed} seconds elapsed.
+ {:then}Done!
-- {(() => { - clearInterval(uploadData.interval); - return uploadData.elapsed; - })()} seconds elapsed. -
- {/if} +{uploadData.elapsed} seconds elapsed.
+ {/await} {/await} {/await} {/await}