diff --git a/public/ERTSQlite.db b/public/ERTSQlite.db index 40eb347..9d03c97 100644 Binary files a/public/ERTSQlite.db and b/public/ERTSQlite.db differ 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.
- +