diff --git a/berichtsheft/assets/js/notebook.js b/berichtsheft/assets/js/notebook.js index ff8b998..656e510 100644 --- a/berichtsheft/assets/js/notebook.js +++ b/berichtsheft/assets/js/notebook.js @@ -62,7 +62,7 @@ function populate(pnum) { let startDate = data.start; if (typeof startDate === "undefined") { const dates = (pnum > 1) && app.children[pnum-2].getElementsByClassName("date") || []; - startDate = dates.length > 1 && dates[1].textContent.split(".").reverse().map(Number) || undefined + startDate = dates.length > 1 && dates[1].textContent.split(".").reverse().map(Number) || undefined; if (typeof startDate === "undefined") { startDate = userdata.meta.start || [0,0,0]; } else { @@ -209,16 +209,35 @@ function exportData() { e.click(); } -function editDayOpen(e) { - // Find page and day index - const getIndex = (n, e) => { - for (const i in n) { - if (n[i].contains(e)) { - return i; - } +function getIndex(n, e) { + // Find index of element (or object containing) e in nodelist n) + for (const i in n) { + if (n[i].contains(e)) { + return i; } - return null; + } + return null; +}; +function editDate(e, target) { + const page = getIndex(app.children, e); + const input = document.createElement("input"); + let data = target === "meta" && userdata["meta"] || userdata["pages"][page]; + input.value = getDate(data[target[1]]); + input.classList = e.classList; + input.pattern = "[0-9]{2}.[0-9]{2}.[0-9]{4}"; + input.onblur = () => { + data[target[1]] = input.value.split(".").reverse().map(Number); + e.style.display = "block"; + input.remove(); + populate(Number(page)+1); + save(); }; + e.style.display = "none"; + e.insertAdjacentElement("afterend", input); + input.focus(); +} + +function editDayOpen(e) { let page = getIndex(app.children, e); let day = (page !== null && getIndex(app.children[page].querySelectorAll(".day"), e)) diff --git a/berichtsheft/assets/templates/report.html b/berichtsheft/assets/templates/report.html index 49358f1..3cce194 100644 --- a/berichtsheft/assets/templates/report.html +++ b/berichtsheft/assets/templates/report.html @@ -5,9 +5,9 @@
Woche vom:
- +bis:
- +Ausbildungsbeginn:
- +Ausbildungsende:
- +Name: