aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom/onEnter.ts
blob: 5ab532c1000ed31dfc623ac533b754a8efa16076 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { client, selectedShout } from "../client";
import { escapeChat } from "../encoding";


/**
 * Triggered when the Return key is pressed on the in-character chat input box.
 * @param {KeyboardEvent} event
 */
 export function onEnter(event: KeyboardEvent) {
    if (event.keyCode === 13) {
      const mychar = client.character;
      const myemo = client.emote;
      const evi = client.evidence;
      const flip = Boolean(
        document.getElementById("button_flip")!.classList.contains("dark")
      );
      const flash = Boolean(
        document.getElementById("button_flash")!.classList.contains("dark")
      );
      const screenshake = Boolean(
        document.getElementById("button_shake")!.classList.contains("dark")
      );
      const noninterrupting_preanim = Boolean(
        (<HTMLInputElement>document.getElementById("check_nonint")).checked
      );
      const looping_sfx = Boolean(
        (<HTMLInputElement>document.getElementById("check_loopsfx")).checked
      );
      const color = Number(
        (<HTMLInputElement>document.getElementById("textcolor")).value
      );
      const showname = escapeChat(
        (<HTMLInputElement>document.getElementById("ic_chat_name")).value
      );
      const text = (<HTMLInputElement>document.getElementById("client_inputbox"))
        .value;
      const pairchar = (<HTMLInputElement>document.getElementById("pair_select"))
        .value;
      const pairoffset = Number(
        (<HTMLInputElement>document.getElementById("pair_offset")).value
      );
      const pairyoffset = Number(
        (<HTMLInputElement>document.getElementById("pair_y_offset")).value
      );
      const myrole = (<HTMLInputElement>document.getElementById("role_select"))
        .value
        ? (<HTMLInputElement>document.getElementById("role_select")).value
        : mychar.side;
      const additive = Boolean(
        (<HTMLInputElement>document.getElementById("check_additive")).checked
      );
      const effect = (<HTMLInputElement>document.getElementById("effect_select"))
        .value;
  
      let sfxname = "0";
      let sfxdelay = 0;
      let emote_mod = myemo.zoom;
      if ((<HTMLInputElement>document.getElementById("sendsfx")).checked) {
        sfxname = myemo.sfx;
        sfxdelay = myemo.sfxdelay;
      }
  
      // not to overwrite a 5 from the ini or anything else
      if ((<HTMLInputElement>document.getElementById("sendpreanim")).checked) {
        if (emote_mod === 0) {
          emote_mod = 1;
        }
      } else if (emote_mod === 1) {
        emote_mod = 0;
      }
  
      client.sender.sendIC(
        myemo.deskmod,
        myemo.preanim,
        mychar.name,
        myemo.emote,
        text,
        myrole,
        sfxname,
        emote_mod,
        sfxdelay,
        selectedShout,
        evi,
        flip,
        flash,
        color,
        showname,
        pairchar,
        pairoffset,
        pairyoffset,
        noninterrupting_preanim,
        looping_sfx,
        screenshake,
        "-",
        "-",
        "-",
        additive,
        effect
      );
    }
    return false;
  }
  window.onEnter = onEnter;