From 1de3c68fc66144178e797bc9f0220432b003422e Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Wed, 7 Oct 2026 10:25:47 +0200 Subject: [PATCH] Wrap UI updates in try/catch so errors don't break the animation --- index.html | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index b5adb1b..26a5c64 100644 --- a/index.html +++ b/index.html @@ -930,6 +930,7 @@ var weatherThemes = { } function updateDebug(t, palette, vantaColors, themeName) { + try { var now = new Date(); var hh = now.getHours(), mm = now.getMinutes(), ss = now.getSeconds(); document.getElementById('dbg-time').textContent = @@ -968,28 +969,39 @@ var weatherThemes = { document.getElementById(hid).textContent = '#' + ('00000' + vc.toString(16)).slice(-6); } } + } catch (e) { + console.log('updateDebug error:', e); + } } function animate() { - var elapsed = (Date.now() - startTime) % CYCLE; - var t = elapsed / CYCLE; - var c = getColor(t); - c = applyWeatherTheme(c); - effect.setOptions({ - skyColor: c.sky, - cloudColor: c.cloud, - lightColor: c.light, - backgroundColor: c.bg, - backgroundAlpha: 0, - speed: currentThemeSpeed - }); - document.body.style.backgroundColor = '#' + ('00000' + c.sky.toString(16)).slice(-6); - updateDebug(t, null, c, currentWeatherThemeName); + try { + var elapsed = (Date.now() - startTime) % CYCLE; + var t = elapsed / CYCLE; + var c = getColor(t); + c = applyWeatherTheme(c); + effect.setOptions({ + skyColor: c.sky, + cloudColor: c.cloud, + lightColor: c.light, + backgroundColor: c.bg, + backgroundAlpha: 0, + speed: currentThemeSpeed + }); + document.body.style.backgroundColor = '#' + ('00000' + c.sky.toString(16)).slice(-6); + updateDebug(t, null, c, currentWeatherThemeName); + } catch (e) { + console.log('animate error:', e); + } requestAnimationFrame(animate); } function tick() { - updateClockAndEvents(); + try { + updateClockAndEvents(); + } catch (e) { + console.log('tick error:', e); + } setTimeout(tick, 1000); } @@ -1168,10 +1180,11 @@ var weatherThemes = { } // Update weather every 15 minutes + animate(); + tick(); + fetchWeather(); setInterval(fetchWeather, 15 * 60 * 1000); - - animate(); tick();