Skip to content

Commit

Permalink
doing this up right
Browse files Browse the repository at this point in the history
  • Loading branch information
Siliconrob committed Apr 14, 2024
1 parent be80e7f commit c04338b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions html_helper/reviews.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@
<script>
let reviewsData = [];
let currentReview = 0;
//const reviewsUrl = "https://www.woodhavenrentals.com/reviews";
const reviewsUrl = "https://www.noworryvacations.com/reviews";

window.addEventListener("DOMContentLoaded", function () {
showReview(currentReview);
Expand Down Expand Up @@ -259,8 +257,24 @@
location.reload();
}
}

function getReviewUrl() {
const queryString = window.location.search;
console.log(queryString);
const urlParams = new URLSearchParams(queryString);
let reviewsUrl = "https://www.noworryvacations.com/reviews";

if (urlParams.has("reviews")) {
const reviewLink = urlParams.get('reviews') || null;
if (!(reviewLink == null)) {
reviewsUrl = reviewLink;
}
}
return reviewsUrl;
}

window.addEventListener("load", async (e) => {
window.addEventListener("load", async (e) => {
const reviewsUrl = getReviewUrl();
await getReviews(reviewsUrl);

document.querySelector(".next-review-btn").addEventListener("click", function () {
Expand Down Expand Up @@ -313,10 +327,11 @@
const currentReviewData = reviewsData[reviewIndex];
authorElement.textContent = currentReviewData.reviewer_name;
dateLineElement.textContent = currentReviewData.date_line;
const propertyName = currentReviewData.property_name || "";
let propertyName = currentReviewData.property_name || "";
if (propertyName !== "") {
propertyElement.textContent = `Stayed at ${propertyName}`;
}
propertyName = `Stayed at ${propertyName}`;
}
propertyElement.textContent = propertyName ?? "";
infoElement.textContent = currentReviewData.content;
}
}
Expand Down

0 comments on commit c04338b

Please sign in to comment.