From be7755d1a2c2c3201fc3391e701cffca7aeb6f2c Mon Sep 17 00:00:00 2001 From: jndaniels Date: Wed, 4 Dec 2024 11:43:40 -0600 Subject: [PATCH] SAVE BEFORE Wappler upgrade to beta 13 --- public/ERTSQlite.db | Bin 69632 -> 69632 bytes public/PDF/pdfLibSignature.js | 58 +++++++++++++++++++++++++++++++++- public/js/libProcessScript.js | 11 +++++++ views/index0.ejs | 6 ++-- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/public/ERTSQlite.db b/public/ERTSQlite.db index 40eb347c662dd7ecc2a154be39860664e1b9f68e..9d03c975dc44903974ee92612e5b1843e87f8924 100644 GIT binary patch delta 107 zcmV-x0F?iLpag)R1dtm6x{(}10lKkZq#qUt4x<1M+z*crZVyNf%?_gvArAKru#+Gl zT$3;$2D5x1cMd5BB_$CkRtNwk9T5p307_+MW*|giZfRv~b1^hFI5agmHdI(KGA%GP Nvm7tu5CK-AK+wIB9`gVI delta 107 zcmZozz|ydQWr8&0&WSS4j5{|bERh#u=UdFce}})HKabyo?=0V9enq~;d>bY!D8x)Q zP+;3!qfpMLX{f3y$fy{SpR3@e7{Jb;C=BHJCKgpHc;)A%7Mq$FhxjoY8tNLEZI;o0 LEWjAL$l(G2ulpXO diff --git a/public/PDF/pdfLibSignature.js b/public/PDF/pdfLibSignature.js index 066afbf..3761f07 100644 --- a/public/PDF/pdfLibSignature.js +++ b/public/PDF/pdfLibSignature.js @@ -100,4 +100,60 @@ function generateRandomIdentifier(size) { //canvas.addEventListener('touchstart', (e) => startDrawing(e.touches[0])); //canvas.addEventListener('touchend', endDrawing); -//canvas.addEventListener('touchmove', (e) => draw(e.touches[0])); \ No newline at end of file +//canvas.addEventListener('touchmove', (e) => draw(e.touches[0])); + + +/** FUTURE CODE BLOCK TO DETECT WHICH CANVAS IS DRAWN ON. DYNAMIC DETECT CANVAS ID + * + +let activeCanvasId = null; // Variable to store the ID of the active canvas +let isDrawing = false; // Flag to check if drawing is active + +function startDrawing(event) { + isDrawing = true; + const canvas = event.target; // The canvas where the event occurred + activeCanvasId = canvas.id; // Store the ID of the active canvas + console.log(`Started drawing on: ${activeCanvasId}`); +} + +function draw(event) { + if (!isDrawing) return; + + const canvas = document.getElementById(activeCanvasId); + const ctx = canvas.getContext('2d'); + ctx.lineWidth = 2; + ctx.lineCap = 'round'; + ctx.strokeStyle = '#000000'; + + // Get cursor position relative to the canvas + const rect = canvas.getBoundingClientRect(); + const x = event.clientX - rect.left; + const y = event.clientY - rect.top; + + ctx.lineTo(x, y); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(x, y); +} + +function stopDrawing() { + isDrawing = false; + console.log(`Stopped drawing on: ${activeCanvasId}`); +} + +// Attach event listeners to both canvases +const canvases = document.querySelectorAll('canvas'); + +canvases.forEach((canvas) => { + canvas.addEventListener('mousedown', startDrawing); + canvas.addEventListener('mousemove', draw); + canvas.addEventListener('mouseup', stopDrawing); + canvas.addEventListener('mouseleave', stopDrawing); // Stop drawing if the mouse leaves the canvas + + // Support for touch events + canvas.addEventListener('touchstart', (event) => startDrawing(event.touches[0])); + canvas.addEventListener('touchmove', (event) => draw(event.touches[0])); + canvas.addEventListener('touchend', stopDrawing); +}); + + */ \ No newline at end of file diff --git a/public/js/libProcessScript.js b/public/js/libProcessScript.js index 1c8b01a..4ac6803 100644 --- a/public/js/libProcessScript.js +++ b/public/js/libProcessScript.js @@ -192,6 +192,17 @@ function saveSignature() { }); } +function saveSignatureAsBase64() { + //const canvas = document.getElementById('signatureCanvas'); + + return document.getElementById('signatureCanvas').toDataURL('image/png'); // Get the Base64 string + +} + +function getSignatureData() { + dmx.global.set('canvasDataEncoded', saveSignatureAsBase64()) + dd('SignatureData:', saveSignatureAsBase64()) +} function saveSignatureNew() { const canvas = document.getElementById('signatureCanvas'); diff --git a/views/index0.ejs b/views/index0.ejs index a734753..9a7fd6d 100644 --- a/views/index0.ejs +++ b/views/index0.ejs @@ -104,7 +104,7 @@

 Please submit your signature and click the save button.

- +
-
+
@@ -286,7 +286,7 @@

You must sign for Road Test

- +