all repos — onyx @ main

minimal map annotation and location data sharing tool

src/22-okCancelModal.ts (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class OKCancelModal implements Modal {
  self(): HTMLElement | null {
    return document.getElementById("confirm-container");
  }
  
  confirmMsg(): HTMLElement | null {
    return document.getElementById("confirm-msg");
  }
  
  okBtn(): HTMLElement | null {
    return document.getElementById("yes-btn");
  }
  
  cancelBtn(): HTMLElement | null {
    return document.getElementById("no-btn");
  }
  
  visible(): boolean {
    return this.self()?.style.display != "none";
  }
  
  setVisible(v: boolean): void {
    const modal = this.self();
    if (modal) {
      modal.style.display = v ? "block" : "none";
    }
  }
  
  setMsg(s: string): void {
    const msg = this.confirmMsg();
    if (msg) {
      msg.innerText = s;
    }
  }
}