]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
Hide task list during replay
[vopamoi] / vopamoi.ts
index 5f759d08588cfa18d24da7f07e41df026d565c1d..f550fa1cbbbd1ea9fa309a60d0d5e549dd5aacf0 100644 (file)
@@ -207,6 +207,7 @@ function Log(prefix: string = "vp-") {
     },
 
     replay: function () {
+      document.getElementById("tasks")!.style.display = "none";
       while (true) {
         const entry = window.localStorage.getItem(`${prefix}${next_log_index}`);
         if (entry === null) {
@@ -215,6 +216,7 @@ function Log(prefix: string = "vp-") {
         this.apply(entry);
         next_log_index++;
       }
+      document.getElementById("tasks")!.style.display = "";
     },
   };
 }
@@ -378,8 +380,9 @@ function BrowserUI() {
       return target as HTMLElement;
     },
 
-    firstVisibleTask: function () {
-      for (const task of document.getElementsByClassName("task")) {
+    firstVisibleTask: function (root: Element | null = null) {
+      if (root === null) root = document.body;
+      for (const task of root.getElementsByClassName("task")) {
         const state = task.getAttribute("data-state");
         if (
           task instanceof HTMLElement &&
@@ -447,7 +450,9 @@ function BrowserUI() {
     },
 
     moveCursorRight: function () {
-      (this.currentTask()?.getElementsByClassName("task")[0] as HTMLElement)?.focus();
+      const active = this.currentTask();
+      if (!active) return false;
+      (this.firstVisibleTask(active) as HTMLElement | null)?.focus();
     },
 
     moveCursorVertically: function (offset: number): boolean {