commit a5179642de16800886ba9bc88dade670c01855fe
parent 7da1ea7bcb12cb71165feee6397cc04aed5190bf
Author: Hunter
Date:   Thu, 16 Apr 2026 15:16:56 -0400

show confirmation dialog when navigating away if painting exists

Diffstat:
Mindex.html | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/index.html b/index.html @@ -245,6 +245,7 @@ let painting = false; let picking = false; let lastPaintX = null, lastPaintY = null; + let dirty = false; function resize() { const firstResize = cssW === 0; @@ -269,6 +270,7 @@ } function paintAt(cx, cy) { + dirty = true; const tl = brushTopLeft(cx, cy); if (roundness === 0) { paintRect(tl.x, tl.y, brush, brush, 'rgb(' + r + ',' + g + ',' + b + ')'); @@ -710,6 +712,10 @@ requestDraw(); }, { passive: false }); + window.addEventListener('beforeunload', (e) => { + if (dirty) { e.preventDefault(); } + }); + window.addEventListener('contextmenu', (e) => e.preventDefault()); // block the OS pinch gesture events too (Safari)