cf87ca5658
deploy / deploy (push) Successful in 3s
Both forms nested their status message as a child of the <form>, so form.hidden = true on success hid the confirmation right along with it — looked like nothing happened. Contact form now resets and stays usable (you can send another message) instead of disappearing; enroll form still hides after signup (no reason to sign up twice), but its confirmation is now a sibling so it actually stays visible. Also generalized the privacy policy's language from being anchored on email courses specifically to covering any use of the site.
56 lines
2.0 KiB
HTML
56 lines
2.0 KiB
HTML
{{ define "main" }}
|
|
<h1>Get in touch</h1>
|
|
<p style="opacity:0.85;">Tell me a bit about what you're working on — I read every message myself.</p>
|
|
|
|
<form id="contact-form" style="margin-top:2rem;">
|
|
<label for="name">Name</label>
|
|
<input type="text" id="name" name="name" required autocomplete="name">
|
|
|
|
<label for="email">Email</label>
|
|
<input type="email" id="email" name="email" required autocomplete="email">
|
|
|
|
<label for="message">Message</label>
|
|
<textarea id="message" name="message" rows="6" required></textarea>
|
|
|
|
<div class="field-honeypot" aria-hidden="true">
|
|
<label for="website">Leave this field empty</label>
|
|
<input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
|
|
</div>
|
|
|
|
<button type="submit" class="btn">Send message</button>
|
|
</form>
|
|
<p id="contact-status" role="status" style="margin-top:1rem;"></p>
|
|
|
|
<script>
|
|
(function () {
|
|
var form = document.getElementById("contact-form");
|
|
var status = document.getElementById("contact-status");
|
|
form.addEventListener("submit", function (e) {
|
|
e.preventDefault();
|
|
var payload = {
|
|
name: form.name.value,
|
|
email: form.email.value,
|
|
message: form.message.value,
|
|
website: form.website.value
|
|
};
|
|
var submitBtn = form.querySelector("button[type=submit]");
|
|
submitBtn.disabled = true;
|
|
status.textContent = "Sending…";
|
|
fetch("{{ .Site.Params.eec_base_url }}/contact", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(payload)
|
|
}).then(function (res) {
|
|
if (!res.ok) throw new Error("request failed");
|
|
form.reset();
|
|
submitBtn.disabled = false;
|
|
status.textContent = "Thanks — I'll get back to you soon.";
|
|
}).catch(function () {
|
|
submitBtn.disabled = false;
|
|
status.textContent = "Something went wrong sending that. Try again, or email hello@reground.org directly.";
|
|
});
|
|
});
|
|
})();
|
|
</script>
|
|
{{ end }}
|