Debug export, handle export of by player
This commit is contained in:
@@ -222,13 +222,14 @@ object OpenGotha {
|
||||
<Games>
|
||||
// TODO - table number is not any more kinda random like this
|
||||
${(1..tournament.lastRound()).map { tournament.games(it) }.flatMapIndexed { index, games ->
|
||||
games.values.mapIndexed { table, game ->
|
||||
Triple(index + 1, table , game)
|
||||
games.values.mapIndexedNotNull { table, game ->
|
||||
if (game.black == 0 || game.white == 0) null
|
||||
else Triple(index + 1, table , game)
|
||||
}
|
||||
}.joinToString("\n") { (round, table, game) ->
|
||||
"""<Game blackPlayer="${
|
||||
(tournament.pairables[game.black]!! as Player).let { black ->
|
||||
"${black.name}${black.firstname}".uppercase(Locale.ENGLISH) // Use Locale.ENGLISH to transform é to É
|
||||
"${black.name.replace(" ", "")}${black.firstname.replace(" ", "")}".uppercase(Locale.ENGLISH) // Use Locale.ENGLISH to transform é to É
|
||||
}
|
||||
}" handicap="0" knownColor="true" result="${
|
||||
when (game.result) {
|
||||
@@ -252,6 +253,20 @@ object OpenGotha {
|
||||
}
|
||||
</Games>
|
||||
<ByePlayer>
|
||||
${
|
||||
(1..tournament.lastRound()).map { round ->
|
||||
tournament.games(round).values.firstNotNullOfOrNull { g ->
|
||||
if (g.black == 0 || g.white == 0) g else null
|
||||
}?.let {
|
||||
tournament.pairables[
|
||||
if (it.black == 0) it.white
|
||||
else it.black
|
||||
] as Player
|
||||
}?.let { p ->
|
||||
"<ByePlayer player=\"${p.name.replace(" ", "")}${p.firstname.replace(" ", "")}\" roundNumber=\"${round}\"/>"
|
||||
}
|
||||
}.joinToString("\n")
|
||||
}
|
||||
</ByePlayer>
|
||||
<TournamentParameterSet>
|
||||
<GeneralParameterSet bInternet="${tournament.online}" basicTime="${tournament.timeSystem.mainTime}" beginDate="${tournament.startDate}" canByoYomiTime="${tournament.timeSystem.byoyomi}" complementaryTimeSystem="${when(tournament.timeSystem.type) {
|
||||
|
@@ -165,6 +165,7 @@ function close_modal() {
|
||||
|
||||
function downloadFile(blob, filename) {
|
||||
let url = URL.createObjectURL(blob);
|
||||
let link = document.createElement("a");
|
||||
link.setAttribute("href", url);
|
||||
link.setAttribute("download", filename);
|
||||
link.style.visibility = 'hidden';
|
||||
|
@@ -102,15 +102,15 @@ onLoad(() => {
|
||||
$('#export').on('click', e => {
|
||||
let form = $('#tournament-infos')[0];
|
||||
let shortName = form.val('shortName');
|
||||
let headers = headers();
|
||||
headers['Accept'] = 'application/xml';
|
||||
let hdrs = headers();
|
||||
hdrs['Accept'] = 'application/xml';
|
||||
fetch(`${base}tour/${tour_id}`, {
|
||||
headers: headers
|
||||
headers: hdrs
|
||||
}).then(resp => {
|
||||
if (resp.ok) return resp.text()
|
||||
else throw "export error"
|
||||
}).then(txt => {
|
||||
let blob = new Blob(['\uFEFF', txt], {type: 'application/xml;charset=utf-8'});
|
||||
let blob = new Blob(['\uFEFF', txt.trim()], {type: 'application/xml;charset=utf-8'});
|
||||
downloadFile(blob, `${shortName}.xml`);
|
||||
}).catch(err => showError(err));
|
||||
});
|
||||
|
Reference in New Issue
Block a user