From e1a7d5a13b89e0ba9fedf894c62280c8048203a9 Mon Sep 17 00:00:00 2001 From: Dev Bahl Date: Fri, 3 Jul 2026 17:23:20 -0400 Subject: [PATCH] Reflect score updates immediately and sort teams by score - server.py: sort scoreboard descending by score before returning JSON - scoreboard.js: call display_scoreboard in the AJAX success callback so the UI updates without a page refresh --- server.py | 1 + static/scoreboard.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..2a7fd030 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,7 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + scoreboard.sort(key=lambda x: x["score"], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..f48d7c1c 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,7 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");