diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/tournamentResultsUi.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/tournamentResultsUi.js
index c50df0ce2..08f869fcb 100644
--- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/tournamentResultsUi.js
+++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/tournamentResultsUi.js
@@ -81,7 +81,7 @@ var TournamentResultsUI = Class.extend({
var tournamentStage = tournament.getAttribute("stage");
$("#tournamentResults").append("
" + tournamentName + "
");
- $("#tournamentResults").append("Round: " + tournamentRound + "
");
+ $("#tournamentResults").append("Rounds: " + tournamentRound + "
");
var detailsBut = $("").button();
detailsBut.click(
@@ -103,45 +103,51 @@ var TournamentResultsUI = Class.extend({
}
},
- createStandingsTable:function (standings, tournamentId, tournamentStage) {
+ createStandingsTable:function (xmlstandings, tournamentId, tournamentStage) {
var standingsTable = $("");
standingsTable.append("| Standing | Player | Points | Games played | Opp. Win % | | Standing | Player | Points | Games played | Opp. Win % |
");
- var secondColumnBaseIndex = Math.ceil(standings.length / 2);
+ var standings = [];
+ for (var k = 0; k < xmlstandings.length; k++) {
+ var standing = {};
+ var xmlstanding = xmlstandings[k];
+
+ standing.currentStanding = xmlstanding.getAttribute("standing");
+ standing.player = xmlstanding.getAttribute("player");
+ standing.points = parseInt(xmlstanding.getAttribute("points"));
+ standing.gamesPlayed = parseInt(xmlstanding.getAttribute("gamesPlayed"));
+ standing.opponentWinPerc = xmlstanding.getAttribute("opponentWin");
+ if (tournamentStage == "Finished")
+ standing.playerStr = "" + standing.player + "";
+ else
+ standing.playerStr = standing.player;
+
+ standings.push(standing);
+ }
+
+ standings.sort((a, b) => a.currentStanding - b.currentStanding);
+
+ var secondColumnBaseIndex = Math.ceil(standings.length / 2);
+
for (var k = 0; k < secondColumnBaseIndex; k++) {
var standing = standings[k];
- var currentStanding = standing.getAttribute("standing");
- var player = standing.getAttribute("player");
- var points = parseInt(standing.getAttribute("points"));
- var gamesPlayed = parseInt(standing.getAttribute("gamesPlayed"));
- var opponentWinPerc = standing.getAttribute("opponentWin");
-
- var playerStr;
- if (tournamentStage == "Finished")
- playerStr = "" + player + "";
- else
- playerStr = player;
-
- standingsTable.append("| " + currentStanding + " | " + playerStr + " | " + points + " | " + gamesPlayed + " | " + opponentWinPerc + " |
");
+
+ standingsTable.append("| " + standing.currentStanding + " | "
+ + standing.playerStr + " | " + standing.points
+ + " | " + standing.gamesPlayed + " | "
+ + standing.opponentWinPerc + " |
");
}
for (var k = secondColumnBaseIndex; k < standings.length; k++) {
var standing = standings[k];
- var currentStanding = standing.getAttribute("standing");
- var player = standing.getAttribute("player");
- var points = parseInt(standing.getAttribute("points"));
- var gamesPlayed = parseInt(standing.getAttribute("gamesPlayed"));
- var opponentWinPerc = standing.getAttribute("opponentWin");
- var playerStr;
- if (tournamentStage == "Finished")
- playerStr = "" + player + "";
- else
- playerStr = player;
-
- $("tr:eq(" + (k - secondColumnBaseIndex + 1) + ")", standingsTable).append(" | " + currentStanding + " | " + playerStr + " | " + points + " | " + gamesPlayed + " | " + opponentWinPerc + " | ");
+ $("tr:eq(" + (k - secondColumnBaseIndex + 1) + ")", standingsTable)
+ .append(" | " + standing.currentStanding + " | "
+ + standing.playerStr + " | " + standing.points
+ + " | " + standing.gamesPlayed + " | "
+ + standing.opponentWinPerc + " | ");
}
return standingsTable;