summaryrefslogtreecommitdiff
path: root/src/renderer/gameserver/serverView/info.ts
blob: 40c7e03a1891a352188e0d8278c98b4b2151fe0a (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { News } from "../news";
import { shell } from "electron";
import { GameServerPage } from "./serverPage";

export class ServerInfoPage extends GameServerPage {
  public getPage(): HTMLElement {
    const content = document.createElement("div");
    content.classList.add("infoServerPage");

    const title = document.createElement("div");
    title.classList.add("title");
    title.innerText = this.server.name;
    content.appendChild(title);

    const socialContainer = document.createElement("div");
    socialContainer.classList.add("socialContainer");
    setTimeout(() => {
      this.server.socialLinks.forEach((link) => {
        socialContainer.appendChild(link.getHTML());
      });
    }, 5);
    content.appendChild(socialContainer);

    const shrtDsrption = document.createElement("div");
    shrtDsrption.classList.add("shortDescription");
    shrtDsrption.innerText = this.server.shortDescription;
    content.appendChild(shrtDsrption);
    if (this.server.newsLatestPage && this.server.newsLatestPage != null) {
      const latestNews = document.createElement("div");
      latestNews.classList.add("news");
      content.appendChild(latestNews);
      News.get(
        this.server.newsLatestPage.url,
        this.server.newsLatestPage.type
      ).then((result: string) => {
        latestNews.innerHTML = result;
        const aTags = latestNews.getElementsByTagName("a");
        for (var i = 0; i < aTags.length; i++) {
          const href = aTags[i].href.toString();
          aTags[i].addEventListener("click", () => {
            shell.openExternal(href);
          });
          aTags[i].href = "#";
        }
      });
    }

    return content;
  }
}