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
|
||||
Edit Éditer
|
||||
Enter the magic word Entrer le mot magique
|
||||
Export Exporter
|
||||
Family name Nom de famille
|
||||
First name Prénom
|
||||
Fischer timing Cadence Fisher
|
||||
|
@@ -163,34 +163,16 @@ function close_modal() {
|
||||
$(`.popup`).removeClass('shown');
|
||||
}
|
||||
|
||||
function screenshot() {
|
||||
const bodyContent = document.body.innerHTML;
|
||||
|
||||
// Create an SVG element
|
||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
svg.setAttribute('width', window.innerWidth);
|
||||
svg.setAttribute('height', window.innerHeight);
|
||||
|
||||
// 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">');
|
||||
function downloadFile(blob, filename) {
|
||||
let url = URL.createObjectURL(blob);
|
||||
link.setAttribute("href", url);
|
||||
link.setAttribute("download", filename);
|
||||
link.style.visibility = 'hidden';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
|
||||
onLoad(() => {
|
||||
$('button.close').on('click', e => {
|
||||
let modal = e.target.closest('.popup');
|
||||
|
@@ -99,6 +99,22 @@ onLoad(() => {
|
||||
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 => {
|
||||
e.preventDefault();
|
||||
let form = e.target;
|
||||
|
@@ -215,6 +215,10 @@
|
||||
<i class="times icon"></i>
|
||||
Close
|
||||
</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">
|
||||
<i class="pencil icon"></i>
|
||||
Edit
|
||||
|
Reference in New Issue
Block a user