Skip to content

Commit

Permalink
send comment with enter key
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed May 16, 2024
1 parent 231251c commit ece5139
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,15 @@ function openRatingPopup(popupId, profId) {
});
}

function openCommentsPopup(popupId, profId) {
openPopup(popupId);

getComments(profId).then(function (comments) {
loadComments(comments);
});

recreateNode(document.getElementById("commentPopup"), true);

const sendCommentButton = document.getElementById("sendCommentButton");
const sendCommentInput = document.getElementById("commentContentInput");
console.log(sendCommentInput.value);
sendCommentInput.addEventListener("input", function (e) {
alert(e.key);
if (e.key == "Enter") {
onCommentSend();
}
});
sendCommentButton.addEventListener("click", () => onCommentSend());
}

function onCommentSend() {
function onCommentSend(profId) {
sendComment(
document.getElementById("commentContentInput").value,
profId
).then(() => {
getComments(profId).then(function (comments) {
loadComments(comments);
});
document.getElementById("commentContentInput").value = "";
});
}

Expand All @@ -78,17 +58,15 @@ function openCommentsPopup(popupId, profId) {
recreateNode(document.getElementById("commentPopup"), true);

const sendCommentButton = document.getElementById("sendCommentButton");
sendCommentButton.addEventListener("click", () => {
sendComment(
document.getElementById("commentContentInput").value,
profId
).then(() => {
getComments(profId).then(function (comments) {
loadComments(comments);
});
document.getElementById("commentContentInput").value = "";
});
const sendCommentInput = document.getElementById("commentContentInput");

sendCommentInput.addEventListener("keyup", function (e) {
if (e.key == "Enter") {
onCommentSend(profId);
}
});

sendCommentButton.addEventListener("click", () => onCommentSend(profId));
}

function closePopup(id) {
Expand Down

0 comments on commit ece5139

Please sign in to comment.