Tournament result display.
This commit is contained in:
@@ -57,6 +57,7 @@ public class TournamentResource extends AbstractResource {
|
||||
tournamentElem.setAttribute("format", _lotroFormatLibrary.getFormat(tournament.getFormat()).getName());
|
||||
tournamentElem.setAttribute("collection", tournament.getCollectionType().getFullName());
|
||||
tournamentElem.setAttribute("round", String.valueOf(tournament.getCurrentRound()));
|
||||
tournamentElem.setAttribute("finished", String.valueOf(tournament.isFinished()));
|
||||
|
||||
tournaments.appendChild(tournamentElem);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public class TournamentResource extends AbstractResource {
|
||||
|
||||
List<PlayerStanding> leagueStandings = tournament.getCurrentStandings();
|
||||
for (PlayerStanding standing : leagueStandings) {
|
||||
Element standingElem = doc.createElement("leagueStanding");
|
||||
Element standingElem = doc.createElement("tournamentStanding");
|
||||
setStandingAttributes(standing, standingElem);
|
||||
tournamentElem.appendChild(standingElem);
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@
|
||||
<script type="text/javascript" src="js/gemp-007/commonUi.js"></script>
|
||||
<script type="text/javascript" src="js/gemp-007/hallUi.js"></script>
|
||||
<script type="text/javascript" src="js/gemp-007/leagueResultsUi.js"></script>
|
||||
<script type="text/javascript" src="js/gemp-007/tournamentResultsUi.js"></script>
|
||||
<script type="text/javascript" src="js/gemp-007/gameHistoryUi.js"></script>
|
||||
<script type="text/javascript" src="js/gemp-007/communication.js"></script>
|
||||
<!-- This is needed for delivery -->
|
||||
@@ -298,6 +299,7 @@
|
||||
<ul>
|
||||
<li><a href="#gameHall">Game Hall</a></li>
|
||||
<li><a href="includes/gameHistory.html">Game History</a></li>
|
||||
<li><a href="includes/tournamentResults.html">Tournaments</a></li>
|
||||
<li><a href="includes/leagueResults.html">Leagues</a></li>
|
||||
<script type="text/javascript">
|
||||
document.write('<li><a href="includes/leagueRules.html?_=' + (new Date().getTime()) + '">League Rules (updated)</a></li>');
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(
|
||||
function () {
|
||||
var ui = new TournamentResultsUI("/gemp-lotr-server");
|
||||
});
|
||||
|
||||
</script>
|
||||
All times are GMT based.
|
||||
<div id="tournamentResults"></div>
|
||||
@@ -68,6 +68,19 @@ var GempLotrCommunication = Class.extend({
|
||||
});
|
||||
},
|
||||
|
||||
getLiveTournaments:function (callback, errorMap) {
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:this.url + "/tournament",
|
||||
cache:false,
|
||||
data:{
|
||||
participanId:getUrlParam("participantId") },
|
||||
success:this.deliveryCheck(callback),
|
||||
error:this.errorCheck(errorMap),
|
||||
dataType:"xml"
|
||||
});
|
||||
},
|
||||
|
||||
getLeagues:function (callback, errorMap) {
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
var TournamentResultsUI = Class.extend({
|
||||
communication:null,
|
||||
formatDialog:null,
|
||||
|
||||
init:function (url) {
|
||||
this.communication = new GempLotrCommunication(url,
|
||||
function (xhr, ajaxOptions, thrownError) {
|
||||
});
|
||||
|
||||
this.formatDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
modal:true,
|
||||
title:"Format description"
|
||||
});
|
||||
|
||||
this.loadLiveTournaments();
|
||||
},
|
||||
|
||||
loadLiveTournaments:function () {
|
||||
var that = this;
|
||||
this.communication.getLiveTournaments(
|
||||
function (xml) {
|
||||
that.loadedLiveTournaments(xml);
|
||||
});
|
||||
},
|
||||
|
||||
loadedTournament:function (xml) {
|
||||
var that = this;
|
||||
log(xml);
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == 'tournament') {
|
||||
$("#tournamentExtraInfo").html("");
|
||||
|
||||
var tournament = root;
|
||||
|
||||
var tournamentName = tournament.getAttribute("name");
|
||||
var tournamentFormat = tournament.getAttribute("format");
|
||||
var tournamentCollection = tournament.getAttribute("collection");
|
||||
var tournamentRound = tournament.getAttribute("round");
|
||||
var tournamentFinished = tournament.getAttribute("finished");
|
||||
|
||||
$("#tournamentExtraInfo").append("<div class='tournamentName'>" + tournamentName + "</div>");
|
||||
$("#tournamentExtraInfo").append("<div class='tournamentFormat'><b>Format:</b> " + tournamentFormat + "</div>");
|
||||
$("#tournamentExtraInfo").append("<div class='tournamentCollection'><b>Collection:</b> " + tournamentCollection + "</div>");
|
||||
if (tournamentFinished == "false")
|
||||
$("#tournamentExtraInfo").append("<div class='tournamentRound'><b>Round:</b> " + tournamentRound + "</div>");
|
||||
|
||||
var standings = tournament.getElementsByTagName("tournamentStanding");
|
||||
if (standings.length > 0)
|
||||
$("#tournamentExtraInfo").append(this.createStandingsTable(standings));
|
||||
}
|
||||
},
|
||||
|
||||
loadedLiveTournaments:function (xml) {
|
||||
var that = this;
|
||||
log(xml);
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == 'tournaments') {
|
||||
$("#tournamentResults").html("");
|
||||
|
||||
var tournaments = root.getElementsByTagName("tournament");
|
||||
for (var i = 0; i < tournaments.length; i++) {
|
||||
var tournament = tournaments[i];
|
||||
var tournamentName = tournament.getAttribute("name");
|
||||
var tournamentFormat = tournament.getAttribute("format");
|
||||
var tournamentCollection = tournament.getAttribute("collection");
|
||||
var tournamentRound = tournament.getAttribute("round");
|
||||
var tournamentFinished = tournament.getAttribute("finished");
|
||||
|
||||
$("#tournamentResults").append("<div class='tournamentName'>" + tournamentName + "</div>");
|
||||
$("#tournamentResults").append("<div class='tournamentRound'>" + tournamentRound + "</div>");
|
||||
|
||||
var detailsBut = $("<button>See details</button>").button();
|
||||
detailsBut.click(
|
||||
(function (type) {
|
||||
return function () {
|
||||
that.communication.getTournament(type,
|
||||
function (xml) {
|
||||
that.loadedTournament(xml);
|
||||
});
|
||||
};
|
||||
})(tournamentFormat));
|
||||
$("#tournamentResults").append(detailsBut);
|
||||
}
|
||||
if (tournaments.length == 0)
|
||||
$("#tournamentResults").append("<i>There is no running tournaments at the moment</i>");
|
||||
|
||||
$("#tournamentResults").append("<hr />");
|
||||
$("#tournamentResults").append("<div id='tournamentExtraInfo'></div>");
|
||||
}
|
||||
},
|
||||
|
||||
createStandingsTable:function (standings) {
|
||||
var standingsTable = $("<table class='standings'></table>");
|
||||
|
||||
standingsTable.append("<tr><th>Standing</th><th>Player</th><th>Points</th><th>Games played</th><th>Opp. Win %</th><th></th><th>Standing</th><th>Player</th><th>Points</th><th>Games played</th><th>Opp. Win %</th></tr>");
|
||||
|
||||
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");
|
||||
|
||||
standingsTable.append("<tr><td>" + currentStanding + "</td><td>" + player + "</td><td>" + points + "</td><td>" + gamesPlayed + "</td><td>" + opponentWinPerc + "</td></tr>");
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
$("tr:eq(" + (k - secondColumnBaseIndex + 1) + ")", standingsTable).append("<td></td><td>" + currentStanding + "</td><td>" + player + "</td><td>" + points + "</td><td>" + gamesPlayed + "</td><td>" + opponentWinPerc + "</td>");
|
||||
}
|
||||
|
||||
return standingsTable;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user