@@ 26,7 26,7 @@ function encodeAsFormData(obj) {
return urlEncodedDataPairs.join('&');
}
function postReaction(reaction) {
function postReaction(reaction, callback) {
let xhr = new XMLHttpRequest();
xhr.open('POST', "/api/comment/react", true);
@@ 36,6 36,7 @@ function postReaction(reaction) {
xhr.onload = function(data) {
switch (xhr.status) {
case 200:
callback();
break;
case 429:
alert("Failed -- you can react at most once an hour.");
@@ 113,6 114,10 @@ window.addEventListener("load", () => {
postReaction({
"id": reactButton.getAttribute("data-react-to-id"),
"reaction": button.innerHTML
}, () => {
let reactAcknowledgement = document.createElement("span");
reactAcknowledgement.innerHTML = "successfully reacted!"
reactButton.replaceWith(reactAcknowledgement);
});
emojiPicker.remove();
});