Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,23 @@ def increase_score():
for team in scoreboard:
if team["id"] == team_id:
team["score"] += 1

reorder()

return jsonify(scoreboard=scoreboard)

def reorder():
global scoreboard
for i in range(len(scoreboard)):
max_score = i
for j in range(i + 1, len(scoreboard)):
if scoreboard[j]["score"] > scoreboard[max_score]["score"]:
max_score = j
temp = scoreboard[i]
scoreboard[i] = scoreboard[max_score]
scoreboard[max_score] = temp




if __name__ == '__main__':
app.run(debug = True)
Expand Down
3 changes: 2 additions & 1 deletion static/scoreboard.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

function display_scoreboard(scoreboard){
$("#teams").empty();
$.each(scoreboard, function(index, team){
Expand Down Expand Up @@ -32,7 +33,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");
Expand Down