|
|
|
@ -27,6 +27,7 @@ async function init() { |
|
|
|
|
"report": await fetchTemplate("report"), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
userdata.pages = userdata.pages || []; |
|
|
|
|
[...app.children].forEach(child => app.removeChild(child)) |
|
|
|
|
|
|
|
|
|
userdata.pages.forEach((e,i) => { |
|
|
|
@ -138,3 +139,51 @@ userdata = JSON.parse(localStorage.getItem("userdata")) || |
|
|
|
|
function save() { |
|
|
|
|
localStorage.setItem("userdata", JSON.stringify(userdata)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function hideOverlay() { |
|
|
|
|
document.getElementById("overlay").style.display = "none"; |
|
|
|
|
document.getElementById("import").style.display = "none"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function ignoreData(event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showImport(event) { |
|
|
|
|
document.getElementById("overlay").style.display = "block"; |
|
|
|
|
document.getElementById("import").style.display = "block"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function importData(event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
if (event.dataTransfer.items) { |
|
|
|
|
[...event.dataTransfer.items].forEach(f => { |
|
|
|
|
if (f.kind == "file") { |
|
|
|
|
f.getAsFile().text().then(t => { |
|
|
|
|
userdata = JSON.parse(t); |
|
|
|
|
init(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
[...event.dataTransfer.files].forEach(f => { |
|
|
|
|
if (f.kind == "file") { |
|
|
|
|
f.text().then(t => { |
|
|
|
|
userdata = JSON.parse(t); |
|
|
|
|
init(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
document.getElementById("overlay").style.display = "none"; |
|
|
|
|
document.getElementById("import").style.display = "none"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function exportData() { |
|
|
|
|
const e = document.createElement('a'); |
|
|
|
|
e.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userdata))); |
|
|
|
|
e.setAttribute('download', "Berichtsheft.json"); |
|
|
|
|
e.click(); |
|
|
|
|
} |
|
|
|
|