From 57a8cb17d98880dea6c8824d1cb8d28e43d51dc3 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 4 Jan 2026 14:40:33 -0700 Subject: [PATCH] Add Cancel animation --- app.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 21 +++++++++++++++---- style.css | 26 +++++++++++++++++++---- sw.js | 2 +- 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index 26763d2..17d677c 100644 --- a/app.js +++ b/app.js @@ -602,6 +602,66 @@ document.addEventListener('DOMContentLoaded', function () { }); } + // Goodbye popup elements + const goodbyePopup = document.getElementById('goodbye-popup'); + const goodbyeCancelBtn = document.getElementById('goodbye-cancel-btn'); + const goodbyeProgressBar = document.querySelector('.goodbye-progress-bar'); + const cancelBtn = document.getElementById('cancel-btn'); + let goodbyeTimeout = null; + let goodbyeInterval = null; + + function showGoodbyePopup() { + if (goodbyePopup && goodbyePopup.style.display !== 'flex') { + goodbyePopup.style.display = 'flex'; + if (goodbyeProgressBar) { + goodbyeProgressBar.style.width = '0%'; + } + startGoodbyeCountdown(); + } + } + + function hideGoodbyePopup() { + if (goodbyePopup) { + goodbyePopup.style.display = 'none'; + } + if (goodbyeTimeout) { + clearTimeout(goodbyeTimeout); + goodbyeTimeout = null; + } + if (goodbyeInterval) { + clearInterval(goodbyeInterval); + goodbyeInterval = null; + } + } + + function startGoodbyeCountdown() { + const duration = 4000; + const startTime = Date.now(); + + goodbyeInterval = setInterval(() => { + const elapsed = Date.now() - startTime; + const progress = Math.min(elapsed / duration, 1); + if (goodbyeProgressBar) { + goodbyeProgressBar.style.width = (progress * 100) + '%'; + } + if (progress >= 1) { + clearInterval(goodbyeInterval); + } + }, 50); + + goodbyeTimeout = setTimeout(() => { + window.location.href = 'https://legoisland.org'; + }, duration); + } + + if (cancelBtn) { + cancelBtn.addEventListener('click', showGoodbyePopup); + } + + if (goodbyeCancelBtn) { + goodbyeCancelBtn.addEventListener('click', hideGoodbyePopup); + } + if ('serviceWorker' in navigator) { Promise.all([ configManager.init(), diff --git a/index.html b/index.html index 310f5ea..f1bf7d8 100644 --- a/index.html +++ b/index.html @@ -40,8 +40,21 @@ -