Add export of json file

This commit is contained in:
Claude Brisson
2024-01-26 09:07:06 +01:00
parent a4c55c82e2
commit 0c378af406
4 changed files with 54 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ Canadian byo-yomi Byo-yomi canadien
Cancel Annuler
Change Mettre à jour
Chinese rules Règles chinoises
Choose format Choix du format
Close Fermer
Club Club
Compile from the sources Compiler depuis les sources 
@@ -33,6 +34,7 @@ Download the standalone web interface module which suits your need, then follow
Edit Éditer
Enter the magic word Entrer le mot magique
Export Exporter
Export tournament Exporter le tournoi
Family name Nom de famille
First name Prénom
Fischer timing Cadence Fisher
@@ -73,6 +75,8 @@ Pair-go tournament Tournoi de pair-go
Pairing Appariement
Pairings for round Appariement pour la ronde
Participation Participation
Publish Publier
Publish standings Publier le classement
Rank Niveau
Rating Classement
Register Inscrire
@@ -80,6 +84,7 @@ Registration Inscriptions
Rengo with 2 players teams Rengo par équipes de 2
Rengo with 3 players team Rengo par équipes de 3
Required field Champs requis
Reset Mac Mahon groups Réinitialiser les groupes Mac Mahon
Results Résultats
Results for round Résultats pour la ronde
Round-robin Toutes rondes

View File

@@ -100,6 +100,28 @@ onLoad(() => {
});
$('#export').on('click', e => {
modal('export-modal');
});
$('#export-pairgoth').on('click', e => {
close_modal();
let form = $('#tournament-infos')[0];
let shortName = form.val('shortName');
let hdrs = headers();
hdrs['Accept'] = 'application/json';
fetch(`${base}tour/${tour_id}`, {
headers: hdrs
}).then(resp => {
if (resp.ok) return resp.text()
else throw "export error"
}).then(txt => {
let blob = new Blob(['\uFEFF', txt.trim()], {type: 'application/json;charset=utf-8'});
downloadFile(blob, `${shortName}.tour`);
}).catch(err => showError(err));
});
$('#export-opengotha').on('click', e => {
close_modal();
let form = $('#tournament-infos')[0];
let shortName = form.val('shortName');
let hdrs = headers();

View File

@@ -235,3 +235,22 @@
</div>
</form>
</div>
<div id="export-modal" class="popup">
<div class="popup-body">
<div class="popup-header">
Export tournament
</div>
<div class="popup-content">
<div class="horz">
<span>Choose format</span>
<button id="export-pairgoth" type="button" class="ui blue floating button">Pairgoth</button>
<button id="export-opengotha" type="button" class="ui blue floating button">OpenGotha</button>
</div>
</div>
<div class="popup-footer">
<div class="form-actions">
<button type="button" class="ui gray floating cancel button">Cancel</button>
</div>
</div>
</div>
</div>

View File

@@ -94,17 +94,19 @@
<div id="publish-modal" class="popup">
<div class="popup-body">
<div class="popup-header">
Download Standings
Publish standings
</div>
<div class="popup-content">
Choose format
</div>
<div class="popup-footer">
<div class="form-actions">
<button type="button" class="ui gray floating cancel button">Cancel</button>
<div class="horz">
<span>Choose format</span>
<button type="button" class="ui blue floating publish-egf button">EGF</button>
<button type="button" class="ui blue floating publish-ffg button">FFG</button>
</div>
</div>
<div class="popup-footer">
<div class="form-actions">
<button type="button" class="ui gray floating cancel button">Cancel</button>
</div>
</div>
</div>
</div>