Beginning of menu implementation for importing files

This commit is contained in:
KingOfDog
2019-03-05 19:18:21 +01:00
parent 85ee4b117a
commit 3ff3c90cf6
3 changed files with 47 additions and 3 deletions

View File

@@ -96,14 +96,21 @@ function importFromJson(json) {
}
function exportToFile() {
const name = 'placeholder.fsm';
const json = exportToJson();
if(activeDocument === null) {
return;
}
const document = documents[activeDocument];
const name = `${new Date(document.createdAt).toLocaleDateString()} - ${document.name || 'Unbenannt'}.fsm`;
const json = exportToJson(document);
downloadFile(name, json, 'application/json');
}
function downloadFile(name, content, type) {
const element = document.createElement('a');
console.log(content);
element.setAttribute('href', `data:${type},charset=utf-8,${content}`);
element.setAttribute('download', name);