Initial import
144
app.js
Normal file
@ -0,0 +1,144 @@
|
||||
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) => `<li>${note}</li>`).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) => `
|
||||
<tr>
|
||||
<td><strong>${hotel.name}</strong><br><span class="badge ${hotel.segment === "8-9" ? "" : "warn"}">${hotel.rank}</span></td>
|
||||
<td>${hotel.dates}</td>
|
||||
<td>${hotel.nights}</td>
|
||||
<td class="price">${formatByn(hotel.price_byn)} BYN<br><span>${formatRub(hotel.price_rub)} RUB</span></td>
|
||||
<td>${hotel.transfer}</td>
|
||||
<td>${hotel.verdict}</td>
|
||||
</tr>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function renderCards(filter = "all") {
|
||||
const visible = data.hotels.filter((hotel) => filter === "all" || hotel.segment === filter);
|
||||
cards.innerHTML = visible.map((hotel) => `
|
||||
<article class="hotel-card" data-segment="${hotel.segment}">
|
||||
<div class="gallery" aria-label="Фото ${hotel.name}">
|
||||
${hotel.images.map((image, index) => `
|
||||
<button class="shot" data-full="${image.file}" data-source="${image.source}" type="button">
|
||||
<img src="${image.file}" loading="${index < 2 ? "eager" : "lazy"}" alt="${hotel.name}: ${labelByKind[image.kind] || "фото"}" />
|
||||
<span class="tag">${labelByKind[image.kind] || image.kind}</span>
|
||||
</button>
|
||||
`).join("")}
|
||||
</div>
|
||||
|
||||
<div class="hotel-info">
|
||||
<div class="hotel-head">
|
||||
<div class="hotel-title">
|
||||
<h3>${hotel.name} ${hotel.stars}</h3>
|
||||
<p>${hotel.rank}</p>
|
||||
</div>
|
||||
<div class="hotel-price">
|
||||
<strong>${formatByn(hotel.price_byn)} BYN</strong>
|
||||
<span>${formatRub(hotel.price_rub)} RUB. ${hotel.alt_price}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="facts">
|
||||
<div class="fact"><span>Даты</span><strong>${hotel.dates}</strong></div>
|
||||
<div class="fact"><span>Ночи</span><strong>${hotel.nights}</strong></div>
|
||||
<div class="fact"><span>Питание</span><strong>${hotel.meal}</strong></div>
|
||||
<div class="fact"><span>Трансфер</span><strong>${hotel.transfer}</strong></div>
|
||||
<div class="fact"><span>Рейс</span><strong>${hotel.flight}</strong></div>
|
||||
<div class="fact"><span>Пляж</span><strong>${hotel.line}, ${hotel.beach}</strong></div>
|
||||
<div class="fact"><span>Рейтинг</span><strong>${hotel.rating}</strong></div>
|
||||
<div class="fact"><span>Сегмент</span><strong>${hotel.segment === "near-9" ? "рядом с 9" : hotel.segment + " тыс."}</strong></div>
|
||||
</div>
|
||||
|
||||
<p class="verdict">${hotel.verdict}</p>
|
||||
|
||||
<div class="columns">
|
||||
<div>
|
||||
<h4>Плюсы</h4>
|
||||
<ul class="pros">${hotel.pros.map((item) => `<li>${item}</li>`).join("")}</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Риски</h4>
|
||||
<ul class="cons">${hotel.cons.map((item) => `<li>${item}</li>`).join("")}</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="review">
|
||||
<h4>По фото и отзывам</h4>
|
||||
<p>${hotel.review}</p>
|
||||
</div>
|
||||
|
||||
<div class="links">
|
||||
<h4>Источники</h4>
|
||||
<a href="${hotel.top_source}" target="_blank" rel="noreferrer">TopHotels media</a>
|
||||
<a href="${hotel.trip}" target="_blank" rel="noreferrer">Tripadvisor</a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
`).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");
|
||||
BIN
assets/first-class-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
assets/first-class-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
assets/first-class-03-review.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
assets/first-class-04-review.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
assets/first-class-05-review.jpg
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
assets/first-class-06-review.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
assets/first-class-07-review.jpg
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
assets/first-class-08-review.jpg
Normal file
|
After Width: | Height: | Size: 109 KiB |
BIN
assets/first-class-09-review.jpg
Normal file
|
After Width: | Height: | Size: 110 KiB |
BIN
assets/first-class-10-review.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
assets/first-class-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/first-class-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
assets/galaxy-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
assets/galaxy-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
assets/galaxy-03-review.jpg
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
assets/galaxy-04-review.jpg
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
assets/galaxy-05-review.jpg
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
assets/galaxy-06-review.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
assets/galaxy-07-review.jpg
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
assets/galaxy-08-review.jpg
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
assets/galaxy-09-review.jpg
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/galaxy-10-review.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
assets/hedef-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
assets/hedef-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
assets/hedef-03-review.jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
assets/hedef-04-review.jpg
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
assets/hedef-05-review.jpg
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
assets/hedef-06-review.jpg
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
assets/hedef-07-review.jpg
Normal file
|
After Width: | Height: | Size: 99 KiB |
BIN
assets/hedef-08-review.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/hedef-09-review.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
assets/hedef-10-review.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
assets/hedef-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
assets/hedef-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/insula-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
assets/insula-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
assets/insula-03-review.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
assets/insula-04-review.jpg
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
assets/insula-05-review.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
assets/insula-06-review.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
assets/insula-07-review.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
assets/insula-08-review.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
assets/insula-09-review.jpg
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
assets/insula-10-review.jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
assets/insula-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/insula-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/kirbiyik-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
assets/kirbiyik-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
assets/kirbiyik-03-review.jpg
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
assets/kirbiyik-04-review.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
assets/kirbiyik-05-review.jpg
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
assets/kirbiyik-06-review.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
assets/kirbiyik-07-review.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
assets/kirbiyik-08-review.jpg
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
assets/kirbiyik-09-review.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
assets/kirbiyik-10-review.jpg
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
assets/kirbiyik-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/kirbiyik-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/mc-beach-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
assets/mc-beach-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
assets/mc-beach-03-review.jpg
Normal file
|
After Width: | Height: | Size: 99 KiB |
BIN
assets/mc-beach-04-review.jpg
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
assets/mc-beach-05-review.jpg
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
assets/mc-beach-06-review.jpg
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
assets/mc-beach-07-review.jpg
Normal file
|
After Width: | Height: | Size: 184 KiB |
BIN
assets/mc-beach-08-review.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
assets/mc-beach-09-review.jpg
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
assets/mc-beach-10-review.jpg
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/mc-beach-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/mc-beach-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
assets/miarosa-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/miarosa-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/miarosa-03-review.jpg
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
assets/miarosa-04-review.jpg
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/miarosa-05-review.jpg
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/miarosa-06-review.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
assets/miarosa-07-review.jpg
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
assets/miarosa-08-review.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
assets/miarosa-09-review.jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
assets/miarosa-10-review.jpg
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
assets/miarosa-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/miarosa-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/nora-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
assets/nora-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
assets/nora-03-review.jpg
Normal file
|
After Width: | Height: | Size: 196 KiB |
BIN
assets/nora-04-review.jpg
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
assets/nora-05-review.jpg
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
assets/nora-06-review.jpg
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
assets/nora-07-review.png
Normal file
|
After Width: | Height: | Size: 275 KiB |
BIN
assets/nora-08-review.jpg
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
assets/nora-09-review.jpg
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
assets/nora-10-review.jpg
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
assets/nora-11-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/nora-12-traveler-video.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/perre-delta-01-hotel.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
assets/perre-delta-02-hotel.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
assets/perre-delta-03-review.jpg
Normal file
|
After Width: | Height: | Size: 122 KiB |
BIN
assets/perre-delta-04-review.jpg
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
assets/perre-delta-05-review.jpg
Normal file
|
After Width: | Height: | Size: 53 KiB |