aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom/updateBackgroundPreview.ts
blob: 0daea7475048783e4b96560e9d48bb99b0f7686e (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 { AO_HOST } from '../client/aoHost'
/**
 * Update background preview.
 */
export function updateBackgroundPreview() {
    const background_select = <HTMLSelectElement>(
        document.getElementById("bg_select")
    );
    const background_filename = <HTMLInputElement>(
        document.getElementById("bg_filename")
    );
    const background_preview = <HTMLImageElement>(
        document.getElementById("bg_preview")
    );

    if (background_select.selectedIndex === 0) {
        background_filename.style.display = "initial";
    } else {
        background_filename.style.display = "none";
    }
    tryUrls(`${AO_HOST}background/${encodeURI(
            background_select.value.toLowerCase()
        )}/defenseempty`).then((resp) => {
        background_preview.src = resp;
    });
}
window.updateBackgroundPreview = updateBackgroundPreview;