xparagon / flip2learn

2 stars 1 forks source link

The Export button does not work on mobile #6

Closed xparagon closed 1 year ago

xparagon commented 1 year ago

On a PC there is no problem

xparagon commented 1 year ago

ChatGPT suggest this:

async function saveFile() {
    const fileContent = 'Flip  \n' + ((new Date()).toDateString()) + '\n' + words.length + ' words\n\n\n';
    let exportedWords = '';
    words.forEach(line => {
        if (!(line.word === '' || line.meaning === '')) {
            exportedWords += line.word + '\n' + line.meaning + '\n\n';
        }
    });
    const fileContent = fileContent + exportedWords + '\n\nhttps://flip.fred.technology/\n' + '\n\nhttps://sprakverksted.no/\n';
    const blob = new Blob([fileContent], {type: 'text/plain'});
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = url;
    a.download = 'Flip - ' + ((new Date()).toDateString()) + '.txt';
    document.body.appendChild(a);
    a.click();
    window.URL.revokeObjectURL(url);
    a.remove();
    setMessage(labels.msgSaved.at(language - 1) as string);
}
xparagon commented 1 year ago

thank you GPT!