moved to web, forgot to exclude in gitignore

This commit is contained in:
2026-11-21 18:05:30 -05:00
parent 18b1172f93
commit 67849def05
14 changed files with 881 additions and 2 deletions
+336
View File
@@ -0,0 +1,336 @@
:root {
--bg: #191919;
--surface: #2a2a2a;
--surface-between: #3a3a3a;
--surface-hover: #4a4a4a;
--text: #eee;
--text-muted: #aaa;
--border: #4e4e4e;
--border-strong: #7e7e7e;
}
* {
box-sizing: border-box;
}
body {
min-height: 100vh;
background-color: var(--bg);
color: var(--text);
margin: 0;
font-family: Consolas, monospace;
font-size: 14px;
background-image: var(--qt-url);
background-repeat: no-repeat;
background-position: bottom right;
background-size: auto 256px;
background-attachment: fixed;
}
b {
font-weight: bold;
}
h1,
h2 {
margin: 0;
font-weight: 400;
}
h4 {
margin: 6px 0;
}
h1 {
font-size: 18px;
font-weight: 700;
}
a {
color: var(--text);
}
main {
width: min(100% - 36px, 720px);
margin: 0 auto;
padding: 11px 0 64px;
}
.site-header {
width: min(100% - 36px, 720px);
margin: 0 auto;
padding: 44px 0 0;
display: flex;
justify-content: space-between;
}
textarea {
background: var(--bg);
display: block;
width: 100%;
min-height: 120px;
height: 120px;
resize: vertical;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-bottom: 12px;
}
textarea:focus {
border-color: var(--border-strong);
}
input[type="text"] {
background: var(--bg);
display: block;
width: 100%;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-top: 6px;
margin-bottom: 12px;
}
input[type="text"]:focus {
border-color: var(--border-strong);
}
.upload-tabs {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.upload-tabs > label {
cursor: pointer;
border-bottom: 1px solid transparent;
color: var(--text-muted);
}
.upload-tabs > input {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
.upload-tabs > input:checked + label {
border-bottom-color: currentColor;
color: var(--text);
}
.upload-tabs > input:focus-visible + label {
border: 1px solid currentColor;
}
.file-panel,
.paste-panel {
display: none;
width: 100%;
}
#type-file:checked ~ .file-panel,
#type-paste:checked ~ .paste-panel {
display: block;
}
input[type="file"] {
display: block;
border: 1px solid var(--border);
color: var(--text);
width: 100%;
cursor: pointer;
margin-bottom: 12px;
font: inherit;
}
input[type="file"]:hover {
background-color: var(--surface);
}
input[type="file"]:hover::file-selector-button {
background-color: var(--surface-hover);
}
input[type="file"]::file-selector-button {
background-color: var(--surface);
border: none;
color: var(--text);
padding: 10px;
font: inherit;
}
.muted {
color: var(--text-muted);
}
select {
padding: 0 0 2px;
background: var(--bg);
border: none;
color: var(--text);
border-bottom: 1px solid var(--border-strong);
border-radius: 0;
font: inherit;
margin-bottom: 12px;
}
option {
background-color: var(--bg);
font: inherit;
}
.btn {
border-radius: 0;
border: none;
background-color: var(--text);
padding: 11px;
color: var(--surface);
font: inherit;
cursor: pointer;
}
.btn:hover {
background-color: var(--text-muted);
}
.btn:disabled {
background-color: var(--surface);
color: var(--text-muted);
cursor: not-allowed;
}
.link-btn {
border: none;
background: none;
padding: 0;
text-decoration: underline;
color: var(--text);
cursor: pointer;
font: inherit;
}
img,
video,
audio {
max-width: 100%;
max-height: 80dvh;
}
.upload-links {
margin-top: 12px;
display: flex;
flex-direction: row;
gap: 12px;
align-items: baseline;
}
.upload-links form {
margin: 0;
}
body.dragging::after {
content: "drop file to select";
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: rgb(0 0 0 / 30%);
color: var(--text);
font-size: 1.5rem;
pointer-events: none;
}
.upload-metadata {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.upload-metadata th,
.upload-metadata td {
padding: 8px 0;
border-bottom: 1px solid var(--border);
text-align: left;
vertical-align: top;
overflow-wrap: anywhere;
}
.upload-metadata th:first-child {
width: 20%;
padding-right: 16px;
}
.upload-metadata th[scope="row"] {
color: var(--text-muted);
font-weight: bold;
}
code {
background-color: var(--surface-between);
padding-inline: 3px;
border: 1px solid var(--surface-hover);
}
.submit-container {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.noscript {
border: var(--border-strong);
background-color: var(--surface-between);
width: 100%;
display: block;
font-size: larger;
padding: 0.5rem;
margin-bottom: 5px;
}
.full-dropdown {
background: var(--bg);
display: block;
width: 100%;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-top: 6px;
margin-bottom: 12px;
}
.loading {
position: relative;
overflow: hidden;
background: var(--surface);
isolation: isolate;
}
.loading::before {
content: "";
position: absolute;
inset: 0;
width: 200%;
background: repeating-linear-gradient(
45deg,
var(--surface-hover) 0 25%,
transparent 25% 50%
);
background-size: 1em 1em;
animation: barStripe 1s linear infinite;
z-index: -1;
}
@keyframes barStripe {
to {
transform: translateX(-1em);
}
}
+18
View File
@@ -0,0 +1,18 @@
const link = document.getElementById("copy-link");
if (link && navigator.clipboard?.writeText) {
link.style.display = "";
link.hidden = false;
link.onclick = async (e) => {
e.preventDefault();
try {
await navigator.clipboard.writeText(`${location.origin}/${link.dataset.id}${link.dataset.extension}`);
link.textContent = "copied";
setTimeout(() => {
link.textContent = "copy link";
}, 2000);
} catch (error) {
console.error("failed to copy link:", error);
}
};
}
+46
View File
@@ -0,0 +1,46 @@
const fileInput = document.getElementById("upload-file");
function isFile(event) {
return event.dataTransfer.types.includes("Files");
}
function resetDrag() {
document.body.classList.remove("dragging");
}
document.addEventListener("dragenter", (event) => {
if (!isFile(event)) return;
event.preventDefault();
document.body.classList.add("dragging");
});
document.addEventListener("dragover", (event) => {
if (!isFile(event)) return;
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
});
document.addEventListener("dragleave", () => {
resetDrag();
});
document.addEventListener("drop", (event) => {
resetDrag();
if (!isFile(event)) return;
event.preventDefault();
const file = event.dataTransfer.files[0];
if (!file) return;
const transfer = new DataTransfer();
transfer.items.add(file);
fileInput.files = transfer.files;
document.getElementById("type-file").checked = true;
fileInput.dispatchEvent(new Event("change", { bubbles: true }));
});
document.addEventListener("dragend", resetDrag);
+32
View File
@@ -0,0 +1,32 @@
function hasLeadingZeroBits(bytes, requiredBits) {
const whole = Math.floor(requiredBits / 8);
const remaining = requiredBits % 8;
for (let i = 0; i < whole; i++) {
if (bytes[i] !== 0) return false;
}
return remaining === 0 || bytes[whole] >>> (8 - remaining) === 0;
}
self.onmessage = async ({ data }) => {
const { challenge, difficulty, startNonce = 0 } = data;
if (difficulty < 0 || difficulty > 256 || !Number.isInteger(difficulty)) {
throw new Error("Invalid difficulty");
}
console.log(`[PoW] Difficulty: ${difficulty}, Starting Nonce: ${startNonce}, Challenge: ${challenge}`)
const startTime = performance.now();
const encoder = new TextEncoder();
for (let nonce = startNonce; ; nonce++) {
const input = encoder.encode(`${challenge}${nonce}`);
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", input));
if (hasLeadingZeroBits(digest, difficulty)) {
const hashHex = Array.from(digest).map((b) => b.toString(16).padStart(2, "0")).join("");
const elapsed = performance.now() - startTime;
const attempts = nonce - startNonce + 1;
console.log(`[PoW] took ${elapsed} ms to solve challenge`)
console.log(`[PoW] ${(attempts / (elapsed / 1000)).toFixed(0)} hashes/s`)
console.log(`[PoW] Result: ${hashHex}, Nonce: ${nonce}`)
self.postMessage({ nonce: nonce, hash: hashHex, });
return;
}
}
};
+17
View File
@@ -0,0 +1,17 @@
const worker = new Worker("/js/pow-worker.js");
const reportForm = document.getElementById("report-form");
const submitBtn = document.getElementById("submit-btn");
const powLabel = document.getElementById("pow-label");
const challenge = reportForm.dataset;
submitBtn.disabled = true;
worker.onmessage = ({ data }) => {
submitBtn.disabled = false;
powLabel.style.display = "none";
submitBtn.classList.remove("loading");
document.getElementById("pow-result").value = data.hash;
document.getElementById("pow-nonce").value = data.nonce;
}
worker.postMessage({
challenge: reportForm.dataset.challengeData,
difficulty: Number.parseInt(reportForm.dataset.challengeDifficulty, 10),
})