From c62472358296c31a0968180a4b8ec29110111ebb Mon Sep 17 00:00:00 2001 From: derped Date: Wed, 21 Apr 2021 10:46:18 +0200 Subject: [PATCH] Fix date input and make input fields smaller. --- berichtsheft/assets/css/notebook.css | 1 + berichtsheft/assets/js/notebook.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/berichtsheft/assets/css/notebook.css b/berichtsheft/assets/css/notebook.css index 18a853c..8e7af2c 100644 --- a/berichtsheft/assets/css/notebook.css +++ b/berichtsheft/assets/css/notebook.css @@ -7,6 +7,7 @@ body { } input { + font-size: 0.66em; width: 90%; height: 100%; } diff --git a/berichtsheft/assets/js/notebook.js b/berichtsheft/assets/js/notebook.js index 656e510..dc32bea 100644 --- a/berichtsheft/assets/js/notebook.js +++ b/berichtsheft/assets/js/notebook.js @@ -66,7 +66,6 @@ function populate(pnum) { if (typeof startDate === "undefined") { startDate = userdata.meta.start || [0,0,0]; } else { - startDate[1] -= 1; startDate[2] += 3; } } @@ -123,11 +122,10 @@ function getTotal(day) { st = st || null; day.querySelector(".subtotal").textContent = st; return st; - } function getDate(date) { - let d = date && new Date(...date) || new Date(); + let d = date && new Date(...((d)=>{d[1]-=1; return d;})([...date])) || new Date(); return `${String(d.getDate()).padStart(2, "0")}.${String(d.getMonth()+1).padStart(2, "0")}.${d.getFullYear()}` } @@ -222,7 +220,7 @@ 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.value = data[target[1]] && getDate(data[target[1]]) || e.textContent; input.classList = e.classList; input.pattern = "[0-9]{2}.[0-9]{2}.[0-9]{4}"; input.onblur = () => {