74 lines
3.1 KiB
JavaScript
74 lines
3.1 KiB
JavaScript
// 食 block: Кухня загружается отдельно как блок на странице
|
|
function generateFoodHTML(lang) {
|
|
const t = (k) => (window.translations[lang] && window.translations[lang][k]) || k;
|
|
return `
|
|
<section>
|
|
<h2 class="section-title animate" data-i18n="food_title">${t('food_title')}</h2>
|
|
<div class="about-grid">
|
|
<div class="about-image-wrapper animate delay-1">
|
|
<img src="img/food.webp" alt="${t('food_subtitle')}" class="about-img" loading="lazy">
|
|
</div>
|
|
<div class="about-text animate delay-2">
|
|
<h3>${t('food_subtitle')}</h3>
|
|
<p>${t('food_text')}</p>
|
|
<div class="facts-grid food-features">
|
|
<div class="fact-card">
|
|
<div class="fact-icon">🍽️</div>
|
|
<div class="fact-text">${t('food_request')}</div>
|
|
</div>
|
|
<div class="fact-card">
|
|
<div class="fact-icon">👨🍳</div>
|
|
<div class="fact-text">${t('food_chef')}</div>
|
|
</div>
|
|
<div class="fact-card">
|
|
<div class="fact-icon">🕒</div>
|
|
<div class="fact-text">${t('food_breakfast')}</div>
|
|
</div>
|
|
<div class="fact-card">
|
|
<div class="fact-icon">🕒</div>
|
|
<div class="fact-text">${t('food_lunch')}</div>
|
|
</div>
|
|
<div class="fact-card">
|
|
<div class="fact-icon">🕒</div>
|
|
<div class="fact-text">${t('food_dinner')}</div>
|
|
</div>
|
|
</div>
|
|
<p class="food-note">📢 <em>${t('food_note')}</em></p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
`;
|
|
}
|
|
|
|
function renderFood(lang) {
|
|
const foodSection = document.getElementById('food');
|
|
if (!foodSection) return;
|
|
foodSection.innerHTML = generateFoodHTML(lang);
|
|
|
|
// Анимации на повторный вход
|
|
document.querySelectorAll('.animate').forEach(el => {
|
|
if (el.style.animationPlayState !== 'running') {
|
|
el.style.animationPlayState = 'paused';
|
|
}
|
|
});
|
|
}
|
|
|
|
function updateFoodLanguage(lang) {
|
|
if (document.getElementById('food').innerHTML.trim() !== '') {
|
|
// обновляем тексты, если уже отрисован блок
|
|
const header = document.querySelector('#food .section-title');
|
|
if (header) header.innerHTML = window.translations[lang].food_title;
|
|
// Перерисуем контент для корректной подстановки
|
|
renderFood(lang);
|
|
} else {
|
|
renderFood(lang);
|
|
}
|
|
}
|
|
|
|
window.updateFoodLanguage = updateFoodLanguage;
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const currentLang = localStorage.getItem('siteLang') || 'ru';
|
|
renderFood(currentLang);
|
|
});
|