summaryrefslogtreecommitdiff
path: root/includes/components/sysbanner.inc
blob: 26a049e88834192c7f82dfa657500e396c7df767 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php

global $memberData;
global $memberCommonName;
global $memberID;
global $systemCommonName;
global $systemID;
global $system;
global $lang; global $pages; global $app;

$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);
$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true);

?>

<div id="system-info" style="background-color:rgba(255, 255, 255, .05);margin-left: -20px; margin-right: -20px;margin-top:-20px;padding: 0 20px 10px; <?php if ($systemID === $app["other"]["id"]): ?>padding-top: 15px;<?php endif; ?>">
    <div style="padding:10px 10px 10px 20px;text-align:center;">
        <div>
            <img src="<?= getAsset($systemID) ?>" alt="" style="margin-right: auto; margin-left: auto; display: block; width:128px;max-height:128px;border-radius:10px;">
            <h3 style="height:max-content;"><?= $systemCommonName ?></h3>
            <div style="height:max-content;" id="member-card">
                <span>
                    <?php

                    if ($systemID === $app["other"]["id"]) {
                        $travellers = [];
                    } else {
                        $travellers = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), function ($i) use ($travelling) {
                            return $travelling[$i['id']]['travelling'] && !$travelling[$i['id']]['equestria'];
                        });
                    }

                    ?>
                        <?= count(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true), $systemID)) ?> members<?php

                    if (count($travellers) > 0) {
                        echo(" (+ " . count($travellers) . " " . (count($travellers) > 1 ? $lang["system"]["traveller"] : $lang["system"]["travellers"]) . ")");
                    }

                    ?>
                    </span>
                <span>

                    </span>
            </div>
        </div>
    </div>
</div>

<div id="system-actions" style="padding:5px 30px;background-color:rgba(255, 255, 255, .025);margin-left: -20px; margin-right: -20px;">
    <div id="timeline"></div>
    <script>
        async function refreshTimeline() {
            document.getElementById("timeline").innerHTML = await (await fetch("/api/timeline?<?= $systemID ?>")).text();

            Array.from(document.getElementsByClassName("dynamic-time")).forEach((el) => {
                let time = el.getAttribute("data-time");
                el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":").splice(0, 2).join(":");
            });

            Array.from(document.getElementsByClassName("dynamic-time-mobile")).forEach((el) => {
                let time = el.getAttribute("data-time");
                el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":")[0] + ":";
            });
        }

        setInterval(refreshTimeline, 10000);
        refreshTimeline();
    </script>
    <div style="display:grid;grid-template-columns: repeat(2, 1fr);">
        <div style="display: flex; align-items: center; justify-content: center; text-align: center;">
            Last switch&nbsp;<span data-bs-toggle="tooltip" title="<?= date("D j M Y, G:i:s (e)", strtotime(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true)["timestamp"])) ?>"><?= timeAgo(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/fronters.json"), true)["timestamp"]) ?></span>
        </div>
        <a title="<?= $pages["s:history"]["name"][$lang["_name"]] ?>" data-bs-toggle="tooltip" style="display:inline-block;padding:5px 10px;text-align: center" class="system-action tooltip-nohelp" href="/<?= $system ?>/-/history">
            <img src="/assets/icons/history.svg" style="vertical-align: middle;height: 24px;width: 24px;filter: invert(1)" alt="">
            <span style="vertical-align: middle;" class="list-separator-desktop"><?= $pages["s:history"]["name"][$lang["_name"]] ?></span>
        </a>
        <div></div>
    </div>
</div>