75 lines
4.4 KiB
JavaScript
75 lines
4.4 KiB
JavaScript
const translations = {
|
||
ru: {
|
||
nav_about: "О нас", nav_food: "Кухня", nav_location: "Где мы", nav_booking: "Бронь",
|
||
hero_title: "Добро пожаловать", hero_subtitle: "Ваш идеальный отдых на берегу Черного моря", hero_btn: "Забронировать номер",
|
||
about_title: "Море в шаговой доступности", about_subtitle: "Бескрайние пляжи Гудауты", about_text: "Наш отель расположен в живописном селе Мгудзырхуа. Мы предлагаем комфортные номера и прямой выход к морю.",
|
||
food_title: "Вкус Абхазии", food_subtitle: "Домашняя кухня из местных продуктов", food_text: "Почувствуйте гостеприимство! Свежайший сыр сулугуни, мамалыга, овощи с грядки и домашнее вино.",
|
||
loc_title: "Удобное расположение", book_title: "Забронировать отдых", label_name: "Ваше имя", label_phone: "Номер телефона", ph_name: "Иван Иванов",
|
||
fz152: "Согласие на обработку данных (152-ФЗ)", book_btn: "Отправить заявку", footer_text: "© 2026 Hotel 777. Абхазия, Мгудзырхуа.",
|
||
cookie_text: "Мы используем файлы cookie для улучшения работы сайта.", cookie_btn: "Согласен", alert_msg: "Спасибо! Ваша заявка принята."
|
||
},
|
||
en: {
|
||
nav_about: "About", nav_food: "Kitchen", nav_location: "Location", nav_booking: "Booking",
|
||
hero_title: "Welcome", hero_subtitle: "Your perfect vacation on the Black Sea", hero_btn: "Book a room",
|
||
about_title: "Sea at your doorstep", food_title: "Taste of Abkhazia", food_subtitle: "Local home cooking",
|
||
alert_msg: "Thank you! Your request has been received."
|
||
},
|
||
ab: {
|
||
nav_about: "Ҳазкы", nav_food: "Афатә", nav_location: "Аҭыԥ", nav_booking: "Аанкылара",
|
||
hero_title: "Бзиала шәаабеит", hero_subtitle: "Амшын аԥшаҳәаҿы адырра", hero_btn: "Ауада аанкылара",
|
||
food_title: "Аԥсны аҳамҭа", alert_msg: "Ишәҭабуп! Азҳәара дәықәҵоуп."
|
||
}
|
||
};
|
||
|
||
document.addEventListener("DOMContentLoaded", () => {
|
||
// Прогрессивная загрузка фона
|
||
const hero = document.querySelector('.hero');
|
||
const imgHD = new Image();
|
||
imgHD.src = 'img/h777.webp';
|
||
imgHD.onload = () => { hero.style.backgroundImage = `linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('${imgHD.src}')`; };
|
||
|
||
// Локализация
|
||
const langSelect = document.getElementById('langSwitch');
|
||
let currentLang = localStorage.getItem('siteLang') || 'ru';
|
||
|
||
const updateText = (lang) => {
|
||
document.querySelectorAll('[data-i18n]').forEach(el => {
|
||
const key = el.getAttribute('data-i18n');
|
||
if (translations[lang][key]) el.innerHTML = translations[lang][key];
|
||
});
|
||
document.querySelectorAll('[data-i18n-ph]').forEach(el => {
|
||
const key = el.getAttribute('data-i18n-ph');
|
||
if (translations[lang][key]) el.placeholder = translations[lang][key];
|
||
});
|
||
localStorage.setItem('siteLang', lang);
|
||
};
|
||
|
||
langSelect.value = currentLang;
|
||
updateText(currentLang);
|
||
langSelect.onchange = (e) => updateText(e.target.value);
|
||
|
||
// Cookie
|
||
if (!localStorage.getItem('cookiesAccepted')) {
|
||
setTimeout(() => document.getElementById('cookieBanner').classList.add('show'), 2000);
|
||
}
|
||
|
||
// Форма
|
||
document.getElementById('bookingForm').onsubmit = (e) => {
|
||
e.preventDefault();
|
||
alert(translations[localStorage.getItem('siteLang') || 'ru'].alert_msg);
|
||
};
|
||
|
||
// Анимации при скролле
|
||
const obs = new IntersectionObserver(entries => {
|
||
entries.forEach(en => { if(en.isIntersecting) en.target.style.animationPlayState = 'running'; });
|
||
});
|
||
document.querySelectorAll('.animate').forEach(el => {
|
||
el.style.animationPlayState = 'paused';
|
||
obs.observe(el);
|
||
});
|
||
});
|
||
|
||
function acceptCookies() {
|
||
localStorage.setItem('cookiesAccepted', 'true');
|
||
document.getElementById('cookieBanner').classList.remove('show');
|
||
} |