summaryrefslogtreecommitdiffstats
path: root/src/wwwroot/index.html
blob: 1495cf168d127f6c353d89b1031fc5ee097b70e7 (plain) (blame)
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/index.css">
    <title>Blobbin</title>
</head>
<body>
<h1>Blobbin</h1>
<p>This is a web service you can upload files and texts to.</p>
<main id="forms">
    <div class="wrapper">
        <h2>Upload a file</h2>
        <form action="/file" enctype="multipart/form-data" id="file-form" method="post" autocomplete="off"
              autocapitalize="off">
            <input type="file" maxlength="104857600" id="file" name="files" required>
            <label for="file-password">Password (optional)</label>
            <input type="password" name="password" id="file-password">
            <label for="file-auto-delete">
                Automatically delete after (optional)
                <span class="label-description"
                      title="<number><unit>, Unit can be seconds(s,second), minutes(m,minute), hours(h,hour), days(d,day), weeks(w,week), years(y,year). Number can be non-negative whole number">?</span>
            </label>
            <input type="text"
                   id="file-auto-delete"
                   name="autoDeleteAfter">
            <label for="file-singleton">
                <input type="checkbox" name="singleton" id="file-singleton">
                Delete after first open</label>
            <button class="btn" type="submit">Start upload</button>
        </form>
    </div>
    <div class="wrapper">
        <h2>Upload some text</h2>
        <form action="/text" method="post" id="text-form" autocomplete="off" autocapitalize="off">
            <textarea id="text" name="content" required></textarea>
            <label for="text-password">Mimetype (default: text/plain)</label>
            <input type="password" name="mime" id="text-mimetype">
            <label for="text-password">Password (optional)</label>
            <input type="password" name="password" id="text-password">
            <label for="text-auto-delete">
                Automatically delete after (optional)
                <span class="label-description"
                      title="<number><unit>, Unit can be seconds(s,second), minutes(m,minute), hours(h,hour), days(d,day), weeks(w,week), years(y,year). Number can be non-negative whole number">?</span>
            </label>
            <input type="text"
                   id="text-auto-delete"
                   name="autoDeleteAfter">
            <label for="text-singleton">
                <input type="checkbox" id="text-singleton" name="singleton">
                Delete after first open</label>
            <button class="btn" type="submit">Start upload</button>
        </form>
    </div>
</main>
<script>
    document.addEventListener("DOMContentLoaded", () => {
        const fileInput = document.getElementById("file");
        document.getElementById("file-form").addEventListener("submit", () => {
            if (fileInput.files[0].size > 104_857_60) {
                document.querySelector("#file-form .btn").innerText = "Uploading...";
            }
        });
        fileInput.addEventListener("change", (e) => {
            if (e.target.files[0].size > 104_857_600) {
                alert("File is too big!");
                e.target.value = "";
            }
        });
        document.querySelectorAll("textarea").forEach(area => {
            area.addEventListener("input", event => {
                event.target.style.height = "auto";
                event.target.style.height = event.target.scrollHeight + "px";
            })
        })
    });
</script>
</body>
</html>