summaryrefslogtreecommitdiff
path: root/index.php
blob: efebeb3d795ab22b5d28c92cca42467bd4af116f (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
<?php

$title = "lang_home_title";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
global $_PROFILE; global $_USER;

$version = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/version");

?>

<div class="container">
    <br><br>
    <h1><?= l("lang_home_greeting") ?> <?= $_PROFILE["nick_name"] ?? $_PROFILE["first_name"] . " " . $_PROFILE["last_name"] ?></h1>

    <?php if (isset($_COOKIE["DeltaHandoffPalette"]) && isset($_GET["debug"])): ?>
        <div class="alert alert-primary">
            <details>
                <summary>This device is using a custom handoff palette.</summary>
                <ul>
                    <?php foreach (explode(",", $_COOKIE['DeltaHandoffPalette']) as $color): ?>
                        <li><?= $color ?> <span style="background-color:#<?= $color ?>;width:36px;height:36px;display:inline-block;"></span></li>
                    <?php endforeach; ?>
                </ul>
            </details>
        </div>
    <?php endif; ?>

    <?php if ($_SERVER["HTTP_HOST"] === "192.168.1.121:81"): ?>
        <div class="alert alert-danger">
            <b>This is a development environment.</b> All data is reset with data from production every 60 minutes. Run <code style="color: inherit;"><?= $_SERVER['DOCUMENT_ROOT'] ?>/includes/prod.sh</code> to push this release to production.
        </div>
    <?php endif; ?>
    <?php if (isset($_COOKIE["DeltaHandoffPalette"])): ?>
        <div class="alert alert-danger">
            <b><?= l("lang_mobile_end_0") ?></b> <?= l("lang_mobile_end_1") ?>
        </div>
    <?php endif; ?>

    <?php if (str_contains($version, "rc") ||
              str_contains($version, "eap") ||
              str_contains($version, "beta") ||
              str_contains($version, "dev")): ?>
    <div class="alert alert-secondary">
        <b><?= l("lang_experimental_title") ?></b> <?= str_replace("%2", '</a>', str_replace("%1", '<a href="/support">', l("lang_experimental_message"))) ?>
    </div>
    <?php endif; ?>

    <div id="homepage-content"></div>

    <div style="display: flex; align-items: center; justify-content: center; margin-top: 30px;" id="homepage-loader">
        <svg class="spinner" width="32px" height="32px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
            <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
        </svg>
    </div>

    <br><br><br>

    <script>
        window.list = [
            "birthday.php",
            "family.php",
            "history.php",
            "recent.php"
        ];

        function nextItem() {
            let item = list[0];

            try {
                window.fetch("/home/" + item).then((res) => {
                    res.text().then((data) => {
                        document.getElementById("homepage-content").innerHTML += data;
                        list.shift();
                        if (list.length > 0) {
                            nextItem();
                        } else {
                            document.getElementById("homepage-loader").style.display = "none";
                        }
                    });
                })
            } catch (e) {
                list.shift();
                if (list.length > 0) {
                    nextItem();
                } else {
                    document.getElementById("homepage-loader").style.display = "none";
                }
            }
        }

        window.addEventListener("load", () => {
            nextItem();
        });
    </script>
</div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>