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

feat: reset form functionality to feedback form after display of confirmation message #829

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
27 changes: 19 additions & 8 deletions feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ document.addEventListener('DOMContentLoaded', () => {
const ratingTexts = document.querySelectorAll('[id$="-rating-text"]');
let currentRating = 0;

function colourStar(ind , container) {

function colourStar(ind, container) {
let s = container.querySelectorAll("span");
s = Array.from(s);
// remove existing rating
for(let i = 0; i < s.length; i++) {
for (let i = 0; i < s.length; i++) {
s[i].style.color = "white";
}

for(let i = 0; i < ind; i++) {
for (let i = 0; i < ind; i++) {
s[i].style.color = "#FFA500";
}
// console.log(container);
}

// Create 5 stars dynamically for each stars container
Expand All @@ -30,7 +28,7 @@ document.addEventListener('DOMContentLoaded', () => {
star.addEventListener('click', () => {
currentRating = i;
updateRating(index);
colourStar(i , starsContainer);
colourStar(i, starsContainer);
});

}
Expand All @@ -41,7 +39,6 @@ document.addEventListener('DOMContentLoaded', () => {
};
});


function submitFeedback() {
var feedbackInput = document.getElementById("feedback-input");
var feedback = feedbackInput.value.trim();
Expand All @@ -65,7 +62,21 @@ function submitFeedback() {
// Clear the feedback input box after the user acknowledges the success modal
if (result.isConfirmed || result.isDismissed) {
feedbackInput.value = "";
resetForm(); // Call resetForm function to reset the entire form
}
});
}

}
function resetForm() {
const starsContainers = document.getElementsByClassName("stars");
const ratingTexts = document.querySelectorAll('[id$="-rating-text"]');
let currentRating = 0;

Array.from(starsContainers).forEach((starsContainer, index) => {
const stars = starsContainer.querySelectorAll("span");
stars.forEach(star => {
star.style.color = "white"; // Reset star colors to default
});
ratingTexts[index].textContent = `Rating: ${currentRating}`; // Reset rating text
});
}
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ <h4>Reach Out To Us</h4>
return;
}
sendEmail(email);
event.target.reset();
});

function sendEmail(email) {
Expand Down Expand Up @@ -1436,4 +1437,4 @@ <h4>Reach Out To Us</h4>


</div>
<!-- New bubble background end -->
<!-- New bubble background end -->
Loading