Export in progress
This commit is contained in:
@@ -32,6 +32,7 @@ Download Télécharger
|
|||||||
Download the standalone web interface module which suits your need, then follow Télécharger le module d’interface web qui correspond à vos besoins, puis suivez
|
Download the standalone web interface module which suits your need, then follow Télécharger le module d’interface web qui correspond à vos besoins, puis suivez
|
||||||
Edit Éditer
|
Edit Éditer
|
||||||
Enter the magic word Entrer le mot magique
|
Enter the magic word Entrer le mot magique
|
||||||
|
Export Exporter
|
||||||
Family name Nom de famille
|
Family name Nom de famille
|
||||||
First name Prénom
|
First name Prénom
|
||||||
Fischer timing Cadence Fisher
|
Fischer timing Cadence Fisher
|
||||||
|
@@ -163,34 +163,16 @@ function close_modal() {
|
|||||||
$(`.popup`).removeClass('shown');
|
$(`.popup`).removeClass('shown');
|
||||||
}
|
}
|
||||||
|
|
||||||
function screenshot() {
|
function downloadFile(blob, filename) {
|
||||||
const bodyContent = document.body.innerHTML;
|
let url = URL.createObjectURL(blob);
|
||||||
|
link.setAttribute("href", url);
|
||||||
// Create an SVG element
|
link.setAttribute("download", filename);
|
||||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
link.style.visibility = 'hidden';
|
||||||
svg.setAttribute('width', window.innerWidth);
|
document.body.appendChild(link);
|
||||||
svg.setAttribute('height', window.innerHeight);
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
// Create a foreignObject element
|
|
||||||
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
||||||
foreignObject.setAttribute('width', '100%');
|
|
||||||
foreignObject.setAttribute('height', '100%');
|
|
||||||
|
|
||||||
// Append the body content to foreignObject
|
|
||||||
foreignObject.innerHTML = bodyContent;
|
|
||||||
|
|
||||||
// Append foreignObject to the SVG
|
|
||||||
svg.appendChild(foreignObject);
|
|
||||||
|
|
||||||
// Create a data URL from the SVG
|
|
||||||
const dataUrl = 'data:image/svg+xml,' + encodeURIComponent(new XMLSerializer().serializeToString(svg));
|
|
||||||
|
|
||||||
// Open the screenshot in a new window/tab (optional)
|
|
||||||
const screenshotWindow = window.open();
|
|
||||||
screenshotWindow.document.write('<img src="' + dataUrl + '" alt="Screenshot">');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
$('button.close').on('click', e => {
|
$('button.close').on('click', e => {
|
||||||
let modal = e.target.closest('.popup');
|
let modal = e.target.closest('.popup');
|
||||||
|
@@ -99,6 +99,22 @@ onLoad(() => {
|
|||||||
overwrite: true
|
overwrite: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#export').on('click', e => {
|
||||||
|
let form = $('#tournament-infos')[0];
|
||||||
|
let shortName = form.val('shortName');
|
||||||
|
let headers = headers();
|
||||||
|
headers['Accept'] = 'application/xml';
|
||||||
|
fetch(`${base}tour/${tour_id}`, {
|
||||||
|
headers: headers
|
||||||
|
}).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'});
|
||||||
|
downloadFile(blob, `${shortName}.xml`);
|
||||||
|
}).catch(err => showError(err));
|
||||||
|
});
|
||||||
|
|
||||||
$('#tournament-infos').on('submit', e => {
|
$('#tournament-infos').on('submit', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let form = e.target;
|
let form = e.target;
|
||||||
|
@@ -215,6 +215,10 @@
|
|||||||
<i class="times icon"></i>
|
<i class="times icon"></i>
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
|
<button id="export" type="button" class="ui yellow right labeled icon floating button">
|
||||||
|
<i class="download icon"></i>
|
||||||
|
Export
|
||||||
|
</button>
|
||||||
<button id="edit" class="ui blue right labeled icon floating info button">
|
<button id="edit" class="ui blue right labeled icon floating info button">
|
||||||
<i class="pencil icon"></i>
|
<i class="pencil icon"></i>
|
||||||
Edit
|
Edit
|
||||||
|
Reference in New Issue
Block a user