const data = window.REPORT_DATA; const cards = document.querySelector("#cards"); const rows = document.querySelector("#summaryRows"); const rate = document.querySelector("#rate"); const criteria = document.querySelector("#criteria"); const notes = document.querySelector("#notes"); const lightbox = document.querySelector("#lightbox"); const lightboxImage = document.querySelector("#lightboxImage"); const lightboxSource = document.querySelector("#lightboxSource"); rate.textContent = `${data.generated}. ${data.rate}`; criteria.textContent = data.criteria; notes.innerHTML = data.notes.map((note) => `
  • ${note}
  • `).join(""); const labelByKind = { hotel: "отель", review: "отзыв", "traveler-video": "видео" }; function formatRub(value) { return new Intl.NumberFormat("ru-RU").format(value); } function formatByn(value) { return new Intl.NumberFormat("ru-RU").format(value); } function renderSummary(filter = "all") { const visible = data.hotels.filter((hotel) => filter === "all" || hotel.segment === filter); rows.innerHTML = visible.map((hotel) => ` ${hotel.name}
    ${hotel.rank} ${hotel.dates} ${hotel.nights} ${formatByn(hotel.price_byn)} BYN
    ${formatRub(hotel.price_rub)} RUB ${hotel.transfer} ${hotel.verdict} `).join(""); } function renderCards(filter = "all") { const visible = data.hotels.filter((hotel) => filter === "all" || hotel.segment === filter); cards.innerHTML = visible.map((hotel) => `

    ${hotel.name} ${hotel.stars}

    ${hotel.rank}

    ${formatByn(hotel.price_byn)} BYN ${formatRub(hotel.price_rub)} RUB. ${hotel.alt_price}
    Даты${hotel.dates}
    Ночи${hotel.nights}
    Питание${hotel.meal}
    Трансфер${hotel.transfer}
    Рейс${hotel.flight}
    Пляж${hotel.line}, ${hotel.beach}
    Рейтинг${hotel.rating}
    Сегмент${hotel.segment === "near-9" ? "рядом с 9" : hotel.segment + " тыс."}

    ${hotel.verdict}

    Плюсы

      ${hotel.pros.map((item) => `
    • ${item}
    • `).join("")}

    Риски

      ${hotel.cons.map((item) => `
    • ${item}
    • `).join("")}

    По фото и отзывам

    ${hotel.review}

    `).join(""); } function setFilter(filter) { document.querySelectorAll(".filter").forEach((button) => { button.classList.toggle("active", button.dataset.filter === filter); }); renderSummary(filter); renderCards(filter); } document.querySelectorAll(".filter").forEach((button) => { button.addEventListener("click", () => setFilter(button.dataset.filter)); }); cards.addEventListener("click", (event) => { const shot = event.target.closest(".shot"); if (!shot) return; lightboxImage.src = shot.dataset.full; lightboxSource.href = shot.dataset.source; lightbox.classList.add("open"); lightbox.setAttribute("aria-hidden", "false"); document.body.classList.add("lightbox-open"); }); document.querySelector("#closeLightbox").addEventListener("click", closeLightbox); lightbox.addEventListener("click", (event) => { if (event.target === lightbox) closeLightbox(); }); window.addEventListener("keydown", (event) => { if (event.key === "Escape") closeLightbox(); }); function closeLightbox() { lightbox.classList.remove("open"); lightbox.setAttribute("aria-hidden", "true"); document.body.classList.remove("lightbox-open"); lightboxImage.src = ""; } setFilter("all");