Let user specify encoding for export
This commit is contained in:
@@ -32,6 +32,7 @@ Dates Dates
|
||||
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
|
||||
Encoding Encodage
|
||||
Enter the magic word Entrer le mot magique
|
||||
Export Exporter
|
||||
Export tournament Exporter le tournoi
|
||||
|
@@ -1,15 +1,18 @@
|
||||
function publish(format, extension) {
|
||||
let form = $('#tournament-infos')[0];
|
||||
let shortName = form.val('shortName');
|
||||
let encoding = $('#encoding')[0].value;
|
||||
let hdrs = headers();
|
||||
hdrs['Accept'] = `application/${format}`
|
||||
hdrs['Accept'] = `application/${format};charset=${encoding}`
|
||||
fetch(`api/tour/${tour_id}/standings/${activeRound}`, {
|
||||
headers: hdrs
|
||||
}).then(resp => {
|
||||
if (resp.ok) return resp.text()
|
||||
if (resp.ok) return resp.arrayBuffer()
|
||||
else throw "publish error"
|
||||
}).then(txt => {
|
||||
let blob = new Blob(['\uFEFF', txt.trim()], {type: 'text/plain;charset=utf-8'});
|
||||
}).then(bytes => {
|
||||
let blob = new Blob(
|
||||
encoding === 'utf-8' ? ['\uFEFF', bytes] : [bytes],
|
||||
{ type: `text/plain;charset=${encoding}` });
|
||||
downloadFile(blob, `${shortName}.${extension}`);
|
||||
close_modal();
|
||||
}).catch(err => showError(err));
|
||||
|
@@ -88,7 +88,10 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="right form-actions">
|
||||
<button id="publish" class="ui yellow floating button">Publish</button>
|
||||
<button id="publish" class="ui yellow floating right labeled icon button">
|
||||
<i class="paper plane outline icon"></i>
|
||||
Publish
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="publish-modal" class="popup">
|
||||
@@ -97,12 +100,23 @@
|
||||
Publish standings
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
<div class="horz">
|
||||
<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-ffg button">FFG</button>
|
||||
</div>
|
||||
<form class="ui edit form">
|
||||
<div class="field">
|
||||
<label>Encoding</label>
|
||||
<select id="encoding">
|
||||
<option value="utf-8">UTF-8</option>
|
||||
<option value="iso-8859-1">ISO 8859-1</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Choose format</label>
|
||||
<div class="inline fields">
|
||||
<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-ffg button">FFG</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="popup-footer">
|
||||
<div class="form-actions">
|
||||
|
Reference in New Issue
Block a user