Wrap UI updates in try/catch so errors don't break the animation

This commit is contained in:
Richard Zink committed 2026-10-07 10:25:47 +02:00
1 parent 1ba84cb9df
commit 1de3c68fc6
1 file changed
+15 -2
+15 -2
View File
@@ -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,9 +969,13 @@ var weatherThemes = {
document.getElementById(hid).textContent = '#' + ('00000' + vc.toString(16)).slice(-6);
}
}
} catch (e) {
console.log('updateDebug error:', e);
}
}
function animate() {
try {
var elapsed = (Date.now() - startTime) % CYCLE;
var t = elapsed / CYCLE;
var c = getColor(t);
@@ -985,11 +990,18 @@ var weatherThemes = {
});
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() {
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();
</script>
</body>