comments.js
· 1.2 KiB · JavaScript
Raw
async function sendContact(ev) {
ev.preventDefault();
const thePage = window.location.href;
const senderAddress = document.getElementById('emailInput').value;
const senderMessage = document.getElementById('messageInput').value;
if (document.getElementById('dopost').checked) {
postpref = 'do';
} else if (document.getElementById('dontpost').checked) {
postpref = 'do not';
} else {
postpref = 'either';
};
if (document.getElementById('doreply').checked) {
replypref = 'do';
} else if (document.getElementById('dontreply').checked) {
replypref = 'do not';
} else {
replypref = 'either';
};
const gtsUrl = 'https://kes.praze.net/api/v1/statuses';
const response = await fetch(gtsUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer TOKEN',
},
body: JSON.stringify({'status' : 'new comment on ' + thePage + ' from an anonymous person (' + senderAddress + ')\n\n' + senderMessage + '\n\npost: ' + postpref + ', reply: ' + replypref}),
});
if (response.ok) {
alert('Comment submitted, thank you!');
} else {
alert('This is fucked, sorry. Email me instead, whatever at praze dot net!');
}
document.getElementById("theform").reset();
}
| 1 | async 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 | } |