aboutsummaryrefslogtreecommitdiff
path: root/priv/home.html.eex
blob: 87b0d5d9bc018aeb57b51317162b40bfeac1e6f9 (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
<!DOCTYPE html>
<%
import Mediasync.Constants
{form_action_base, form_action_suffix} = case in_discord_activity? do
  true -> {"/.proxy/", "?#{query_param_discord_activity_inner()}"}
  false -> {"/", ""}
end
%>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>home | mediasync</title>
    <link rel="stylesheet" href="/static/main.css">
</head>

<body>
    <form action="<%= form_action_base %>host_room<%= form_action_suffix %>" method="post">
        <input name="_csrf_token" type="hidden" value="<%= Plug.CSRFProtection.get_csrf_token() %>">
        <label for="host_room_input_video_url">video url:</label>
        <input name="video_url" id="host_room_input_video_url" type="url"
            maxlength="<%= Application.get_env(:mediasync, :max_video_url_size) %>" required><br>

        <script>
            "use strict";
            /*  The built-in validation for <input type="url"> seems very half-hearted in my
                testing (Firefox 127.0.2), so let's replace it with something complete. */
            (() => {
                const checkURLInputValidity = (urlInput) => {
                    if (URL.canParse(urlInput.value)) {
                        urlInput.setCustomValidity("");
                    } else {
                        urlInput.setCustomValidity("Please enter a valid URL.");
                    }
                    urlInput.reportValidity();
                };
                const urlInput = document.querySelector("input#host_room_input_video_url");
                urlInput.addEventListener("input", e => checkURLInputValidity(e.target));
            })();
        </script>

        <input type="submit" value="host room">
    </form>
</body>

</html>