79 lines
2.9 KiB
JavaScript
79 lines
2.9 KiB
JavaScript
// Файл footer.js – динамическая генерация подвала сайта и добавление изображения техники в шапку
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
// ----- 1. Вставка изображения техники в шапку (на всех страницах) -----
|
||
function addFleetImageToHeader() {
|
||
const headerInner = document.querySelector('.header-inner');
|
||
if (!headerInner) return;
|
||
if (document.querySelector('.header-fleet-image')) return;
|
||
|
||
const logo = headerInner.querySelector('.logo');
|
||
if (!logo) return;
|
||
|
||
const fleetDiv = document.createElement('div');
|
||
fleetDiv.className = 'header-fleet-image';
|
||
fleetDiv.style.width = '20%';
|
||
fleetDiv.style.maxWidth = 'none';
|
||
fleetDiv.style.margin = '0 20px';
|
||
|
||
fleetDiv.innerHTML = `
|
||
<img src="/fleet-all"
|
||
alt="Весь парк техники СТС-Авто: экскаваторы, тракторы, краны, самосвалы, тралы, экскаватор-амфибия"
|
||
title="Наша техника для демонтажа трубопроводов"
|
||
style="width: 100%; height: auto; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);">
|
||
`;
|
||
logo.insertAdjacentElement('afterend', fleetDiv);
|
||
}
|
||
|
||
addFleetImageToHeader();
|
||
|
||
// ----- 2. Генерация футера с улучшенной структурой -----
|
||
if (document.getElementById('dynamic-footer')) return;
|
||
|
||
const footer = document.createElement('footer');
|
||
footer.id = 'dynamic-footer';
|
||
footer.innerHTML = `
|
||
<div class="container">
|
||
<div class="footer-grid">
|
||
<div>
|
||
<h4>Контакты</h4>
|
||
<p>📍 <span id="footer-address"></span></p>
|
||
<p><span id="footer-phones"></span></p>
|
||
<p>✉️ <span id="footer-email"></span></p>
|
||
</div>
|
||
<div>
|
||
<h4>Деятельность</h4>
|
||
<p>Демонтаж нефтегазопроводов по России</p>
|
||
<p>Рекультивация земель, вывоз труб</p>
|
||
</div>
|
||
</div>
|
||
<div id="disclaimer-text" class="disclaimer"></div>
|
||
</div>
|
||
`;
|
||
|
||
// Добавляем стили для ссылок в футере (чтобы они были красивыми и кликабельными)
|
||
const footerStyles = document.createElement('style');
|
||
footerStyles.textContent = `
|
||
footer a {
|
||
color: #a0c4e2;
|
||
text-decoration: none;
|
||
transition: color 0.2s;
|
||
}
|
||
footer a:hover {
|
||
color: #e67e22;
|
||
text-decoration: underline;
|
||
}
|
||
#footer-phones a {
|
||
display: inline-block;
|
||
margin-bottom: 6px;
|
||
line-height: 1.4;
|
||
}
|
||
`;
|
||
document.head.appendChild(footerStyles);
|
||
|
||
const main = document.querySelector('main');
|
||
if (main) {
|
||
main.insertAdjacentElement('afterend', footer);
|
||
} else {
|
||
document.body.appendChild(footer);
|
||
}
|
||
}); |