wheelease-express / script.js
Vinderos's picture
Develop a website for the company Soctaxi.com for transportation of disabled and sedentary citizens across Europe, the CIS, Belarus, and Russia. Shape it in yellow-black-white style, do everything in a modern way, in English and Russian, with the ability to switch the language of the site, make animations for the mouse, dynamic images and switching, a stylish one-page website. This is the website of a transportation company, use this particular style!
d5545c5 verified
Raw History Blame Contribute Delete
1.65 kB
// Language Switch
document.addEventListener('DOMContentLoaded', function() {
const langBtn = document.querySelector('.lang-btn');
const elementsToTranslate = document.querySelectorAll('[data-en], [data-ru]');
let currentLang = 'en';
langBtn.addEventListener('click', function() {
currentLang = currentLang === 'en' ? 'ru' : 'en';
langBtn.textContent = currentLang.toUpperCase();
elementsToTranslate.forEach(el => {
if (currentLang === 'en') {
el.textContent = el.getAttribute('data-en');
} else {
el.textContent = el.getAttribute('data-ru');
}
});
});
// Custom Cursor
const cursor = document.querySelector('.cursor');
document.addEventListener('mousemove', (e) => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Interactive elements effect
document.querySelectorAll('a, button').forEach(el => {
el.addEventListener('mouseenter', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(2)';
});
el.addEventListener('mouseleave', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(1)';
});
});
// Image slider
const hero = document.querySelector('.hero');
const images = [
'http://static.photos/transport/1200x630/1',
'http://static.photos/transport/1200x630/2',
'http://static.photos/transport/1200x630/3'
];
let currentImage = 0;
setInterval(() => {
currentImage = (currentImage + 1) % images.length;
hero.style.backgroundImage = `linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('${images[currentImage]}')`;
}, 5000);
});