Last active 2 hours ago

comments.js Raw
1async function sendContact(ev) {
2 ev.preventDefault();
3 const thePage = window.location.href;
4 const senderAddress = document.getElementById('emailInput').value;
5 const senderMessage = document.getElementById('messageInput').value;
6 if (document.getElementById('dopost').checked) {
7 postpref = 'do';
8 } else if (document.getElementById('dontpost').checked) {
9 postpref = 'do not';
10 } else {
11 postpref = 'either';
12 };
13 if (document.getElementById('doreply').checked) {
14 replypref = 'do';
15 } else if (document.getElementById('dontreply').checked) {
16 replypref = 'do not';
17 } else {
18 replypref = 'either';
19 };
20 const gtsUrl = 'https://kes.praze.net/api/v1/statuses';
21 const response = await fetch(gtsUrl, {
22 method: 'POST',
23 headers: {
24 'Content-Type': 'application/json',
25 'Authorization': 'Bearer TOKEN',
26 },
27 body: JSON.stringify({'status' : 'new comment on ' + thePage + ' from an anonymous person (' + senderAddress + ')\n\n' + senderMessage + '\n\npost: ' + postpref + ', reply: ' + replypref}),
28 });
29 if (response.ok) {
30 alert('Comment submitted, thank you!');
31 } else {
32 alert('This is fucked, sorry. Email me instead, whatever at praze dot net!');
33 }
34 document.getElementById("theform").reset();
35}