From ccec95a9d3b68e25e24a9168400fc47099a85c81 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 6 Sep 2022 21:55:10 -0400 Subject: More window functions --- webAO/dom/toggleShout.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 webAO/dom/toggleShout.ts (limited to 'webAO/dom/toggleShout.ts') diff --git a/webAO/dom/toggleShout.ts b/webAO/dom/toggleShout.ts new file mode 100644 index 0000000..8094691 --- /dev/null +++ b/webAO/dom/toggleShout.ts @@ -0,0 +1,22 @@ +import { selectedShout, setSelectedShout } from "../client"; + + +/** + * Highlights and selects a shout for in-character chat. + * If the same shout button is selected, then the shout is canceled. + * @param {number} shout the new shout to be selected + */ +export function toggleShout(shout: number) { + if (shout === selectedShout) { + document.getElementById(`button_${shout}`)!.className = "client_button"; + selectedShout = 0; + } else { + document.getElementById(`button_${shout}`)!.className = "client_button dark"; + if (selectedShout) { + document.getElementById(`button_${selectedShout}`)!.className = + "client_button"; + } + selectedShout = shout; + } +} +window.toggleShout = toggleShout; -- cgit From 3f8d0974b327e663328bc36cd97f1ba1855a2269 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 7 Sep 2022 17:01:25 -0400 Subject: Added more functions --- webAO/dom/toggleShout.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'webAO/dom/toggleShout.ts') diff --git a/webAO/dom/toggleShout.ts b/webAO/dom/toggleShout.ts index 8094691..cb12f49 100644 --- a/webAO/dom/toggleShout.ts +++ b/webAO/dom/toggleShout.ts @@ -1,6 +1,5 @@ import { selectedShout, setSelectedShout } from "../client"; - /** * Highlights and selects a shout for in-character chat. * If the same shout button is selected, then the shout is canceled. @@ -9,14 +8,14 @@ import { selectedShout, setSelectedShout } from "../client"; export function toggleShout(shout: number) { if (shout === selectedShout) { document.getElementById(`button_${shout}`)!.className = "client_button"; - selectedShout = 0; + setSelectedShout(0); } else { document.getElementById(`button_${shout}`)!.className = "client_button dark"; if (selectedShout) { document.getElementById(`button_${selectedShout}`)!.className = "client_button"; } - selectedShout = shout; + setSelectedShout(shout); } } window.toggleShout = toggleShout; -- cgit