Debug export, handle export of by player
This commit is contained in:
@@ -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