]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
Accept "vv" for jumping to the default view
[vopamoi] / vopamoi.ts
index 633ffefba8a52067eb77584c1494cac78d45e4fd..366edd6c3fc6803f0e4de311184d36f5d67d7e39 100644 (file)
@@ -235,18 +235,17 @@ function BrowserUI() {
   return {
     addTask: function (event: KeyboardEvent) {
       const input = <HTMLInputElement>document.getElementById("taskName");
-      if (input.value) {
-        const task = ui.addTask(input.value);
-        if (currentViewState === "todo") {
-          task instanceof HTMLElement && task.focus();
-        } else if (this.returnFocusAfterInput()) {
-        } else {
-          this.firstVisibleTask()?.focus();
-        }
-        input.value = "";
-        if (event.getModifierState("Control")) {
-          this.setPriority(task, null, document.getElementsByClassName("task")[0]);
-        }
+      if (input.value.match(/^ *$/)) return;
+      const task = ui.addTask(input.value);
+      if (currentViewState === "todo") {
+        task instanceof HTMLElement && task.focus();
+      } else if (this.returnFocusAfterInput()) {
+      } else {
+        this.firstVisibleTask()?.focus();
+      }
+      input.value = "";
+      if (event.getModifierState("Control")) {
+        this.setPriority(task, null, document.getElementsByClassName("task")[0]);
       }
     },
 
@@ -288,7 +287,7 @@ function BrowserUI() {
       task.removeChild(input);
       task.removeAttribute("data-description");
       task.focus();
-      if (newDescription === oldDescription || resolution === CommitOrAbort.Abort) {
+      if (resolution === CommitOrAbort.Abort || newDescription.match(/^ *$/) || newDescription === oldDescription) {
         desc.textContent = oldDescription;
       } else {
         ui.edit(task.getAttribute("data-created")!, newDescription, oldDescription);
@@ -302,7 +301,7 @@ function BrowserUI() {
       input.removeEventListener("blur", this.completeTagEdit);
       task.removeChild(input);
       task.focus();
-      if (resolution === CommitOrAbort.Commit && newTagName && !Model.hasTag(task, newTagName)) {
+      if (resolution === CommitOrAbort.Commit && !newTagName.match(/^ *$/) && !Model.hasTag(task, newTagName)) {
         ui.addTag(task.getAttribute("data-created")!, newTagName);
         lastTagNameEntered = newTagName;
       }
@@ -458,6 +457,7 @@ function handleKey(event: any) {
       if (event.key == "d") return browserUI.setView("done", "LawnGreen");
       if (event.key == "q") return browserUI.setView("todo", "White");
       if (event.key == "s") return browserUI.setView("someday-maybe", "DeepSkyBlue");
+      if (event.key == "v") return browserUI.setView("todo", "White");
       if (event.key == "w") return browserUI.setView("waiting", "MediumOrchid");
       if (event.key == "x") return browserUI.setView("deleted", "Black");
     }