From 0738e806e1d062025c97791d7001c550915704f5 Mon Sep 17 00:00:00 2001 From: javl Date: Sat, 15 Aug 2026 13:56:33 +0200 Subject: [PATCH] Fix issue with reading from byte array not populating images list properly --- js/script.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/script.js b/js/script.js index de90217..77778ca 100644 --- a/js/script.js +++ b/js/script.js @@ -548,7 +548,7 @@ function listToImageHorizontal(list, canvas) { const decoded = hexListToBits(list); if (!decoded.valid) { reportInvalidByteArray(decoded.s); - return; + return false; } const imgData = ctx.createImageData(canvas.width, canvas.height); @@ -577,6 +577,7 @@ function listToImageHorizontal(list, canvas) { ctx.putImageData(imgData, 0, 0); commitCanvasToFirstImage(canvas); + return true; } // Quick and effective way to draw single pixels onto the canvas @@ -600,7 +601,7 @@ function listToImageVertical(list, canvas) { const decoded = hexListToBits(list); if (!decoded.valid) { reportInvalidByteArray(decoded.s); - return; + return false; } let page = 0; @@ -623,6 +624,7 @@ function listToImageVertical(list, canvas) { } commitCanvasToFirstImage(canvas); + return true; } // Set width/height preset for byte array text input @@ -688,10 +690,17 @@ function handleTextInput(drawMode) { return; } - if (drawMode === 'horizontal') { - listToImageHorizontal(list, canvas); - } else { - listToImageVertical(list, canvas); + const success = drawMode === 'horizontal' + ? listToImageHorizontal(list, canvas) + : listToImageVertical(list, canvas); + + if (success) { + document.getElementById('text-input-error').style.display = 'none'; + document.querySelectorAll('.no-file-selected').forEach((el) => { + // eslint-disable-next-line no-param-reassign + el.style.display = 'none'; + }); + checkImagesAvailable(); } }