diff options
Diffstat (limited to 'webAO/dom/toggleShout.ts')
| -rw-r--r-- | webAO/dom/toggleShout.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/webAO/dom/toggleShout.ts b/webAO/dom/toggleShout.ts new file mode 100644 index 0000000..cb12f49 --- /dev/null +++ b/webAO/dom/toggleShout.ts @@ -0,0 +1,21 @@ +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"; + setSelectedShout(0); + } else { + document.getElementById(`button_${shout}`)!.className = "client_button dark"; + if (selectedShout) { + document.getElementById(`button_${selectedShout}`)!.className = + "client_button"; + } + setSelectedShout(shout); + } +} +window.toggleShout = toggleShout; |
