summaryrefslogtreecommitdiff
path: root/pages/schedules.inc
blob: dde2981c0f4c0c70ce8a1b8cff1c68ec2ad006f2 (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
<?php

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

global $use2023UI;

?>

<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>

<br>
<div class="container">
    <h2>Schedules</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; margin-bottom: 20px;">
                <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; margin-bottom: 20px;">
                <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; margin-bottom: 20px;">
                <b>Raindrops System</b><br>
                <h3 id="live-time-raindrops">--:--</h3>
            </div>
        </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; margin-bottom: 20px;">
                <b>Moonwind System</b><br>
                <h3 id="live-time-moonwind">--:--</h3>
            </div>
        </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;
        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;
        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;
        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;
        document.getElementById("live-time-other-outer").style.backgroundPositionY = getDayPercentage(time3) + "%";
    }

    updateTime();

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

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