CSV export

This commit is contained in:
Claude Brisson
2024-03-15 20:59:19 +01:00
parent fb710fd219
commit 5ebb21b3b0
5 changed files with 50 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ function publish(format, extension) {
let shortName = form.val('shortName');
let encoding = $('#encoding')[0].value;
let hdrs = headers();
hdrs['Accept'] = `application/${format};charset=${encoding}`
hdrs['Accept'] = `${format};charset=${encoding}`
fetch(`api/tour/${tour_id}/standings/${activeRound}`, {
headers: hdrs
}).then(resp => {
@@ -20,7 +20,6 @@ function publish(format, extension) {
function publishHtml() {
let html = $('#standings-table')[0].outerHTML;
console.log(html)
let form = $('#tournament-infos')[0];
let shortName = form.val('shortName');
let blob = new Blob(['\uFEFF', html], {type: 'text/html;charset=utf-8'});
@@ -78,10 +77,13 @@ onLoad(() => {
});
*/
$('.publish-ffg').on('click', e => {
publish('ffg', 'tou');
publish('application/ffg', 'tou');
});
$('.publish-egf').on('click', e => {
publish('egf', 'h9');
publish('application/egf', 'h9');
});
$('.publish-csv').on('click', e => {
publish('text/csv', 'csv');
});
$('.publish-html').on('click', e => {
publishHtml();

View File

@@ -112,6 +112,7 @@
<label>Choose format</label>
<div class="inline fields">
<button type="button" class="ui blue floating publish-html button">HTML</button>
<button type="button" class="ui blue floating publish-csv button">CSV</button>
<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>