From 13eaa77a40cd65ec40ebbcb8b94a9527bf379eef Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Thu, 29 Feb 2024 17:53:33 +0100 Subject: [PATCH] Add HTML format for output --- view-webapp/src/main/webapp/js/main.js | 4 ++++ .../src/main/webapp/js/tour-standings.inc.js | 17 ++++++++++++++++- .../src/main/webapp/tour-standings.inc.html | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/view-webapp/src/main/webapp/js/main.js b/view-webapp/src/main/webapp/js/main.js index 0a4cad2..0f8e610 100644 --- a/view-webapp/src/main/webapp/js/main.js +++ b/view-webapp/src/main/webapp/js/main.js @@ -281,4 +281,8 @@ onLoad(() => { title.toggleClass('active'); content.toggleClass('active'); }); + $('#dimmer').on('click', e => { + let dialog = e.target.closest('.popup'); + if (!dialog) close_modal(); + }); }); diff --git a/view-webapp/src/main/webapp/js/tour-standings.inc.js b/view-webapp/src/main/webapp/js/tour-standings.inc.js index 9c0b6d6..b185732 100644 --- a/view-webapp/src/main/webapp/js/tour-standings.inc.js +++ b/view-webapp/src/main/webapp/js/tour-standings.inc.js @@ -9,12 +9,22 @@ function publish(format, extension) { if (resp.ok) return resp.text() else throw "publish error" }).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}`); close_modal(); }).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(() => { $('.criterium').on('click', e => { let alreadyOpen = e.target.closest('select'); @@ -59,13 +69,18 @@ onLoad(() => { $('#publish').on('click', e => { modal('publish-modal'); }); +/* $('#publish-modal').on('click', e => { close_modal(); }); +*/ $('.publish-ffg').on('click', e => { publish('ffg', 'tou'); }); $('.publish-egf').on('click', e => { publish('egf', 'h9'); }); + $('.publish-html').on('click', e => { + publishHtml(); + }); }); diff --git a/view-webapp/src/main/webapp/tour-standings.inc.html b/view-webapp/src/main/webapp/tour-standings.inc.html index 0ef93f0..084485c 100644 --- a/view-webapp/src/main/webapp/tour-standings.inc.html +++ b/view-webapp/src/main/webapp/tour-standings.inc.html @@ -99,13 +99,14 @@