From: Scott Worley Date: Thu, 27 Jan 2022 07:19:31 +0000 (-0800) Subject: Use CSS for filtering the view X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/8e91a18ee2db4b5595192f9772c5d375d4619efc?ds=inline Use CSS for filtering the view --- diff --git a/index.html b/index.html index 55c3b35..8453007 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + diff --git a/vopamoi.ts b/vopamoi.ts index b16bc70..f93c51c 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -100,9 +100,6 @@ const Model = { const task = this.getTask(createTimestamp); if (task) { task.setAttribute("data-state", state); - if (task instanceof HTMLElement) { - task.style.display = state == "todo" ? "block" : "none"; // Until view filtering - } } }, }; @@ -225,7 +222,7 @@ const BrowserUI = { firstVisibleTask: function () { for (const task of document.getElementsByClassName("task")) { - if (task instanceof HTMLElement && task.style.display !== "none") { + if (task instanceof HTMLElement && task.getAttribute("data-state")! === "todo") { return task; } } @@ -243,7 +240,7 @@ const BrowserUI = { while (true) { cursor = increment > 0 ? cursor.nextElementSibling : cursor.previousElementSibling; if (!cursor || !(cursor instanceof HTMLElement)) break; - if (cursor.style.display !== "none") { + if (cursor.getAttribute("data-state")! === "todo") { offset -= increment; valid_cursor = cursor; } @@ -294,7 +291,7 @@ const BrowserUI = { setState: function (newState: string) { const task = document.activeElement; if (!task) return; - const oldState = task.getAttribute("data-state"); + const oldState = task.getAttribute("data-state")!; if (newState === oldState) return; const createTimestamp = task.getAttribute("data-created")!; this.moveCursor(1) || this.moveCursor(-1);