.leave-a-review {
max-width: 400px;
width: 100%;
text-align: center;
}#negative {
display: none;
padding-top: 40px;
}.rating-box {
padding: 25px 50px;
background-color: #f1f1f1;
border-radius: 25px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
text-align: center;
}@media (max-width: 768px) {
.rating-box {
padding: 15px 15px;
background-color: #f1f1f1;
border-radius: 25px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
text-align: center;
justify-content: center;
display: flex;
}
}.rating-box h3 {
font-size: 22px;
font-weight: 600;
margin-bottom: 20px;
}
.rating-box .stars {
display: flex;
align-items: center;
gap: 25px;
}
.stars i {
font-size: 35px;
color: #b5b8b1;
transition: all 0.2s;
cursor: pointer;
}
.stars i.active,
.stars i.hover {
color: #ffb851;
transform: scale(1.2);
}// Constants
const stars = document.querySelectorAll(".stars i");
const starsNone = document.querySelector(".rating-box");// Function
function openNewTabFromUrl() {
// Get the current URL and extract the anchor
const url = window.location.href;
const parsedUrl = new URL(url);
const anchor = parsedUrl.hash.substring(1); // Remove the '#' from the anchorconst validAnchors = {
"location-1": "https://g.page/r/XXXXX/review",
"location-2": "https://g.page/r/YYYYY/review",
"location-3": "https://g.page/r/ZZZZZ/review",
};let newUrl = validAnchors[anchor];
if (newUrl == null) {
console.warn("default");
//default link
newUrl = "https://search.google.com/local/writereview?placeid=ChIJ2Xy7M_cOVIgRpZxI9vkfgdY";
}// Open a new tab with the corresponding URL
window.open(newUrl, "_blank");
}//openform
function showNegative() {
const negativeElement = document.getElementById("negative");if (negativeElement) {
negativeElement.setAttribute("style", "display:block !important");
console.log("negative opened");
} else {
console.warn('Element with ID "negative" not found.');
}
}// Function to handle the rating actions
function handleRatingActions(rating) {
if (/*rating === 4 ||*/ rating === 5) {
openNewTabFromUrl();
} else if (rating >= 1 && rating {
if (index1 >= index2) {
star.classList.add("active");
} else {
star.classList.remove("active");
}
});
}// Function to highlight stars on hover
function highlightStarsOnHover(index1) {
stars.forEach((star, index2) => {
if (index1 >= index2) {
star.classList.add("hover");
} else {
star.classList.remove("hover");
}
});
}// Add event listeners to stars
stars.forEach((star, index1) => {
star.addEventListener("click", () => {
updateStarsDisplay(index1);
const rating = index1 + 1;
handleRatingActions(rating);
});star.addEventListener("mouseover", () => {
highlightStarsOnHover(index1);
});star.addEventListener("mouseout", () => {
stars.forEach((star) => {
star.classList.remove("hover");
});
});
});