Skip to content

Commit bcdb10b

Browse files
committed
add static and html files
1 parent 525e6f5 commit bcdb10b

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

static/confirm.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
function confirmForm() {
3+
const file = document.getElementById("upload").value;
4+
if (file == undefined || file == null || file == "") {
5+
window.alert("You need to select a file!");
6+
return false;
7+
}
8+
return true;
9+
}

static/countdown.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
document.querySelectorAll('.countdown').forEach(element => {
3+
setInterval(() => {
4+
let count = parseInt(element.innerText)
5+
if (count > 0) {
6+
count--;
7+
element.textContent = count;
8+
} else {
9+
element.parentElement.parentElement.remove()
10+
}
11+
}, 950);
12+
});

static/main.css

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
:root {
3+
font-size: 20px;
4+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
5+
color: #e8f1f7;
6+
}
7+
8+
body {
9+
background-color: #2D333B;
10+
}
11+
12+
.btn {
13+
cursor: pointer;
14+
border-radius: 20px;
15+
padding: 20px;
16+
color: black;
17+
font-size: 0.75rem;
18+
border: 1px solid black;
19+
}
20+
21+
.container {
22+
border: 1px solid white;
23+
margin: 3rem 10% 3rem 10%;
24+
padding: 15px 50px 25px 50px;
25+
background-color: #22272E;
26+
border-radius: 20px;
27+
}
28+
29+
.upload-btn {
30+
background-color: #47ff4a;
31+
}
32+
33+
.upload-label {
34+
background-color: #47ecff;
35+
}
36+
37+
h3 > a {
38+
background-color: #47ff4a;
39+
color: black;
40+
text-decoration: none;
41+
}
42+
43+
ol {
44+
margin: 0;
45+
padding: 0;
46+
}
47+
48+
ol li {
49+
padding: 5px;
50+
}
51+
52+
ol li:nth-child(odd) {
53+
background-color: #2D333B;
54+
}
55+
56+
ol li a {
57+
color: #e8f1f7;
58+
}
59+
60+
.autodelete {
61+
background-color: #edff47;
62+
}
63+
64+
.autodelete.checked {
65+
background-color: #ff476f;
66+
}
67+
68+
.directory > a {
69+
color:#47ecff;
70+
}
71+
72+
.countdown-wrapper, a.zip {
73+
color: #5e6164;
74+
}

templates/index.html

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="stylesheet" href="/static/main.css" />
6+
<script src="/static/confirm.js" defer></script>
7+
<script src="/static/countdown.js" defer></script>
8+
</head>
9+
<body>
10+
{{ range .messages }}
11+
<div class="container">
12+
<h3>{{ . }}. <a href="/">Dismiss</a>.</h3>
13+
</div>
14+
{{ end }}
15+
16+
<form
17+
action="/"
18+
class="container"
19+
method="post"
20+
enctype="multipart/form-data"
21+
onsubmit="return confirmForm()"
22+
>
23+
<h2>Upload a file to {{ .hostname }}</h2>
24+
<label for="upload" class="upload-label btn">
25+
Click here to upload
26+
<input type="file" multiple id="upload" name="upload" />
27+
</label>
28+
<label for="autodelete" class="btn autodelete">
29+
<input type="checkbox" name="autodelete" id="autodelete" onchange="document.querySelector('label.autodelete').classList.toggle('checked')">
30+
Auto-delete
31+
</label>
32+
<button type="submit" class="upload-btn btn">Upload</button>
33+
</form>
34+
35+
<div class="container">
36+
<h2>Download shared files from {{ .hostname }}</h2>
37+
{{ if ne .view "" }}
38+
<h4 class="directory"><a href="/">shared files</a> / {{ .view }}</h4>
39+
{{ end }}
40+
<ol>
41+
{{ if eq (len .files) 0 }}
42+
<li>
43+
nothing here but linux
44+
</li>
45+
{{ else }}
46+
{{ range .files }}
47+
{{ if ne .Name ".directory" }}
48+
{{ if .IsDir }}
49+
<li class="directory">
50+
<a href="/?view={{ .Path }}">{{ .Name }}</a>
51+
<a class="zip" href="/zip/{{ .Name }}">(download as zip)</a>
52+
</li>
53+
{{ else }}
54+
<li>
55+
<a href="/download/{{ .Name }}" target="_blank">{{ .Name }}</a>
56+
{{ if ne .ExpiresIn 0 }}
57+
<span class="countdown-wrapper">(deletes in <span class="countdown">{{ .ExpiresIn }}</span>)</span>
58+
{{ end }}
59+
</li>
60+
{{ end }}
61+
{{ end }}
62+
{{ end }}
63+
{{ end }}
64+
</ol>
65+
</div>
66+
67+
<div class="container">
68+
<h3>Scan this QR code to connect another device that is on the same network:</h3>
69+
<img src="/qrcode.png" alt="qr code">
70+
</div>
71+
</body>
72+
</html>

0 commit comments

Comments
 (0)