aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/createArea.ts
blob: 63af644d37db25860e2a506ea780eda1c0e70d50 (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
28
29
30
import { client } from "../client";
import { area_click } from "../dom/areaClick";

export const createArea = (id: number, name: string) => {
    const thisarea = {
        name,
        players: 0,
        status: "IDLE",
        cm: "",
        locked: "FREE",
    };

    client.areas.push(thisarea);

    // Create area button
    const newarea = document.createElement("SPAN");
    newarea.className = "area-button area-default";
    newarea.id = `area${id}`;
    newarea.innerText = thisarea.name;
    newarea.title =
        `Players: ${thisarea.players}\n` +
        `Status: ${thisarea.status}\n` +
        `CM: ${thisarea.cm}\n` +
        `Area lock: ${thisarea.locked}`;
    newarea.onclick = function () {
        area_click(newarea);
    };

    document.getElementById("areas")!.appendChild(newarea);
}