@@ -109,6 +109,32 @@ templ RacePublic(currentGroup models.Group, heats []models.Heat, racers []models
}
};
+ // Events WebSocket for race events
+ const eventsSocket = new WebSocket(`${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}/ws/events`);
+
+ eventsSocket.onmessage = function(event) {
+ const data = JSON.parse(event.data);
+
+ if (data.event === 'race_start') {
+ // Race has started
+ console.log('Race started!');
+ // You could add visual effects or sounds here
+ } else if (data.event === 'lane_finish') {
+ // A lane has finished
+ console.log(`Lane ${data.lane} finished with time ${data.time}`);
+ // You could add visual effects or sounds here
+ } else if (data.event === 'race_end') {
+ // Race has ended
+ console.log('Race ended!');
+ // You could add visual effects or sounds here
+
+ // Reload the page after a short delay to show final results
+ setTimeout(() => {
+ window.location.reload();
+ }, 3000);
+ }
+ };
+
// Auto-refresh the page every 30 seconds to keep data current
setTimeout(() => {
window.location.reload();
diff --git a/web/templates/race_public_templ.go b/web/templates/race_public_templ.go
index b1b230a..d3957b6 100644
--- a/web/templates/race_public_templ.go
+++ b/web/templates/race_public_templ.go
@@ -125,13 +125,13 @@ func RacePublic(currentGroup models.Group, heats []models.Heat, racers []models.
return templ_7745c5c3_Err
}
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "