From 99132f168ebd7da304bd38b8b5048501bba4087c Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Mon, 22 Jun 2026 05:12:19 +0000 Subject: [PATCH] feat: notes section with details, checkoff, timestamps, localStorage persistence --- index.html | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) diff --git a/index.html b/index.html index cd1831d..1de8749 100644 --- a/index.html +++ b/index.html @@ -404,7 +404,206 @@ now.toLocaleTimeString('en-US', {hour:'2-digit',minute:'2-digit',second:'2-digit'}); } tick(); setInterval(tick, 1000); + + // ── Notes ────────────────────────────────────────────────────────────── + const NOTES_KEY = 'dashboard_notes'; + + function loadNotes() { + return JSON.parse(localStorage.getItem(NOTES_KEY) || '[]'); + } + function saveNotes(notes) { + localStorage.setItem(NOTES_KEY, JSON.stringify(notes)); + } + + function renderNotes() { + const notes = loadNotes(); + const list = document.getElementById('notes-list'); + if (!list) return; + if (!notes.length) { + list.innerHTML = '
No notes yet. Add one above.
'; + return; + } + list.innerHTML = notes.map((n, i) => ` +
+ +
+
${escHtml(n.text)}
+ ${n.detail ? `
${escHtml(n.detail)}
` : ''} +
${new Date(n.ts).toLocaleString('en-US',{month:'short',day:'numeric',hour:'2-digit',minute:'2-digit'})}
+
+ +
`).join(''); + } + + function escHtml(s) { + return String(s).replace(/&/g,'&').replace(//g,'>').replace(/\n/g,'
'); + } + + function addNote() { + const txt = document.getElementById('note-input').value.trim(); + const det = document.getElementById('note-detail').value.trim(); + if (!txt) { document.getElementById('note-input').focus(); return; } + const notes = loadNotes(); + notes.unshift({ text: txt, detail: det, done: false, ts: Date.now() }); + saveNotes(notes); + document.getElementById('note-input').value = ''; + document.getElementById('note-detail').value = ''; + document.getElementById('note-detail').style.display = 'none'; + document.getElementById('note-detail-toggle').textContent = '+ Add details'; + renderNotes(); + } + + function toggleNote(i) { + const notes = loadNotes(); + notes[i].done = !notes[i].done; + saveNotes(notes); + renderNotes(); + } + + function deleteNote(i) { + const notes = loadNotes(); + notes.splice(i, 1); + saveNotes(notes); + renderNotes(); + } + + function clearDone() { + saveNotes(loadNotes().filter(n => !n.done)); + renderNotes(); + } + + function toggleDetail() { + const d = document.getElementById('note-detail'); + const btn = document.getElementById('note-detail-toggle'); + const show = d.style.display === 'none'; + d.style.display = show ? 'block' : 'none'; + btn.textContent = show ? '− Hide details' : '+ Add details'; + if (show) d.focus(); + } + + document.addEventListener('DOMContentLoaded', () => { + renderNotes(); + document.getElementById('note-input').addEventListener('keydown', e => { + if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); addNote(); } + }); + }); + + + +
+
+
📝 Notes
+ +
+ +
+
+ + +
+ + +
+ +
+
+