From 976e8cc9528b03e0023aa4f69f527880d0b808f0 Mon Sep 17 00:00:00 2001 From: alfonsov2678 <45904009+alfonsov2678@users.noreply.github.com> Date: Mon, 9 Aug 2021 17:57:53 -0400 Subject: [PATCH] Alfonso Velasco alv2145 --- server.py | 8 ++++++++ static/scoreboard.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..420ab54a 100644 --- a/server.py +++ b/server.py @@ -47,9 +47,17 @@ def increase_score(): json_data = request.get_json() team_id = json_data["id"] + index = 0 for team in scoreboard: if team["id"] == team_id: team["score"] += 1 + if index != 0: + if scoreboard[index-1]["score"] < team["score"]: + team_updated = scoreboard.pop(index) + placeholder = scoreboard.pop(index-1) + scoreboard.insert(index - 1, team_updated) + scoreboard.insert(index, placeholder) + index += 1 return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..8f2aa129 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,8 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + console.log(result) + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");