X-Git-Url: http://git.scottworley.com/vopamoi/blobdiff_plain/c2226333bbb69b5110aa5feaf839347321dca9ee..58b569ce38e1d658d0cdfb31d53f2cad2d00e5bd:/vopamoi.ts?ds=inline diff --git a/vopamoi.ts b/vopamoi.ts index 7777f36..931505b 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -355,6 +355,17 @@ function BrowserUI() { } }, + currentTag: function (): Element | null { + var target = document.activeElement; + if (!target) return null; + if (target.classList.contains("task")) { + const tags = target.getElementsByClassName("tag"); + target = tags[tags.length - 1]; + } + if (!target || !target.classList.contains("tag")) return null; + return target; + }, + firstVisibleTask: function () { for (const task of document.getElementsByClassName("task")) { const state = task.getAttribute("data-state"); @@ -436,16 +447,15 @@ function BrowserUI() { }, removeTag: function () { - var target = document.activeElement; + const target = this.currentTag(); if (!target) return; - if (target.classList.contains("task")) { - const tags = target.getElementsByClassName("tag"); - target = tags[tags.length - 1]; - } - if (!target || !target.classList.contains("tag")) return; ui.removeTag(target.parentElement!.getAttribute("data-created")!, target.textContent!); }, + resetView: function () { + this.setView("todo"); + }, + returnFocusAfterInput: function (): boolean { if (taskFocusedBeforeJumpingToInput) { taskFocusedBeforeJumpingToInput.focus(); @@ -574,7 +584,7 @@ function handleKey(event: any) { if (event.key == "d") return browserUI.setView("done"); if (event.key == "q") return browserUI.setView("todo"); if (event.key == "s") return (inputState = InputState.VS); - if (event.key == "v") return browserUI.setView("todo"); + if (event.key == "v") return browserUI.resetView(); if (event.key == "w") return browserUI.setView("waiting"); if (event.key == "x") return browserUI.setView("deleted"); } else if (inputState === InputState.VS) {