aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom/changeBackgroundOOC.ts
blob: abf3a975a927fc68522c0cdbf01cf22911104eb8 (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
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;