summaryrefslogtreecommitdiff
path: root/includes/fragments/dashboard.inc
blob: bb58df1b3c0b85da28a54f824e772e5dda3b4f3f (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php

if (isset($_GET["ec"])) {
    header("HTTP/1.1 " . $_GET["ec"] . " Error");
}

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; $title = "Dashboard"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn;

global $use2023UI;

?>

    <br>
    <div class="container">
        <?php if (isset($_GET['em'])): ?>
            <div class="alert alert-danger alert-dismissible">
                <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button>
                <b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?>
            </div>
        <?php endif; ?>

        <div class="alert alert-warning alert-dismissible" id="gpuWarning" style="display: none;">
            <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button>
            <b>GPU acceleration is turned off or not supported.</b> A lot of visual effects on this website rely on GPU acceleration, which is currently disabled on your browser, meaning the website's overall look will be affected. Please enable GPU acceleration in your browser settings.
        </div>

        <style>
            .day-gradient {
                background-image: linear-gradient(180deg, rgba(7,15,36,1) 0%, rgba(36,56,83,1) 14%, rgba(165,126,57,1) 28%, rgba(37,109,201,1) 42%, rgba(47,165,208,1) 57%, rgba(252,120,15,1) 71%, rgba(38,66,97,1) 85%, rgba(7,15,36,1) 100%);
                background-size: 100% 1000%;
            }

            .invert {
                filter: invert(1) hue-rotate(180deg);
            }

            @media (max-width: 800px) {
                #schedules {
                    grid-template-columns: 1fr !important;
                }

                .schedules-separator {
                    display: block !important;
                }
            }
        </style>

        <h2>
            <span id="greeting">Hi</span> <span><?php

                $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($_PROFILE["login"] === "raindrops" ? "gdapd" : ($_PROFILE["login"] === "cloudburst" ? "ynmuc" : ($_PROFILE["login"] === "Moonwind" ? "hrbom" : "other"))) . "/fronters.json"), true);
                $name = ($_PROFILE["login"] === "raindrops" ? "Raindrops System" : ($_PROFILE["login"] === "cloudburst" ? "Cloudburst System" : ($_PROFILE["login"] === "Moonwind" ? "Moonglow" : $app["other"]["name"])));

                if (isset($fronters["members"][0])) {
                    $name = implode(" and ", array_map(function ($i) {
                        return $i["display_name"] ?? $i["name"];
                    }, $fronters["members"]));
                }

                echo $name;

                ?>!</span>
        </h2>

        <div id="schedules" style="margin-top: 20px; display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 20px;">
            <div>
                <div id="live-time-other-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px;">
                    <b><?= $app["other"]["name"] ?></b><br>
                    <h3 id="live-time-other">--:--</h3>
                </div>

                <hr style="display: none;" class="schedules-separator">
            </div>

            <div>
                <div id="live-time-cloudburst-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px;">
                    <b>Cloudburst System</b><br>
                    <h3 id="live-time-cloudburst">--:--</h3>
                </div>

                <hr style="display: none;" class="schedules-separator">
            </div>

            <div>
                <div id="live-time-raindrops-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px;">
                    <b>Raindrops System</b><br>
                    <h3 id="live-time-raindrops">--:--</h3>
                </div>

                <hr style="display: none;" class="schedules-separator">
            </div>

            <div>
                <div id="live-time-moonwind-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px;">
                    <b>Moonglow</b><br>
                    <h3 id="live-time-moonwind">--:--</h3>
                </div>
            </div>
        </div>

        <script>
            function getDayPercentage(time) {
                let hours = parseInt(time.split(":")[0]);
                let minutes = parseInt(time.split(":")[1].split(" ")[0]);

                if (time.split(":")[1].split(" ")[1] === "PM") hours += 12;
                if (hours === 12 && time.split(":")[1].split(" ")[1] === "AM") hours = 0;
                if (hours === 24 && time.split(":")[1].split(" ")[1] === "PM") hours = 12;

                let timestamp = new Date("1970-01-01 " + hours + ":" + minutes + " UTC").getTime() / 1000;

                return (timestamp / 86400) * 100;
            }

            function updateTime() {
                let time1 = (new Intl.DateTimeFormat('en-US', {
                    timeZone: 'Europe/Paris',
                    hour: 'numeric',
                    minute: '2-digit',
                    hour12: false
                })).format(new Date());

                document.getElementById("live-time-raindrops").innerText = time1.replace("24:", "00:");
                document.getElementById("live-time-raindrops-outer").style.backgroundPositionY = getDayPercentage(time1) + "%";

                let time4 = (new Intl.DateTimeFormat('en-US', {
                    timeZone: 'Europe/Kyiv',
                    hour: 'numeric',
                    minute: '2-digit',
                    hour12: false
                })).format(new Date());

                document.getElementById("live-time-moonwind").innerText = time4.replace("24:", "00:");
                document.getElementById("live-time-moonwind-outer").style.backgroundPositionY = getDayPercentage(time4) + "%";

                let time2 = (new Intl.DateTimeFormat('en-US', {
                    timeZone: 'Europe/London',
                    hour: 'numeric',
                    minute: '2-digit',
                    hour12: false
                })).format(new Date());

                document.getElementById("live-time-cloudburst").innerText = time2.replace("24:", "00:");
                document.getElementById("live-time-cloudburst-outer").style.backgroundPositionY = getDayPercentage(time2) + "%";

                let time3 = (new Intl.DateTimeFormat('en-US', {
                    timeZone: 'America/Chicago',
                    hour: 'numeric',
                    minute: '2-digit',
                    hour12: false
                })).format(new Date());

                document.getElementById("live-time-other").innerText = time3.replace("24:", "00:");
                document.getElementById("live-time-other-outer").style.backgroundPositionY = getDayPercentage(time3) + "%";

                let greeting = "Hi";

                switch (new Date().getHours()) {
                    case 22:
                    case 23:
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        greeting = "Good night";
                        break;

                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10:
                    case 11:
                        greeting = "Good morning";
                        break;

                    case 12:
                    case 13:
                    case 14:
                    case 15:
                    case 16:
                    case 17:
                        greeting = "Good afternoon";
                        break;

                    case 18:
                    case 19:
                    case 20:
                    case 21:
                        greeting = "Good evening";
                        break;
                }

                document.getElementById("greeting").innerText = greeting;
            }

            updateTime();

            setInterval(() => {
                updateTime();
            }, 10000);
        </script>

        <div id="timeline-container" style="background: #3332328a;padding: 5px 10px;border-radius: 10px; margin-top: 20px;">
            <div id="timeline"></div>
            <script>
                async function refreshTimeline() {
                    document.getElementById("timeline").innerHTML = await (await fetch("/api/timeline?gdapd&ynmuc<?= ($isLowerLoggedIn || $isLoggedIn) ? "&" . $app["other"]["id"] : "" ?>&hrbom")).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>

        <div style="display: grid; grid-template-columns: 1fr 2fr; grid-gap: 20px;" id="home-parts">
            <div style="background-color: var(--palette-2) !important; margin-top: 20px; border-radius: 10px;">
                <div class="list-group">
                    <a href="/cloudburst" class="list-group-item list-group-item-action" style="display: flex; align-items: center;">
                        <img src="/assets/avatars/ade46823206b4b0cad3ccaae934a5f3b.webp" style="margin-right: 5px; width: 24px;"><div style="vertical-align: middle; display: flex; align-items: center; color: var(--bs-body-color);">Cloudburst System</div>
                    </a>
                    <a href="/raindrops" class="list-group-item list-group-item-action" style="display: flex; align-items: center;">
                        <img src="/assets/avatars/7d9f543ef74240f69d0786c3f2983124.webp" style="margin-right: 5px; width: 24px;"><div style="vertical-align: middle; display: flex; align-items: center; color: var(--bs-body-color);">Raindrops System</div>
                    </a>
                    <a href="/<?= $app["other"]["slug"] ?>" class="list-group-item list-group-item-action" style="display: flex; align-items: center;">
                        <img src="/assets/avatars/64fb19057fae41cfac0f844e9e186848.webp" style="margin-right: 5px; width: 24px;"><div style="vertical-align: middle; display: flex; align-items: center; color: var(--bs-body-color);"><?= $app["other"]["name"] ?></div>
                    </a>
                    <a href="/moonglow" class="list-group-item list-group-item-action" style="display: flex; align-items: center;">
                        <img src="/assets/avatars/d1cd97eb9c924e4294cd4397a5074ff9.webp" style="margin-right: 5px; width: 24px;"><div style="vertical-align: middle; display: flex; align-items: center; color: var(--bs-body-color);">Moonglow</div>
                    </a>
                    <a href="/-/emergency" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="/assets/icons/new/emergency.svg?color=474747" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Emergency alert</div>
                    </a>
                    <a href="/-/byfront" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="/assets/icons/new/front.svg?color=474747" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">By last fronted date</div>
                    </a>
                    <a href="https://countdown.equestria.horse" target="_blank" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="/assets/icons/new/schedule.svg?color=474747" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Meet-up countdown</div>
                    </a>
                    <a href="https://plex.equestria.horse" target="_blank" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="https://plex.equestria.horse/web/favicon.ico" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Plex</div>
                    </a>
                    <a href="https://live.equestria.dev" target="_blank" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="https://avatars.githubusercontent.com/u/8463692?s=128" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Streaming server</div>
                    </a>
                    <a href="https://mist.equestria.horse" target="_blank" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;">
                        <img src="https://mist.equestria.horse/icons/normal_128x128.png" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Mist</div>
                    </a>
                </div>
            </div>
            <div style="background-color: var(--palette-2) !important; text-align: center; margin-top: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center;">
                <div style="color: var(--palette-9);">There is nothing here yet, check back later!</div>
            </div>
        </div>
    </div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>