Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RateUs.html #1320

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions RateUs.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,42 @@
</div>
<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script>
let feedbackSubmitted = false;

document.querySelectorAll('.emoji').forEach(emoji => {
emoji.addEventListener('click', () => {
document.querySelectorAll('.emoji').forEach(e => e.classList.remove('selected'));
emoji.classList.add('selected');
if (feedbackSubmitted) {
// Allow selecting an emoji again even if feedback was submitted
document.querySelectorAll('.emoji').forEach(e => e.classList.remove('selected'));
emoji.classList.add('selected');
} else {
document.querySelectorAll('.emoji').forEach(e => e.classList.remove('selected'));
emoji.classList.add('selected');
}
});
});

document.querySelector('.submit-button').addEventListener('click', () => {
const selectedEmoji = document.querySelector('.emoji.selected');
const feedback = document.querySelector('textarea').value;


if (feedbackSubmitted) {
Toastify({
text: "Review already submitted.",
backgroundColor: "orange",
gravity: "top",
position: "center",
duration: 3000
}).showToast();

// Clear textarea and stop emoji blinking on resubmit attempt
document.querySelector('textarea').value = '';
if (selectedEmoji) {
selectedEmoji.classList.remove('selected');
}
return;
}

if (selectedEmoji && feedback.trim() !== '') {
Toastify({
text: "Feedback submitted successfully!",
Expand All @@ -179,6 +204,15 @@
position: "center",
duration: 3000
}).showToast();

// Clear the textarea
document.querySelector('textarea').value = '';

// Remove the 'selected' class from the emoji to stop blinking
selectedEmoji.classList.remove('selected');

// Mark feedback as submitted
feedbackSubmitted = true;
} else {
Toastify({
text: "Please select an emoji and provide feedback.",
Expand All @@ -191,5 +225,5 @@
});
</script>
</body>
</html>

</html>