aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom/changeBackgroundOOC.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-09-04 19:30:41 +0200
committerGitHub <noreply@github.com>2022-09-04 19:30:41 +0200
commit975fb353dd7f5bec7bcb836f4ceb86fae9b70340 (patch)
treeac910da9d9766582bec1eed873feabbb7b013259 /webAO/dom/changeBackgroundOOC.ts
parentd20994bd7c244cc84ab138cec441b05c261a83e4 (diff)
parent31a97ce6009204316295fa4fd09749e2ff71dd7d (diff)
Merge pull request #164 from caleb-mabry/move-window-functions-pt-1
Several window functions moved
Diffstat (limited to 'webAO/dom/changeBackgroundOOC.ts')
-rw-r--r--webAO/dom/changeBackgroundOOC.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/webAO/dom/changeBackgroundOOC.ts b/webAO/dom/changeBackgroundOOC.ts
new file mode 100644
index 0000000..abf3a97
--- /dev/null
+++ b/webAO/dom/changeBackgroundOOC.ts
@@ -0,0 +1,27 @@
+import { client } from "../client";
+import queryParser from "../utils/queryParser";
+
+let { mode } = queryParser();
+
+/**
+ * Change background via OOC.
+ */
+export function changeBackgroundOOC() {
+ const selectedBG = <HTMLSelectElement>document.getElementById("bg_select");
+ const changeBGCommand = "bg $1";
+ const bgFilename = <HTMLInputElement>document.getElementById("bg_filename");
+
+ let filename = "";
+ if (selectedBG.selectedIndex === 0) {
+ filename = bgFilename.value;
+ } else {
+ filename = selectedBG.value;
+ }
+
+ if (mode === "join") {
+ client.sendOOC(`/${changeBGCommand.replace("$1", filename)}`);
+ } else if (mode === "replay") {
+ client.sendSelf(`BN#${filename}#%`);
+ }
+}
+window.changeBackgroundOOC = changeBackgroundOOC; \ No newline at end of file