-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (55 loc) · 2.14 KB
/
Copy pathscript.js
File metadata and controls
65 lines (55 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// MECHANIC52 - Pure Vanilla JS Script
document.addEventListener('DOMContentLoaded', function () {
// 1. Live Clock for "работаем прямо сейчас, HH:MM"
var clockEl = document.getElementById('liveClock');
function updateLiveClock() {
if (!clockEl) return;
var now = new Date();
var hours = String(now.getHours()).padStart(2, '0');
var minutes = String(now.getMinutes()).padStart(2, '0');
clockEl.textContent = hours + ':' + minutes;
}
updateLiveClock();
setInterval(updateLiveClock, 30000); // update every 30 sec
// 2. Smooth Scroll for Symptoms Anchor Links
var anchorLinks = document.querySelectorAll('a[href^="#"]');
anchorLinks.forEach(function (link) {
link.addEventListener('click', function (e) {
var targetId = this.getAttribute('href');
if (targetId === '#' || !targetId) return;
var targetEl = document.querySelector(targetId);
if (targetEl) {
e.preventDefault();
targetEl.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// 3. Smart Sticky Call Bar (shows ONLY when no main call button is in viewport)
var stickyBar = document.querySelector('.sticky-call-bar');
var allButtons = document.querySelectorAll('.btn:not(.sticky-call-bar)');
if (stickyBar && allButtons.length > 0) {
function checkVisibility() {
var isAnyButtonInViewport = false;
var windowHeight = window.innerHeight || document.documentElement.clientHeight;
for (var i = 0; i < allButtons.length; i++) {
var rect = allButtons[i].getBoundingClientRect();
if (rect.top < (windowHeight - 10) && rect.bottom > 10) {
isAnyButtonInViewport = true;
break;
}
}
if (!isAnyButtonInViewport) {
stickyBar.classList.add('sticky-active');
} else {
stickyBar.classList.remove('sticky-active');
}
}
// Run check immediately on load and on scroll/resize
checkVisibility();
window.addEventListener('scroll', checkVisibility, { passive: true });
window.addEventListener('resize', checkVisibility, { passive: true });
}
});