1
0
forked from Kieran/route96
void-cat-rs/ui/index.html

100 lines
2.9 KiB
HTML
Raw Normal View History

2024-04-29 21:00:47 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
2024-04-30 21:38:14 +00:00
<title>void_cat_rs</title>
<style>
html {
background-color: black;
color: white;
2024-05-29 11:14:00 +00:00
font-size: 15px;
font-weight: 400;
font-family: Arial, serif;
}
.flex {
display: flex;
}
.flex-col {
flex-direction: column;
}
.gap-2 {
gap: 0.5rem;
2024-04-30 21:38:14 +00:00
}
</style>
2024-05-10 10:54:40 +00:00
<script>
async function uploadFiles(e) {
2024-05-29 11:14:00 +00:00
try {
const input = document.querySelector("#file");
const file = input.files[0];
console.debug(file);
2024-05-10 10:54:40 +00:00
2024-05-29 11:14:00 +00:00
const fd = new FormData();
fd.append("size", file.size.toString());
fd.append("caption", file.name);
fd.append("media_type", file.type);
fd.append("file", file);
fd.append("no_transform", document.querySelector("#no_transform").checked.toString())
2024-05-10 10:54:40 +00:00
2024-05-29 11:14:00 +00:00
const auth_event = await window.nostr.signEvent({
kind: 27235,
created_at: Math.floor(new Date().getTime() / 1000),
content: "",
tags: [
["u", `${window.location.protocol}//${window.location.host}/n96`],
["method", "POST"]
]
});
const rsp = await fetch("/n96", {
body: fd,
method: "POST",
headers: {
accept: "application/json",
authorization: `Nostr ${btoa(JSON.stringify(auth_event))}`,
},
});
console.debug(rsp);
const text = await rsp.text();
if (rsp.ok) {
document.querySelector("#log").append(JSON.stringify(JSON.parse(text), undefined, 2));
} else {
document.querySelector("#log").append(text);
}
document.querySelector("#log").append("\n");
} catch (ex) {
if (ex instanceof Error) {
alert(ex.message);
}
2024-05-10 10:54:40 +00:00
}
}
</script>
2024-04-29 21:00:47 +00:00
</head>
<body>
2024-05-10 10:54:40 +00:00
<h1>
Welcome to void_cat_rs
</h1>
2024-05-29 11:14:00 +00:00
<div class="flex flex-col gap-2">
<div>
2024-05-10 10:54:40 +00:00
Upload a file using NIP-96
2024-05-29 11:14:00 +00:00
</div>
<div style="color: #ff8383;">
2024-05-10 10:54:40 +00:00
You must have a nostr extension for this to work
2024-05-29 11:14:00 +00:00
</div>
2024-05-10 10:54:40 +00:00
<input type="file" id="file">
2024-05-29 11:14:00 +00:00
<div>
<input type="checkbox" id="no_transform">
<label for="no_transform">
Disable compression (images)
</label>
</div>
<div>
<button type="submit" onclick="uploadFiles(event)">
Upload
</button>
</div>
2024-05-10 10:54:40 +00:00
</div>
<pre id="log"></pre>
2024-04-29 21:00:47 +00:00
</body>
</html>