summaryrefslogtreecommitdiff
path: root/dist/landing.html
blob: 285871816b52f6f7b2c7df3d51f34831ba4d80d5 (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
<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        body {
            font-family: "Lato", sans-serif;
        }

        .sidenav {
            height: 100%;
            width: 160px;
            position: fixed;
            z-index: 1;
            top: 0;
            left: 0;
            background-color: #111;
            padding-top: 20px;
            overflow-wrap: break-word;
        }
        .main {
            margin-left: 162px;
            /* Same as the width of the sidenav */
            font-size: 28px;
            /* Increased text to enable scrolling */
            padding: 0px 10px;
        }

        .out {
            margin-left: 162px;
            /* Same as the width of the sidenav */
            font-size: 16px;
            /* Increased text to enable scrolling */
        }

        @media screen and (max-height: 450px) {
            .sidenav {
                padding-top: 15px;
            }

            .sidenav a {
                font-size: 18px;
            }
        }
    </style>
</head>

<body>
    <div class="sidenav">
        <a>Public Lobbys:</a>
        <h1 id="userlist"></h1>
    </div>
    <div class="main">
        <h1>Spotify Intersect</h1>

        <input type="text" id="lobby_name" placeholder="Lobby name">
        <button id="lobby_button" onclick="lobby_button()">Create a new lobby</button>
        <p id="status"></p>
    </div>
    <script>
        //const host = "https://kobert.dev";
        const host = "http://127.0.0.1:8000";
        const api = host + "";
        //const api = host + "/spotify-api";
        function getParameterByName(name) {
            let url = window.location.href;
            name = name.replace(/[\[\]]/g, "\\$&");
            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
                results = regex.exec(url);
            if (!results) return null;
            if (!results[2]) return '';
            return decodeURIComponent(results[2].replace(/\+/g, " "));
        }
        function lobby_button() {
            let lobby_name = document.getElementById("lobby_name").value;
            fetch(api + "/lobby/" + lobby_name, {method: 'POST'})
                .then(function (response) {
                    if (!response.ok) {
                        document.getElementById("status").innerHTML = `Error occured while generating new lobby: ${response.status}`;
                        throw new Error(`HTTP error! status: ${response.status}`);
                    }
                    response.text().then(function (message) {
                        window.location = host + "/callback.html?lobby=" + message; 
                    });
                });
        }
    </script>
</body>

</html>