// Объединяем все JS-файлы
// Содержимое navbar.js
// Содержимое footer.js
// Оригинальный код script.js
// Dark mode toggle functionality
function toggleDarkMode() {
const html = document.documentElement;
html.classList.toggle('dark');
localStorage.setItem('darkMode', html.classList.contains('dark'));
}
// Initialize dark mode based on user preference
function initDarkMode() {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const storedPreference = localStorage.getItem('darkMode');
if (storedPreference === 'false') {
document.documentElement.classList.remove('dark');
} else if (storedPreference === 'true' || prefersDark) {
document.documentElement.classList.add('dark');
}
}
// Smooth scrolling for anchor links
function initSmoothScroll() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
}
// Intersection Observer for animations
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('section-visible');
}
});
}, observerOptions);
// Observe all sections with the fade-in class
document.querySelectorAll('.section-fade-in').forEach(section => {
observer.observe(section);
});
}
// Equipment data
const equipmentData = [
{
name: "Сканер Medit T310",
description: "Точность сканирования 9 мкм, полная дуга за 18 секунд",
icon: "scan",
image: "https://static.photos/technology/640x360/1"
},
{
name: "Фрезерный станок Bloomden X5",
description: "Премиальный уровень, точная обработка материалов",
icon: "tool",
image: "https://static.photos/technology/640x360/2"
},
{
name: "3D принтер Asiga MAX UV",
description: "Разрешение печати 27 микрон, ювелирная точность",
icon: "printer",
image: "https://static.photos/technology/640x360/3"
}
];
// Services data
const servicesData = [
{
title: "E.Max конструкции",
price: "от 4500 руб.",
duration: "4 дня",
link: "/emax"
},
{
title: "Металлокерамика CAD/CAM",
price: "от 4000 руб.",
duration: "4 дня",
link: "/metal-cad-cam"
},
{
title: "Циркониевые конструкции",
price: "от 5500 руб.",
duration: "4 дня",
link: "/bezmetall-ceramic-zro2"
}
];
// Form handling
function initFormHandling() {
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
// Add form submission logic here
console.log('Form submitted');
});
});
}
// Statistics counter animation
function animateCounters() {
const counters = document.querySelectorAll('.counter');
const speed = 200;
counters.forEach(counter => {
const target = +counter.innerText;
const increment = target / speed;
let current = 0;
const updateCounter = () => {
if (current < target) {
current += increment;
counter.innerText = Math.ceil(current);
setTimeout(updateCounter, 1);
} else {
counter.innerText = target;
}
};
updateCounter();
});
}
// Mobile menu functionality
function initMobileMenu() {
const mobileMenuButton = document.querySelector('[data-mobile-menu]');
const mobileMenu = document.querySelector('[data-mobile-menu-content]');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
mobileMenu.classList.add('slide-down');
});
}
}
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
initDarkMode();
initSmoothScroll();
initScrollAnimations();
initFormHandling();
initMobileMenu();
// Re-initialize feather icons after dynamic content
feather.replace();
});
// Add event listener for window resize to handle mobile menu
window.addEventListener('resize', function() {
if (window.innerWidth > 768) {
const mobileMenu = document.querySelector('[data-mobile-menu-content]');
if (mobileMenu) {
mobileMenu.classList.add('hidden');
}
}
});
// Performance optimization: Debounce function
function debounce(func, wait, immediate) {
let timeout;
return function() {
const context = this, args = arguments;
const later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
// Lazy loading for images
function initLazyLoading() {
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.classList.remove('lazy');
observer.unobserve(img);
}
});
});
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
}
// Add to existing DOMContentLoaded event listener
document.addEventListener('DOMContentLoaded', function() {
// ... existing code ...
initLazyLoading();
});