From 3ea36c002014e47a618b8c63a0a43ea50a0f6c74 Mon Sep 17 00:00:00 2001 From: nathangendler <106348682+nathangendler@users.noreply.github.com> Date: Thu, 20 Aug 2026 18:06:41 -0400 Subject: [PATCH] Immediate score update and sorting - server.py: sort the scoreboard in non-increasing score order after each increase before returning JSON - static/scoreboard.js: re-render the board in the AJAX success callback so changes appear without a refresh --- server.py | 2 ++ static/scoreboard.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..0cb04aa9 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,8 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + scoreboard.sort(key=lambda team: team["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");