zachery.lol/routes/contact/message/index.html

332 lines
8.9 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Direct Message</title>
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 50px;
min-height: 120vh;
margin: 0;
font-family: system-ui, -apple-system, sans-serif;
background: #060a10;
}
#fractal-canvas {
image-rendering: auto;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.form-container {
position: relative;
z-index: 1;
background: rgba(10, 14, 20, 0.55);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 16px;
color: #fff;
padding: 2.5rem 3rem;
width: 90%;
max-width: 560px;
min-height: 400px;
margin-bottom: 20px;
}
.back-link {
position: relative;
z-index: 1;
margin-top: 0.5rem;
}
.back-link a {
text-decoration: none;
color: rgba(255, 255, 255, 0.4);
font-size: 0.8rem;
letter-spacing: 0.04em;
transition: color 250ms ease;
}
.back-link a:hover {
color: rgba(255, 255, 255, 0.7);
}
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: 300;
font-size: 0.85rem;
letter-spacing: 0.04em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.6);
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
background: rgba(255, 255, 255, 0.06);
color: #fff;
font-family: inherit;
font-size: 0.95rem;
transition: border-color 250ms ease, box-shadow 250ms ease;
}
input[type="text"]:focus,
input[type="password"]:focus {
outline: none;
border-color: rgba(120, 200, 220, 0.3);
box-shadow: 0 0 0 3px rgba(120, 200, 220, 0.1);
}
textarea {
width: 100%;
height: 120px;
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
resize: vertical;
background: rgba(255, 255, 255, 0.06);
color: #fff;
font-family: inherit;
font-size: 0.95rem;
transition: border-color 250ms ease, box-shadow 250ms ease;
}
textarea:focus {
outline: none;
border-color: rgba(120, 200, 220, 0.3);
box-shadow: 0 0 0 3px rgba(120, 200, 220, 0.1);
}
button[type="submit"] {
width: 100%;
padding: 10px;
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.75);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
cursor: pointer;
font-family: inherit;
font-size: 0.85rem;
font-weight: 400;
letter-spacing: 0.06em;
text-transform: uppercase;
transition: all 250ms ease;
}
button[type="submit"]:hover {
color: #fff;
border-color: rgba(255, 255, 255, 0.2);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.expandable-section {
margin-top: 20px;
}
.expandable-header {
cursor: pointer;
padding: 10px;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 8px;
color: rgba(255, 255, 255, 0.5);
font-size: 0.85rem;
transition: all 250ms ease;
}
.expandable-header:hover {
color: rgba(255, 255, 255, 0.7);
border-color: rgba(255, 255, 255, 0.15);
}
.expandable-content {
display: none;
padding: 10px;
background: rgba(255, 255, 255, 0.03);
border-radius: 0 0 8px 8px;
color: rgba(255, 255, 255, 0.6);
font-size: 0.9rem;
line-height: 1.5;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
<script src="/routes/contact/pkg/message_tools.js"></script>
<script>
const { make_salt, make_key_bytes, box_message } = wasm_bindgen;
var serverPublicKey;
async function run() {
await wasm_bindgen();
await fetchPublicKey();
const form = document.getElementById("message-form");
form.addEventListener("submit", (event) => {
event.preventDefault();
submit();
});
}
async function fetchPublicKey() {
try {
const response = await fetch("/api/pubkey");
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const pubkeyJSON = await response.text();
serverPublicKey = JSON.parse(pubkeyJSON);
} catch (error) {
console.error("Error fetching public key:", error);
document.getElementById("status").textContent =
"Failed to load public key.";
}
}
async function submit() {
const user = document.getElementById("name").value;
const password = document.getElementById("password").value;
const message = document.getElementById("message").value;
const salt = make_salt();
const makeKeyBytesArgs = {
name: String(user),
password: String(password),
salt: [...salt],
};
const keyBytes = make_key_bytes(JSON.stringify(makeKeyBytesArgs));
const boxMessageArgs = {
user: String(user),
salt: [...salt],
user_sk: [...keyBytes],
remote_pk: [...serverPublicKey],
plaintext: String(message),
};
const boxed = box_message(JSON.stringify(boxMessageArgs));
const boxedObj = JSON.parse(boxed);
try {
const response = await fetch("/api/publish", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(boxedObj),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
alert("Sent!");
location.reload();
} catch (error) {
console.error("Error:", error);
alert("Failed to send message: " + error.message);
}
}
run();
</script>
<script>
function toggleSection() {
const content = document.getElementById("expandableContent");
const header = document.querySelector(".expandable-header");
if (content.style.display === "block") {
content.style.display = "none";
header.innerHTML = "How to use ▼";
} else {
content.style.display = "block";
header.innerHTML = "How to use ▲";
}
}
</script>
2026-07-24 08:51:40 +00:00
<link rel="preload" href="/routes/root/dist-strips.bin?v=1" as="fetch" crossorigin />
2026-07-24 09:06:42 +00:00
<script defer src="/routes/root/fractal-gl.js?v=13"></script>
</head>
<body>
<canvas id="fractal-canvas"></canvas>
<div class="form-container">
<form id="message-form">
<div class="input-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" />
</div>
<div class="input-group">
<label for="password">Password (optional)</label>
<input type="password" id="password" name="password" />
</div>
<div class="input-group">
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
</div>
<div class="input-group">
<button type="submit">Submit</button>
</div>
</form>
<div class="expandable-section">
<div class="expandable-header" onclick="toggleSection()">
How to use ▼
</div>
<div class="expandable-content" id="expandableContent">
<p>
Tell me who you are, and add an optional password. If I do not
otherwise have your contact information, please tell me the best way
to reach you back.
</p>
</div>
</div>
</div>
<nav class="back-link">
<a href="/contact">back to contact</a>
</nav>
2026-07-24 08:51:40 +00:00
<!-- fractal background loaded via deferred <script> in <head> -->
</body>
</html>