From bad1467f0f5813a5c6808c2e18e999dae9aae26f Mon Sep 17 00:00:00 2001 From: mikael-lovqvists-claude-agent Date: Sun, 17 May 2026 22:43:52 +0000 Subject: [PATCH] Allow any type for sub entries; add creation timestamp to rows Co-Authored-By: Claude Sonnet 4.6 --- public/app.mjs | 22 +++++++++++++++++++++- public/style.css | 6 ++++++ public/templates.html | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/public/app.mjs b/public/app.mjs index e2d9ae1..3538310 100644 --- a/public/app.mjs +++ b/public/app.mjs @@ -44,6 +44,22 @@ function fill_markdown(el, text) { render_markdown(text).then(html => { el.innerHTML = html; }); } +// --------------------------------------------------------------------------- +// Formatting +// --------------------------------------------------------------------------- + +function format_time(ms) { + const diff = Date.now() - ms; + const m = Math.floor(diff / 60000); + const h = Math.floor(diff / 3600000); + const d = Math.floor(diff / 86400000); + if (m < 1) { return 'just now'; } + if (m < 60) { return `${m}m ago`; } + if (h < 24) { return `${h}h ago`; } + if (d < 7) { return `${d}d ago`; } + return new Date(ms).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: d > 365 ? 'numeric' : undefined }); +} + // --------------------------------------------------------------------------- // Tree helpers // --------------------------------------------------------------------------- @@ -397,7 +413,11 @@ function make_entry_row(entry, children_map) { tags_el.appendChild(span); } - row.querySelector('.btn-sub').addEventListener('click', () => open_add_dialog(entry.id, entry.type)); + const time_el = row.querySelector('.task-time'); + time_el.textContent = format_time(entry.created_at); + time_el.title = new Date(entry.created_at).toLocaleString(); + + row.querySelector('.btn-sub').addEventListener('click', () => open_add_dialog(entry.id, null)); row.querySelector('.btn-edit').addEventListener('click', () => open_edit_dialog(entry)); row.querySelector('.btn-delete').addEventListener('click', () => confirm_delete(entry)); diff --git a/public/style.css b/public/style.css index 5790349..f7cca95 100644 --- a/public/style.css +++ b/public/style.css @@ -141,6 +141,12 @@ main { padding: 1.25rem; } margin-top: 0.1rem; } +.task-time { + font-size: 11px; + color: #555; + margin-left: auto; +} + .task-row[data-priority='high'] { border-left-color: #e05555; } .task-row[data-priority='normal'] { border-left-color: #5588e0; } .task-row[data-priority='low'] { border-left-color: #555; } diff --git a/public/templates.html b/public/templates.html index d6b7c65..b7ab85f 100644 --- a/public/templates.html +++ b/public/templates.html @@ -12,6 +12,7 @@