| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // ts/corps.ts
- var main = document.querySelector("main");
- (async () => {
- const loader = document.querySelector("#loader");
- loader.style.display = "block";
- try {
- await render();
- } catch (e) {
- main.textContent = e instanceof Error ? e.message : String(e);
- }
- loader.style.display = "none";
- })();
- async function render() {
- const corps = await fetch("corps.json").then((r) => r.json());
- corps.sort((a, b) => (a.headquartersAddress?.lines.find((line) => line.type === "SYSTEM").entity.naturalId ?? "").localeCompare(b.headquartersAddress?.lines.find((line) => line.type === "SYSTEM").entity.naturalId ?? ""));
- main.innerHTML = `<table>
- <thead>
- <tr>
- <th>code</th>
- <th>name</th>
- <th>shareholders</th>
- <th>HQ</th>
- </tr>
- </thead>
- <tbody>
- ${corps.map(renderCorpRow).join("")}
- </tbody>
- </table>`;
- }
- function renderCorpRow(corp) {
- let hq = "";
- if (corp.headquartersAddress !== null) {
- const planet = corp.headquartersAddress.lines.find((line) => line.type === "PLANET").entity;
- hq = planet.name;
- if (planet.name !== planet.naturalId)
- hq += ` (${planet.naturalId})`;
- if (!corp.headquartersFinished)
- hq += " [unfinished]";
- }
- return `<tr>
- <td>${corp.code}</td>
- <td>${corp.name}</td>
- <td>${corp.shareholders.length}</td>
- <td>${hq}</td>
- </tr>`;
- }
- //# debugId=938663E409BCBBAE64756E2164756E21
|