Debug export, handle export of by player

This commit is contained in:
Claude Brisson
2023-12-27 12:19:25 +01:00
parent 797ac17b74
commit 23bb6cb86d
3 changed files with 23 additions and 7 deletions

View File

@@ -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';

View File

@@ -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));
});