Add survey

This commit is contained in:
2024-05-15 19:18:15 +02:00
parent 455fe2b3ac
commit 9d222c203c
6 changed files with 106 additions and 13 deletions

View File

@@ -269,7 +269,7 @@ async function onPageLoad() {
clearInterval(interval);
}
if (currentSite === "home" && currentPage === "settings") {
if (currentSite === "account" && currentPage === "settings") {
if (document.getElementById("user-settings")) {
await populateUserInfoFields(UserInfo);
}
@@ -656,11 +656,9 @@ async function reloadMemeVotes(memeID) {
if (0 < memeVotes) {
memeVoteCounterElement.classList.add("positive");
}
else if (0 > memeVotes) {
} else if (0 > memeVotes) {
memeVoteCounterElement.classList.add("negative");
}
else {
} else {
memeVoteCounterElement.classList.add("neutral");
}
@@ -681,18 +679,17 @@ async function reloadMemeVotes(memeID) {
}
async function voteMeme(memeID, isUpvote){
async function voteMeme(memeID, isUpvote) {
let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`);
let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`);
let memeVoteDelete = false;
if(isUpvote) {
if(memeVoteUpvoteElement.classList.contains("ri-arrow-up-circle-fill")){
if (isUpvote) {
if (memeVoteUpvoteElement.classList.contains("ri-arrow-up-circle-fill")) {
await deleteVoteMeme(memeID);
memeVoteDelete = true;
}
}
else {
if(memeVoteDownvoteElement.classList.contains("ri-arrow-down-circle-fill")){
} else {
if (memeVoteDownvoteElement.classList.contains("ri-arrow-down-circle-fill")) {
await deleteVoteMeme(memeID);
memeVoteDelete = true;
}
@@ -713,4 +710,20 @@ async function deleteVoteMeme(memeId) {
meme_id: memeId
}, "Hlas na meme bol zmazaný", "Nastala chyba pri mazaní hlasu na meme", true);
await reloadMemeVotes(memeId);
}
async function surveySubmit() {
const satisfaction = document.querySelector('input[name="satisfaction"]:checked').value;
const functionality = document.querySelector('input[name="functionality"]:checked').value;
const content = document.querySelector('input[name="content"]:checked').value;
const comment = document.querySelector('textarea[name="comment"]').value;
if (satisfaction && functionality && content && comment) {
doAction("/survey", {
action: "surveySubmit",
satisfaction: satisfaction,
functionality: functionality,
content: content,
comment: comment
});
}
}