Add HTML format for output

This commit is contained in:
Claude Brisson
2024-02-29 17:53:33 +01:00
parent 2020db53af
commit 13eaa77a40
3 changed files with 22 additions and 2 deletions

View File

@@ -281,4 +281,8 @@ onLoad(() => {
title.toggleClass('active'); title.toggleClass('active');
content.toggleClass('active'); content.toggleClass('active');
}); });
$('#dimmer').on('click', e => {
let dialog = e.target.closest('.popup');
if (!dialog) close_modal();
});
}); });

View File

@@ -9,12 +9,22 @@ function publish(format, extension) {
if (resp.ok) return resp.text() if (resp.ok) return resp.text()
else throw "publish error" else throw "publish error"
}).then(txt => { }).then(txt => {
let blob = new Blob(['\uFEFF', txt.trim()], {type: 'plain/text;charset=utf-8'}); let blob = new Blob(['\uFEFF', txt.trim()], {type: 'text/plain;charset=utf-8'});
downloadFile(blob, `${shortName}.${extension}`); downloadFile(blob, `${shortName}.${extension}`);
close_modal(); close_modal();
}).catch(err => showError(err)); }).catch(err => showError(err));
} }
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'});
downloadFile(blob, `${shortName}-standings-R${activeRound}.html`);
close_modal();
}
onLoad(() => { onLoad(() => {
$('.criterium').on('click', e => { $('.criterium').on('click', e => {
let alreadyOpen = e.target.closest('select'); let alreadyOpen = e.target.closest('select');
@@ -59,13 +69,18 @@ onLoad(() => {
$('#publish').on('click', e => { $('#publish').on('click', e => {
modal('publish-modal'); modal('publish-modal');
}); });
/*
$('#publish-modal').on('click', e => { $('#publish-modal').on('click', e => {
close_modal(); close_modal();
}); });
*/
$('.publish-ffg').on('click', e => { $('.publish-ffg').on('click', e => {
publish('ffg', 'tou'); publish('ffg', 'tou');
}); });
$('.publish-egf').on('click', e => { $('.publish-egf').on('click', e => {
publish('egf', 'h9'); publish('egf', 'h9');
}); });
$('.publish-html').on('click', e => {
publishHtml();
});
}); });

View File

@@ -99,13 +99,14 @@
<div class="popup-content"> <div class="popup-content">
<div class="horz"> <div class="horz">
<span>Choose format</span> <span>Choose format</span>
<button type="button" class="ui blue floating publish-html button">HTML</button>
<button type="button" class="ui blue floating publish-egf button">EGF</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> <button type="button" class="ui blue floating publish-ffg button">FFG</button>
</div> </div>
</div> </div>
<div class="popup-footer"> <div class="popup-footer">
<div class="form-actions"> <div class="form-actions">
<button type="button" class="ui gray floating cancel button">Cancel</button> <button type="button" class="ui gray floating close button">Cancel</button>
</div> </div>
</div> </div>
</div> </div>